@mountaya/elements 0.1.0 → 0.2.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 +38 -0
- package/README.md +4 -3
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/agent/index.cjs +1152 -1905
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1152 -1202
- package/dist/agent/index.d.ts +1152 -1202
- package/dist/agent/index.js +1147 -1903
- package/dist/agent/index.js.map +1 -1
- package/dist/camera/index.cjs +2470 -3435
- package/dist/camera/index.cjs.map +1 -1
- package/dist/camera/index.d.cts +716 -744
- package/dist/camera/index.d.ts +716 -744
- package/dist/camera/index.js +2438 -3323
- package/dist/camera/index.js.map +1 -1
- package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
- package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
- package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
- package/dist/chunk-6qyuJVvt.d.ts +513 -0
- package/dist/chunk-9fp0lDic.cjs +583 -0
- package/dist/chunk-9fp0lDic.cjs.map +1 -0
- package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
- package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
- package/dist/chunk-B-m1AchR.cjs +57 -0
- package/dist/chunk-B-m1AchR.cjs.map +1 -0
- package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
- package/dist/chunk-B0YROiZh.d.cts +1475 -0
- package/dist/chunk-B14wgOvH.d.cts +68 -0
- package/dist/chunk-B19l3j9r.cjs +150 -0
- package/dist/chunk-B19l3j9r.cjs.map +1 -0
- package/dist/chunk-B2PtjVKg.cjs +86 -0
- package/dist/chunk-B2PtjVKg.cjs.map +1 -0
- package/dist/chunk-B56Oyb7W.cjs +70 -0
- package/dist/chunk-B56Oyb7W.cjs.map +1 -0
- package/dist/chunk-B5WGMQwK.cjs +113 -0
- package/dist/chunk-B5WGMQwK.cjs.map +1 -0
- package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
- package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
- package/dist/chunk-BBikve0Z.cjs +269 -0
- package/dist/chunk-BBikve0Z.cjs.map +1 -0
- package/dist/chunk-BHeXmM0X.js +37 -0
- package/dist/chunk-BHeXmM0X.js.map +1 -0
- package/dist/chunk-BI8WZLpU.cjs +281 -0
- package/dist/chunk-BI8WZLpU.cjs.map +1 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BJ6L6_W9.cjs +553 -0
- package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
- package/dist/chunk-BJ91UCbB.js +11 -0
- package/dist/chunk-BJ91UCbB.js.map +1 -0
- package/dist/chunk-BJEZWTKj.cjs +166 -0
- package/dist/chunk-BJEZWTKj.cjs.map +1 -0
- package/dist/chunk-BJz54mfg.cjs +10 -0
- package/dist/chunk-BJz54mfg.cjs.map +1 -0
- package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
- package/dist/chunk-BP6KgA86.js +35 -0
- package/dist/chunk-BP6KgA86.js.map +1 -0
- package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
- package/dist/chunk-BSiMEwPS.js +46 -0
- package/dist/chunk-BSiMEwPS.js.map +1 -0
- package/dist/chunk-BTPjDw_y.cjs +16 -0
- package/dist/chunk-BTPjDw_y.cjs.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BUeL9y7s.cjs +45 -0
- package/dist/chunk-BUeL9y7s.cjs.map +1 -0
- package/dist/chunk-BWMuCNc9.cjs +172 -0
- package/dist/chunk-BWMuCNc9.cjs.map +1 -0
- package/dist/chunk-BWjRfhpF.js +126 -0
- package/dist/chunk-BWjRfhpF.js.map +1 -0
- package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
- package/dist/chunk-B_4SVmvh.js +94 -0
- package/dist/chunk-B_4SVmvh.js.map +1 -0
- package/dist/chunk-BcTUuZQ3.js +95 -0
- package/dist/chunk-BcTUuZQ3.js.map +1 -0
- package/dist/chunk-BdkqSsJe.cjs +140 -0
- package/dist/chunk-BdkqSsJe.cjs.map +1 -0
- package/dist/chunk-BfktMVmI.js +70 -0
- package/dist/chunk-BfktMVmI.js.map +1 -0
- package/dist/chunk-BfzQb0EK.cjs +6 -0
- package/dist/chunk-BhWfT-22.d.cts +808 -0
- package/dist/chunk-BjJcqX5J.cjs +60 -0
- package/dist/chunk-BjJcqX5J.cjs.map +1 -0
- package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
- package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
- package/dist/chunk-Bl4_uVa6.cjs +11 -0
- package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
- package/dist/chunk-BlKF4lrp.js +43 -0
- package/dist/chunk-BlKF4lrp.js.map +1 -0
- package/dist/chunk-Bm1FieGR.js +4 -0
- package/dist/chunk-Bm1FieGR.js.map +1 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-BpN3hr6a.cjs +541 -0
- package/dist/chunk-BpN3hr6a.cjs.map +1 -0
- package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
- package/dist/chunk-Bqt4LBBz.cjs +648 -0
- package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
- package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
- package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
- package/dist/chunk-BsBiN4w6.d.cts +245 -0
- package/dist/chunk-BvTpOUoC.cjs +207 -0
- package/dist/chunk-BvTpOUoC.cjs.map +1 -0
- package/dist/chunk-BwK6Hl3q.cjs +446 -0
- package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
- package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
- package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
- package/dist/chunk-BxUio8kX.js +20 -0
- package/dist/chunk-BxUio8kX.js.map +1 -0
- package/dist/chunk-BxaocpFi.d.cts +1 -0
- package/dist/chunk-Bywi0K1N.js +36 -0
- package/dist/chunk-Bywi0K1N.js.map +1 -0
- package/dist/chunk-C-IlmkDl.js +59 -0
- package/dist/chunk-C-IlmkDl.js.map +1 -0
- package/dist/chunk-C5PtVewq.d.ts +389 -0
- package/dist/chunk-C5dpC7mQ.js +19 -0
- package/dist/chunk-C5dpC7mQ.js.map +1 -0
- package/dist/chunk-C5q1sgSa.js +46 -0
- package/dist/chunk-C5q1sgSa.js.map +1 -0
- package/dist/chunk-C6fU9G5I.cjs +221 -0
- package/dist/chunk-C6fU9G5I.cjs.map +1 -0
- package/dist/chunk-C71dpWUK.js +5 -0
- package/dist/chunk-C71dpWUK.js.map +1 -0
- package/dist/chunk-C82N1gQX.d.ts +1831 -0
- package/dist/chunk-C8HdaHpu.js +118 -0
- package/dist/chunk-C8HdaHpu.js.map +1 -0
- package/dist/chunk-C8ZGryck.js +236 -0
- package/dist/chunk-C8ZGryck.js.map +1 -0
- package/dist/chunk-C95NG0oD.cjs +43 -0
- package/dist/chunk-C95NG0oD.cjs.map +1 -0
- package/dist/chunk-C9aR8DXb.js +9 -0
- package/dist/chunk-C9aR8DXb.js.map +1 -0
- package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
- package/dist/chunk-CBXWWuM9.cjs +82 -0
- package/dist/chunk-CBXWWuM9.cjs.map +1 -0
- package/dist/chunk-CC_Kquu7.d.cts +125 -0
- package/dist/chunk-CC_Kquu7.d.ts +125 -0
- package/dist/chunk-CCp85vXg.cjs +60 -0
- package/dist/chunk-CCp85vXg.cjs.map +1 -0
- package/dist/chunk-CEcB1_uK.js +39 -0
- package/dist/chunk-CEcB1_uK.js.map +1 -0
- package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
- package/dist/chunk-CH_IZoJE.js +33 -0
- package/dist/chunk-CH_IZoJE.js.map +1 -0
- package/dist/chunk-CHrasH_g.cjs +25 -0
- package/dist/chunk-CHrasH_g.cjs.map +1 -0
- package/dist/chunk-CJVoSaAE.cjs +3 -0
- package/dist/chunk-CJp8nGcb.js +96 -0
- package/dist/chunk-CJp8nGcb.js.map +1 -0
- package/dist/chunk-CJwUtkOt.js +112 -0
- package/dist/chunk-CJwUtkOt.js.map +1 -0
- package/dist/chunk-CKhCOVIf.d.cts +751 -0
- package/dist/chunk-CKiVSRYg.js +50 -0
- package/dist/chunk-CKiVSRYg.js.map +1 -0
- package/dist/chunk-CKtd19eD.cjs +59 -0
- package/dist/chunk-CKtd19eD.cjs.map +1 -0
- package/dist/chunk-CL92KE3j.d.ts +3188 -0
- package/dist/chunk-CLqUlkAe.js +54 -0
- package/dist/chunk-CLqUlkAe.js.map +1 -0
- package/dist/chunk-CMG5OV0q.cjs +4741 -0
- package/dist/chunk-CMG5OV0q.cjs.map +1 -0
- package/dist/chunk-CN_TKSgm.js +10 -0
- package/dist/chunk-CN_TKSgm.js.map +1 -0
- package/dist/chunk-CNe6MtqV.cjs +29 -0
- package/dist/chunk-CNe6MtqV.cjs.map +1 -0
- package/dist/chunk-COQkDTC5.js +83 -0
- package/dist/chunk-COQkDTC5.js.map +1 -0
- package/dist/chunk-CPBl6K4M.cjs +168 -0
- package/dist/chunk-CPBl6K4M.cjs.map +1 -0
- package/dist/chunk-CPx0ZYFB.d.ts +3 -0
- package/dist/chunk-CQQhcP_C.d.ts +197 -0
- package/dist/chunk-CTNoajFh.d.cts +389 -0
- package/dist/chunk-CTd-qgJc.cjs +384 -0
- package/dist/chunk-CTd-qgJc.cjs.map +1 -0
- package/dist/chunk-CW80YYtU.cjs +1056 -0
- package/dist/chunk-CW80YYtU.cjs.map +1 -0
- package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
- package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
- package/dist/chunk-CXjRArgy.d.ts +3 -0
- package/dist/chunk-CXonfH3-.cjs +14 -0
- package/dist/chunk-CXonfH3-.cjs.map +1 -0
- package/dist/chunk-CYcouGXN.d.ts +825 -0
- package/dist/chunk-CZDAzEBw.cjs +1621 -0
- package/dist/chunk-CZDAzEBw.cjs.map +1 -0
- package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
- package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
- package/dist/chunk-CbOtHnnB.cjs +359 -0
- package/dist/chunk-CbOtHnnB.cjs.map +1 -0
- package/dist/chunk-CdA6ZMGk.d.cts +825 -0
- package/dist/chunk-Ce1_thm7.js +146 -0
- package/dist/chunk-Ce1_thm7.js.map +1 -0
- package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
- package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
- package/dist/chunk-Ch1OLzLi.js +1 -0
- package/dist/chunk-Cizu_j1N.cjs +87 -0
- package/dist/chunk-Cizu_j1N.cjs.map +1 -0
- package/dist/chunk-CjDe9z6A.d.cts +427 -0
- package/dist/chunk-Cl1etdlu.js +63 -0
- package/dist/chunk-Cl1etdlu.js.map +1 -0
- package/dist/chunk-CmoVJDoz.js +4 -0
- package/dist/chunk-CmoVJDoz.js.map +1 -0
- package/dist/chunk-CnLucxjG.cjs +197 -0
- package/dist/chunk-CnLucxjG.cjs.map +1 -0
- package/dist/chunk-CsWjBmdi.cjs +56 -0
- package/dist/chunk-CsWjBmdi.cjs.map +1 -0
- package/dist/chunk-CuseO5MZ.d.cts +3 -0
- package/dist/chunk-CvMHibbA.d.ts +427 -0
- package/dist/chunk-CwDeiN5U.js +870 -0
- package/dist/chunk-CwDeiN5U.js.map +1 -0
- package/dist/chunk-Cwdmx4tG.js +1 -0
- package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
- package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
- package/dist/chunk-D0LF-99V.js +1093 -0
- package/dist/chunk-D0LF-99V.js.map +1 -0
- package/dist/chunk-D1fe-0c_.js +367 -0
- package/dist/chunk-D1fe-0c_.js.map +1 -0
- package/dist/chunk-D21fEI6A.d.ts +1926 -0
- package/dist/chunk-D39gAxya.cjs +89 -0
- package/dist/chunk-D39gAxya.cjs.map +1 -0
- package/dist/chunk-D6KdIW5e.cjs +228 -0
- package/dist/chunk-D6KdIW5e.cjs.map +1 -0
- package/dist/chunk-D6qHYbgW.d.cts +36 -0
- package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
- package/dist/chunk-D8bdTysL.js +552 -0
- package/dist/chunk-D8bdTysL.js.map +1 -0
- package/dist/chunk-D96QJT24.cjs +109 -0
- package/dist/chunk-D96QJT24.cjs.map +1 -0
- package/dist/chunk-DAmkQl-i.js +119 -0
- package/dist/chunk-DAmkQl-i.js.map +1 -0
- package/dist/chunk-DEfsb2lc.cjs +10 -0
- package/dist/chunk-DEfsb2lc.cjs.map +1 -0
- package/dist/chunk-DIFjT5-V.d.cts +66 -0
- package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
- package/dist/chunk-DK6lm2IZ.cjs +11 -0
- package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
- package/dist/chunk-DKqgr31j.cjs +61 -0
- package/dist/chunk-DKqgr31j.cjs.map +1 -0
- package/dist/chunk-DLZ0QYm9.js +37 -0
- package/dist/chunk-DLZ0QYm9.js.map +1 -0
- package/dist/chunk-DLjS0uaC.js +4 -0
- package/dist/chunk-DLjS0uaC.js.map +1 -0
- package/dist/chunk-DMokwmOV.cjs +49 -0
- package/dist/chunk-DMokwmOV.cjs.map +1 -0
- package/dist/chunk-DMvWgBZL.d.cts +1831 -0
- package/dist/chunk-DNfGfIF3.js +31 -0
- package/dist/chunk-DNfGfIF3.js.map +1 -0
- package/dist/chunk-DQbSRe8D.d.ts +245 -0
- package/dist/chunk-DSGkP8_y.js +45 -0
- package/dist/chunk-DSGkP8_y.js.map +1 -0
- package/dist/chunk-DTctvfSd.d.cts +197 -0
- package/dist/chunk-DWe7igyw.cjs +206 -0
- package/dist/chunk-DWe7igyw.cjs.map +1 -0
- package/dist/chunk-DWsMP5JR.d.ts +68 -0
- package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
- package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
- package/dist/chunk-DXABHjLa.cjs +3 -0
- package/dist/chunk-D_BeqSbc.cjs +42 -0
- package/dist/chunk-D_BeqSbc.cjs.map +1 -0
- package/dist/chunk-D_svQNdW.d.ts +66 -0
- package/dist/chunk-Dav4xWrp.js +330 -0
- package/dist/chunk-Dav4xWrp.js.map +1 -0
- package/dist/chunk-DbCPhepL.js +293 -0
- package/dist/chunk-DbCPhepL.js.map +1 -0
- package/dist/chunk-DcrTy-y2.cjs +43 -0
- package/dist/chunk-DcrTy-y2.cjs.map +1 -0
- package/dist/chunk-Ddv484ld.js +487 -0
- package/dist/chunk-Ddv484ld.js.map +1 -0
- package/dist/chunk-De0bjnhY.cjs +88 -0
- package/dist/chunk-De0bjnhY.cjs.map +1 -0
- package/dist/chunk-De2FmNPu.cjs +32 -0
- package/dist/chunk-De2FmNPu.cjs.map +1 -0
- package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
- package/dist/chunk-Den0Ta6C.js +132 -0
- package/dist/chunk-Den0Ta6C.js.map +1 -0
- package/dist/chunk-DiDKEeEa.js +8 -0
- package/dist/chunk-DiDKEeEa.js.map +1 -0
- package/dist/chunk-Dj60k5PU.js +197 -0
- package/dist/chunk-Dj60k5PU.js.map +1 -0
- package/dist/chunk-DjnYQBCN.js +4705 -0
- package/dist/chunk-DjnYQBCN.js.map +1 -0
- package/dist/chunk-Dk9VKvyq.d.ts +1 -0
- package/dist/chunk-Dor1ERI9.cjs +85 -0
- package/dist/chunk-Dor1ERI9.cjs.map +1 -0
- package/dist/chunk-DpMouOoH.js +451 -0
- package/dist/chunk-DpMouOoH.js.map +1 -0
- package/dist/chunk-DposgdNL.cjs +52 -0
- package/dist/chunk-DposgdNL.cjs.map +1 -0
- package/dist/chunk-DqLTG_5Q.d.cts +3 -0
- package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
- package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
- package/dist/chunk-DrudttCC.cjs +4 -0
- package/dist/chunk-DsDYVJQC.js +173 -0
- package/dist/chunk-DsDYVJQC.js.map +1 -0
- package/dist/chunk-Dw8ur6FJ.js +27 -0
- package/dist/chunk-Dw8ur6FJ.js.map +1 -0
- package/dist/chunk-DwG6M_0v.js +64 -0
- package/dist/chunk-DwG6M_0v.js.map +1 -0
- package/dist/chunk-Dy9a5ibO.js +284 -0
- package/dist/chunk-Dy9a5ibO.js.map +1 -0
- package/dist/chunk-DyayZlQJ.js +157 -0
- package/dist/chunk-DyayZlQJ.js.map +1 -0
- package/dist/chunk-DyhJZC2i.js +126 -0
- package/dist/chunk-DyhJZC2i.js.map +1 -0
- package/dist/chunk-F9zBzmmG.cjs +45 -0
- package/dist/chunk-F9zBzmmG.cjs.map +1 -0
- package/dist/chunk-FyCYofv2.js +116 -0
- package/dist/chunk-FyCYofv2.js.map +1 -0
- package/dist/chunk-GHJRjAk2.js +1 -0
- package/dist/chunk-H14isiSf.d.ts +751 -0
- package/dist/chunk-HIJzXoN4.js +7 -0
- package/dist/chunk-HIJzXoN4.js.map +1 -0
- package/dist/chunk-Id_8kRtu.d.ts +36 -0
- package/dist/chunk-KN60yxBQ.js +5 -0
- package/dist/chunk-KN60yxBQ.js.map +1 -0
- package/dist/chunk-NM5yg6bh.cjs +82 -0
- package/dist/chunk-NM5yg6bh.cjs.map +1 -0
- package/dist/chunk-OXr3zJfM.cjs +119 -0
- package/dist/chunk-OXr3zJfM.cjs.map +1 -0
- package/dist/chunk-QGqgNC4z.d.ts +928 -0
- package/dist/chunk-QJBtJrZ0.js +36 -0
- package/dist/chunk-QJBtJrZ0.js.map +1 -0
- package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
- package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
- package/dist/chunk-QXW7b4Ev.d.cts +410 -0
- package/dist/chunk-RHZrxUrM.cjs +39 -0
- package/dist/chunk-RHZrxUrM.cjs.map +1 -0
- package/dist/chunk-RTxe2i66.js +91 -0
- package/dist/chunk-RTxe2i66.js.map +1 -0
- package/dist/chunk-RrKkJb6P.js +16 -0
- package/dist/chunk-RrKkJb6P.js.map +1 -0
- package/dist/chunk-VOJqpcnM.cjs +181 -0
- package/dist/chunk-VOJqpcnM.cjs.map +1 -0
- package/dist/chunk-VljGTrid.js +1 -0
- package/dist/chunk-X3UVwUEK.d.cts +513 -0
- package/dist/chunk-X9K2WChn.cjs +28 -0
- package/dist/chunk-X9K2WChn.cjs.map +1 -0
- package/dist/chunk-YrtOx6oy.js +251 -0
- package/dist/chunk-YrtOx6oy.js.map +1 -0
- package/dist/chunk-bY7ySujI.d.cts +928 -0
- package/dist/chunk-bYf1sBz5.d.cts +11 -0
- package/dist/chunk-bYf1sBz5.d.ts +11 -0
- package/dist/chunk-blfknWoM.d.cts +1926 -0
- package/dist/chunk-blqsohAb.js +113 -0
- package/dist/chunk-blqsohAb.js.map +1 -0
- package/dist/chunk-cDMCjodI.cjs +58 -0
- package/dist/chunk-cDMCjodI.cjs.map +1 -0
- package/dist/chunk-cWjE3qd6.cjs +10 -0
- package/dist/chunk-cWjE3qd6.cjs.map +1 -0
- package/dist/chunk-dfOgV3fu.js +26 -0
- package/dist/chunk-dfOgV3fu.js.map +1 -0
- package/dist/chunk-f9cTwUX1.cjs +125 -0
- package/dist/chunk-f9cTwUX1.cjs.map +1 -0
- package/dist/chunk-fHVYEZs4.cjs +28 -0
- package/dist/chunk-fHVYEZs4.cjs.map +1 -0
- package/dist/chunk-fWRUMgRI.js +22 -0
- package/dist/chunk-fWRUMgRI.js.map +1 -0
- package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
- package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
- package/dist/chunk-gWmB1l3A.cjs +3122 -0
- package/dist/chunk-gWmB1l3A.cjs.map +1 -0
- package/dist/chunk-gbj2R-_w.js +58 -0
- package/dist/chunk-gbj2R-_w.js.map +1 -0
- package/dist/chunk-iIWxsAXd.js +59 -0
- package/dist/chunk-iIWxsAXd.js.map +1 -0
- package/dist/chunk-lItIuOIS.cjs +137 -0
- package/dist/chunk-lItIuOIS.cjs.map +1 -0
- package/dist/chunk-m6Rh4PCe.cjs +798 -0
- package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
- package/dist/chunk-o3IRANDf.cjs +99 -0
- package/dist/chunk-o3IRANDf.cjs.map +1 -0
- package/dist/chunk-obUcg3Sk.d.ts +808 -0
- package/dist/chunk-ohsf-6Rn.js +600 -0
- package/dist/chunk-ohsf-6Rn.js.map +1 -0
- package/dist/chunk-pBleU6Nv.js +3061 -0
- package/dist/chunk-pBleU6Nv.js.map +1 -0
- package/dist/chunk-px4e99cy.js +71 -0
- package/dist/chunk-px4e99cy.js.map +1 -0
- package/dist/chunk-qwYDLeXc.cjs +99 -0
- package/dist/chunk-qwYDLeXc.cjs.map +1 -0
- package/dist/chunk-rF_859Qk.cjs +101 -0
- package/dist/chunk-rF_859Qk.cjs.map +1 -0
- package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
- package/dist/chunk-twQItIRg.cjs +338 -0
- package/dist/chunk-twQItIRg.cjs.map +1 -0
- package/dist/chunk-vnPrMVjY.js +10 -0
- package/dist/chunk-vnPrMVjY.js.map +1 -0
- package/dist/chunk-ws3bVwaS.d.ts +410 -0
- package/dist/chunk-xh3UkuVs.cjs +246 -0
- package/dist/chunk-xh3UkuVs.cjs.map +1 -0
- package/dist/chunk-yMzRr26E.js +153 -0
- package/dist/chunk-yMzRr26E.js.map +1 -0
- package/dist/collab/index.cjs +802 -1254
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.cts +518 -544
- package/dist/collab/index.d.ts +518 -544
- package/dist/collab/index.js +797 -1252
- package/dist/collab/index.js.map +1 -1
- package/dist/data/index.cjs +39 -132
- package/dist/data/index.d.cts +6 -468
- package/dist/data/index.d.ts +6 -468
- package/dist/data/index.js +7 -15
- package/dist/editor/index.cjs +2631 -4424
- package/dist/editor/index.cjs.map +1 -1
- package/dist/editor/index.d.cts +10 -59
- package/dist/editor/index.d.ts +10 -59
- package/dist/editor/index.js +2619 -4403
- package/dist/editor/index.js.map +1 -1
- package/dist/errors/index.cjs +11 -28
- package/dist/errors/index.d.cts +2 -125
- package/dist/errors/index.d.ts +2 -125
- package/dist/errors/index.js +1 -3
- package/dist/geo/index.cjs +68 -232
- package/dist/geo/index.d.cts +6 -821
- package/dist/geo/index.d.ts +6 -821
- package/dist/geo/index.js +11 -15
- package/dist/i18n/fr/index.cjs +329 -334
- package/dist/i18n/fr/index.cjs.map +1 -1
- package/dist/i18n/fr/index.d.cts +3 -10
- package/dist/i18n/fr/index.d.ts +3 -10
- package/dist/i18n/fr/index.js +324 -332
- package/dist/i18n/fr/index.js.map +1 -1
- package/dist/i18n/index.cjs +434 -447
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +152 -111
- package/dist/i18n/index.d.ts +152 -111
- package/dist/i18n/index.js +420 -420
- package/dist/i18n/index.js.map +1 -1
- package/dist/icons/index.cjs +37 -116
- package/dist/icons/index.d.cts +4 -457
- package/dist/icons/index.d.ts +4 -457
- package/dist/icons/index.js +8 -11
- package/dist/index.cjs +515 -1867
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -121
- package/dist/index.d.ts +44 -121
- package/dist/index.js +52 -65
- package/dist/index.js.map +1 -1
- package/dist/layers/index.cjs +83 -318
- package/dist/layers/index.d.cts +3 -1555
- package/dist/layers/index.d.ts +3 -1555
- package/dist/layers/index.js +5 -17
- package/dist/map-client/index.cjs +5 -4
- package/dist/map-client/index.d.cts +6 -1856
- package/dist/map-client/index.d.ts +6 -1856
- package/dist/map-client/index.js +0 -3
- package/dist/maplibre-worker.mjs +4 -4
- package/dist/navigation/index.cjs +584 -671
- package/dist/navigation/index.cjs.map +1 -1
- package/dist/navigation/index.d.cts +191 -272
- package/dist/navigation/index.d.ts +191 -272
- package/dist/navigation/index.js +579 -669
- package/dist/navigation/index.js.map +1 -1
- package/dist/profile/index.cjs +177 -675
- package/dist/profile/index.d.cts +8 -2086
- package/dist/profile/index.d.ts +8 -2086
- package/dist/profile/index.js +10 -18
- package/dist/seams/index.cjs +15 -39
- package/dist/seams/index.d.cts +4 -254
- package/dist/seams/index.d.ts +4 -254
- package/dist/seams/index.js +4 -6
- package/dist/search/index.cjs +39 -147
- package/dist/search/index.d.cts +6 -888
- package/dist/search/index.d.ts +6 -888
- package/dist/search/index.js +3 -14
- package/dist/style/index.cjs +34 -116
- package/dist/style/index.d.cts +5 -538
- package/dist/style/index.d.ts +5 -538
- package/dist/style/index.js +5 -11
- package/dist/testing/index.cjs +432 -617
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +61 -109
- package/dist/testing/index.d.ts +61 -109
- package/dist/testing/index.js +427 -615
- package/dist/testing/index.js.map +1 -1
- package/dist/timezone/index.cjs +1946 -752
- package/dist/timezone/index.cjs.map +1 -1
- package/dist/timezone/index.d.cts +4 -29
- package/dist/timezone/index.d.ts +4 -29
- package/dist/timezone/index.js +1941 -750
- package/dist/timezone/index.js.map +1 -1
- package/dist/units/index.cjs +29 -99
- package/dist/units/index.d.cts +3 -75
- package/dist/units/index.d.ts +3 -75
- package/dist/units/index.js +3 -6
- package/dist/video/index.cjs +1684 -2169
- package/dist/video/index.cjs.map +1 -1
- package/dist/video/index.d.cts +386 -413
- package/dist/video/index.d.ts +386 -413
- package/dist/video/index.js +1678 -2162
- package/dist/video/index.js.map +1 -1
- package/dist/view/index.cjs +6 -42
- package/dist/view/index.d.cts +3 -836
- package/dist/view/index.d.ts +3 -836
- package/dist/view/index.js +1 -34
- package/package.json +12 -12
- package/src/auth/rules/clientHeader.ts +1 -1
- package/src/camera/rules/modes.ts +38 -42
- package/src/camera/rules/routeContent.ts +1 -0
- package/src/collab/index.ts +1 -5
- package/src/compose/engines/mountayaMap.ts +16 -42
- package/src/compose/rules/developmentWarnings.ts +4 -3
- package/src/compose/rules/fitBox.ts +67 -0
- package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
- package/src/compose/rules/maxBounds.ts +5 -5
- package/src/compose/rules/types.ts +4 -11
- package/src/compose/rules/workerUrl.ts +41 -6
- package/src/editing/rules/engine.ts +4 -2
- package/src/editor/engines/viewClient.ts +8 -0
- package/src/editor/rules/contract.ts +1 -6
- package/src/errors/rules/errors.ts +1 -0
- package/src/geo/index.ts +1 -6
- package/src/i18n/index.ts +1 -0
- package/src/i18n/rules/dates.ts +165 -0
- package/src/index.ts +5 -24
- package/src/map-client/rules/mapClient.ts +4 -2
- package/src/profile/rules/scale.ts +1 -5
- package/src/profile/rules/waypointCard.ts +8 -11
- package/src/search/index.ts +3 -18
- package/src/video/index.ts +1 -1
- package/src/video/profileOverlay/rules/contract.ts +1 -3
- package/src/video/rules/videoEncoder.ts +1 -1
- package/dist/accentColor-GNKBD2CW.js +0 -4
- package/dist/accentColor-GNKBD2CW.js.map +0 -1
- package/dist/accentColor-VX2JSMGE.cjs +0 -17
- package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
- package/dist/chunk-23PFRRB6.js +0 -3
- package/dist/chunk-23PFRRB6.js.map +0 -1
- package/dist/chunk-2GI5SAH2.js +0 -71
- package/dist/chunk-2GI5SAH2.js.map +0 -1
- package/dist/chunk-2MQK6A74.js +0 -39
- package/dist/chunk-2MQK6A74.js.map +0 -1
- package/dist/chunk-2RE7R4LD.js +0 -73
- package/dist/chunk-2RE7R4LD.js.map +0 -1
- package/dist/chunk-3JZQKN4O.js +0 -6
- package/dist/chunk-3JZQKN4O.js.map +0 -1
- package/dist/chunk-3NDXVUUI.js +0 -50
- package/dist/chunk-3NDXVUUI.js.map +0 -1
- package/dist/chunk-3R4GFTUM.cjs +0 -59
- package/dist/chunk-3R4GFTUM.cjs.map +0 -1
- package/dist/chunk-3RVUQ6JN.cjs +0 -22
- package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
- package/dist/chunk-4F6BJMJC.cjs +0 -49
- package/dist/chunk-4F6BJMJC.cjs.map +0 -1
- package/dist/chunk-4NWQD4BX.js +0 -132
- package/dist/chunk-4NWQD4BX.js.map +0 -1
- package/dist/chunk-5K2MH3R6.js +0 -10
- package/dist/chunk-5K2MH3R6.js.map +0 -1
- package/dist/chunk-6ACRNQQQ.cjs +0 -8
- package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
- package/dist/chunk-6D26E3IA.js +0 -66
- package/dist/chunk-6D26E3IA.js.map +0 -1
- package/dist/chunk-6ESAW35P.cjs +0 -80
- package/dist/chunk-6ESAW35P.cjs.map +0 -1
- package/dist/chunk-6LIW2A5M.cjs +0 -1176
- package/dist/chunk-6LIW2A5M.cjs.map +0 -1
- package/dist/chunk-6OTTWVCA.js +0 -57
- package/dist/chunk-6OTTWVCA.js.map +0 -1
- package/dist/chunk-6VROJ4UG.js +0 -862
- package/dist/chunk-6VROJ4UG.js.map +0 -1
- package/dist/chunk-6Y7FTGO4.js +0 -23
- package/dist/chunk-6Y7FTGO4.js.map +0 -1
- package/dist/chunk-75I4CG64.js +0 -104
- package/dist/chunk-75I4CG64.js.map +0 -1
- package/dist/chunk-7CUBXHAH.cjs +0 -14
- package/dist/chunk-7CUBXHAH.cjs.map +0 -1
- package/dist/chunk-7GTCURVY.js +0 -52
- package/dist/chunk-7GTCURVY.js.map +0 -1
- package/dist/chunk-7IWOL6AM.cjs +0 -100
- package/dist/chunk-7IWOL6AM.cjs.map +0 -1
- package/dist/chunk-7QN7M667.cjs +0 -151
- package/dist/chunk-7QN7M667.cjs.map +0 -1
- package/dist/chunk-A6KQDKLM.cjs +0 -1197
- package/dist/chunk-A6KQDKLM.cjs.map +0 -1
- package/dist/chunk-A77EA67G.js +0 -354
- package/dist/chunk-A77EA67G.js.map +0 -1
- package/dist/chunk-AFKOABJ4.cjs +0 -7194
- package/dist/chunk-AFKOABJ4.cjs.map +0 -1
- package/dist/chunk-AG6JV5Z2.cjs +0 -183
- package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
- package/dist/chunk-APBK7NMS.js +0 -30
- package/dist/chunk-APBK7NMS.js.map +0 -1
- package/dist/chunk-AWO5YA7A.cjs +0 -33
- package/dist/chunk-AWO5YA7A.cjs.map +0 -1
- package/dist/chunk-AZATU6QW.js +0 -108
- package/dist/chunk-AZATU6QW.js.map +0 -1
- package/dist/chunk-BD2U3WST.cjs +0 -623
- package/dist/chunk-BD2U3WST.cjs.map +0 -1
- package/dist/chunk-BHBEOU6L.cjs +0 -65
- package/dist/chunk-BHBEOU6L.cjs.map +0 -1
- package/dist/chunk-CNOSNYNE.js +0 -8
- package/dist/chunk-CNOSNYNE.js.map +0 -1
- package/dist/chunk-CW3EFR4O.js +0 -12
- package/dist/chunk-CW3EFR4O.js.map +0 -1
- package/dist/chunk-DASVRNBK.js +0 -7187
- package/dist/chunk-DASVRNBK.js.map +0 -1
- package/dist/chunk-DJ6LCKYP.js +0 -42
- package/dist/chunk-DJ6LCKYP.js.map +0 -1
- package/dist/chunk-E5FHQAIO.cjs +0 -45
- package/dist/chunk-E5FHQAIO.cjs.map +0 -1
- package/dist/chunk-EOML5OTY.cjs +0 -360
- package/dist/chunk-EOML5OTY.cjs.map +0 -1
- package/dist/chunk-EP5CASHL.js +0 -613
- package/dist/chunk-EP5CASHL.js.map +0 -1
- package/dist/chunk-EP5OEEVZ.cjs +0 -14
- package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
- package/dist/chunk-EUXI3FGQ.js +0 -150
- package/dist/chunk-EUXI3FGQ.js.map +0 -1
- package/dist/chunk-EWFSHCOS.js +0 -40
- package/dist/chunk-EWFSHCOS.js.map +0 -1
- package/dist/chunk-EX2C5K2T.cjs +0 -25
- package/dist/chunk-EX2C5K2T.cjs.map +0 -1
- package/dist/chunk-FEXWDQIZ.cjs +0 -8
- package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
- package/dist/chunk-FEYBFY7H.cjs +0 -358
- package/dist/chunk-FEYBFY7H.cjs.map +0 -1
- package/dist/chunk-FRGAV6N6.cjs +0 -34
- package/dist/chunk-FRGAV6N6.cjs.map +0 -1
- package/dist/chunk-G5DHP5VF.js +0 -6
- package/dist/chunk-G5DHP5VF.js.map +0 -1
- package/dist/chunk-G5W2UHV2.js +0 -99
- package/dist/chunk-G5W2UHV2.js.map +0 -1
- package/dist/chunk-G7OP7O2C.cjs +0 -39
- package/dist/chunk-G7OP7O2C.cjs.map +0 -1
- package/dist/chunk-GE6CFCAM.cjs +0 -25
- package/dist/chunk-GE6CFCAM.cjs.map +0 -1
- package/dist/chunk-GIFALLHI.cjs +0 -111
- package/dist/chunk-GIFALLHI.cjs.map +0 -1
- package/dist/chunk-GLFET5GM.js +0 -129
- package/dist/chunk-GLFET5GM.js.map +0 -1
- package/dist/chunk-GQ6UFPFM.js +0 -22
- package/dist/chunk-GQ6UFPFM.js.map +0 -1
- package/dist/chunk-GQJWVMXS.js +0 -129
- package/dist/chunk-GQJWVMXS.js.map +0 -1
- package/dist/chunk-GVVJPUKC.js +0 -80
- package/dist/chunk-GVVJPUKC.js.map +0 -1
- package/dist/chunk-GZ2HOCQ2.cjs +0 -134
- package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
- package/dist/chunk-HCBOHXWP.js +0 -37
- package/dist/chunk-HCBOHXWP.js.map +0 -1
- package/dist/chunk-IBQJDVHF.cjs +0 -281
- package/dist/chunk-IBQJDVHF.cjs.map +0 -1
- package/dist/chunk-ISLB6Y5Q.cjs +0 -106
- package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
- package/dist/chunk-J55CRR4F.js +0 -105
- package/dist/chunk-J55CRR4F.js.map +0 -1
- package/dist/chunk-JBG6Z6MQ.cjs +0 -28
- package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
- package/dist/chunk-K3RQOZRU.js +0 -61
- package/dist/chunk-K3RQOZRU.js.map +0 -1
- package/dist/chunk-KDJYS4GB.cjs +0 -703
- package/dist/chunk-KDJYS4GB.cjs.map +0 -1
- package/dist/chunk-KMCAHUZM.cjs +0 -4
- package/dist/chunk-KMCAHUZM.cjs.map +0 -1
- package/dist/chunk-KUCBNPC6.js +0 -87
- package/dist/chunk-KUCBNPC6.js.map +0 -1
- package/dist/chunk-KV6UE5A4.js +0 -50
- package/dist/chunk-KV6UE5A4.js.map +0 -1
- package/dist/chunk-L6TZ2HQR.cjs +0 -18
- package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
- package/dist/chunk-L7QHHGG2.cjs +0 -141
- package/dist/chunk-L7QHHGG2.cjs.map +0 -1
- package/dist/chunk-LHK3Y2AL.js +0 -271
- package/dist/chunk-LHK3Y2AL.js.map +0 -1
- package/dist/chunk-LO5RYRBH.cjs +0 -6317
- package/dist/chunk-LO5RYRBH.cjs.map +0 -1
- package/dist/chunk-LS5SJMUO.cjs +0 -194
- package/dist/chunk-LS5SJMUO.cjs.map +0 -1
- package/dist/chunk-LUGTMZFN.cjs +0 -42
- package/dist/chunk-LUGTMZFN.cjs.map +0 -1
- package/dist/chunk-LVUQU6D5.js +0 -32
- package/dist/chunk-LVUQU6D5.js.map +0 -1
- package/dist/chunk-M2QRC2GZ.js +0 -166
- package/dist/chunk-M2QRC2GZ.js.map +0 -1
- package/dist/chunk-M6QJYQIM.cjs +0 -53
- package/dist/chunk-M6QJYQIM.cjs.map +0 -1
- package/dist/chunk-MGCPH5EO.js +0 -12
- package/dist/chunk-MGCPH5EO.js.map +0 -1
- package/dist/chunk-MLVUWEZR.cjs +0 -474
- package/dist/chunk-MLVUWEZR.cjs.map +0 -1
- package/dist/chunk-MTAMJMZL.cjs +0 -707
- package/dist/chunk-MTAMJMZL.cjs.map +0 -1
- package/dist/chunk-MXL5AT3N.js +0 -48
- package/dist/chunk-MXL5AT3N.js.map +0 -1
- package/dist/chunk-MYEQSESM.cjs +0 -75
- package/dist/chunk-MYEQSESM.cjs.map +0 -1
- package/dist/chunk-N3VPF6ZD.js +0 -427
- package/dist/chunk-N3VPF6ZD.js.map +0 -1
- package/dist/chunk-N6VUAIGI.js +0 -7
- package/dist/chunk-N6VUAIGI.js.map +0 -1
- package/dist/chunk-N6XRLUN6.js +0 -6286
- package/dist/chunk-N6XRLUN6.js.map +0 -1
- package/dist/chunk-NOGDOZIT.cjs +0 -114
- package/dist/chunk-NOGDOZIT.cjs.map +0 -1
- package/dist/chunk-NUWXEISH.cjs +0 -10
- package/dist/chunk-NUWXEISH.cjs.map +0 -1
- package/dist/chunk-NZCZHXYN.cjs +0 -161
- package/dist/chunk-NZCZHXYN.cjs.map +0 -1
- package/dist/chunk-ODROSWQX.cjs +0 -53
- package/dist/chunk-ODROSWQX.cjs.map +0 -1
- package/dist/chunk-OE36AYKG.cjs +0 -82
- package/dist/chunk-OE36AYKG.cjs.map +0 -1
- package/dist/chunk-OLON7MO6.cjs +0 -437
- package/dist/chunk-OLON7MO6.cjs.map +0 -1
- package/dist/chunk-PBUOR2IT.js +0 -277
- package/dist/chunk-PBUOR2IT.js.map +0 -1
- package/dist/chunk-PC2ELXFF.cjs +0 -225
- package/dist/chunk-PC2ELXFF.cjs.map +0 -1
- package/dist/chunk-PCSGXLOC.js +0 -71
- package/dist/chunk-PCSGXLOC.js.map +0 -1
- package/dist/chunk-PFNMP6FQ.js +0 -56
- package/dist/chunk-PFNMP6FQ.js.map +0 -1
- package/dist/chunk-PIWSZTIP.js +0 -690
- package/dist/chunk-PIWSZTIP.js.map +0 -1
- package/dist/chunk-PKWHJ2GI.js +0 -136
- package/dist/chunk-PKWHJ2GI.js.map +0 -1
- package/dist/chunk-PLMVBX2A.cjs +0 -76
- package/dist/chunk-PLMVBX2A.cjs.map +0 -1
- package/dist/chunk-PM3XCD2G.cjs +0 -113
- package/dist/chunk-PM3XCD2G.cjs.map +0 -1
- package/dist/chunk-QAL4GZO7.cjs +0 -143
- package/dist/chunk-QAL4GZO7.cjs.map +0 -1
- package/dist/chunk-QDB2SEA2.js +0 -74
- package/dist/chunk-QDB2SEA2.js.map +0 -1
- package/dist/chunk-QOV7UNUN.js +0 -25
- package/dist/chunk-QOV7UNUN.js.map +0 -1
- package/dist/chunk-QQUWYLSF.cjs +0 -50
- package/dist/chunk-QQUWYLSF.cjs.map +0 -1
- package/dist/chunk-QUMBH3U4.cjs +0 -9
- package/dist/chunk-QUMBH3U4.cjs.map +0 -1
- package/dist/chunk-R4KA7OFQ.js +0 -12
- package/dist/chunk-R4KA7OFQ.js.map +0 -1
- package/dist/chunk-RBSGAZQQ.js +0 -17
- package/dist/chunk-RBSGAZQQ.js.map +0 -1
- package/dist/chunk-RM5YJWZI.js +0 -46
- package/dist/chunk-RM5YJWZI.js.map +0 -1
- package/dist/chunk-ROKNKXA4.cjs +0 -8
- package/dist/chunk-ROKNKXA4.cjs.map +0 -1
- package/dist/chunk-RQG6D546.cjs +0 -75
- package/dist/chunk-RQG6D546.cjs.map +0 -1
- package/dist/chunk-SG4YDD5L.cjs +0 -74
- package/dist/chunk-SG4YDD5L.cjs.map +0 -1
- package/dist/chunk-SNRCA7EO.js +0 -56
- package/dist/chunk-SNRCA7EO.js.map +0 -1
- package/dist/chunk-SO75R4WW.cjs +0 -22
- package/dist/chunk-SO75R4WW.cjs.map +0 -1
- package/dist/chunk-SP34NHFI.js +0 -45
- package/dist/chunk-SP34NHFI.js.map +0 -1
- package/dist/chunk-SSKSSBWJ.cjs +0 -179
- package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
- package/dist/chunk-TB5663C2.js +0 -1108
- package/dist/chunk-TB5663C2.js.map +0 -1
- package/dist/chunk-TGH4NRES.js +0 -220
- package/dist/chunk-TGH4NRES.js.map +0 -1
- package/dist/chunk-TJ6ZPNID.js +0 -189
- package/dist/chunk-TJ6ZPNID.js.map +0 -1
- package/dist/chunk-U45T35N2.cjs +0 -90
- package/dist/chunk-U45T35N2.cjs.map +0 -1
- package/dist/chunk-UKVOPEZ2.js +0 -442
- package/dist/chunk-UKVOPEZ2.js.map +0 -1
- package/dist/chunk-UTB4NROA.cjs +0 -887
- package/dist/chunk-UTB4NROA.cjs.map +0 -1
- package/dist/chunk-UTW33B5V.js +0 -6
- package/dist/chunk-UTW33B5V.js.map +0 -1
- package/dist/chunk-UYUBSD2V.cjs +0 -33
- package/dist/chunk-UYUBSD2V.cjs.map +0 -1
- package/dist/chunk-V3JEP5AG.cjs +0 -59
- package/dist/chunk-V3JEP5AG.cjs.map +0 -1
- package/dist/chunk-VFAGJXHR.js +0 -18
- package/dist/chunk-VFAGJXHR.js.map +0 -1
- package/dist/chunk-VMEE57E5.cjs +0 -58
- package/dist/chunk-VMEE57E5.cjs.map +0 -1
- package/dist/chunk-VQVBEX3Y.cjs +0 -113
- package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
- package/dist/chunk-VZDXX7TT.cjs +0 -64
- package/dist/chunk-VZDXX7TT.cjs.map +0 -1
- package/dist/chunk-WE5ZTI4D.js +0 -346
- package/dist/chunk-WE5ZTI4D.js.map +0 -1
- package/dist/chunk-WEFUVABP.js +0 -19
- package/dist/chunk-WEFUVABP.js.map +0 -1
- package/dist/chunk-WMU4LRKC.js +0 -28
- package/dist/chunk-WMU4LRKC.js.map +0 -1
- package/dist/chunk-WQ24RRHL.cjs +0 -354
- package/dist/chunk-WQ24RRHL.cjs.map +0 -1
- package/dist/chunk-WW4CGS7G.cjs +0 -26
- package/dist/chunk-WW4CGS7G.cjs.map +0 -1
- package/dist/chunk-WXE5WCTM.js +0 -1144
- package/dist/chunk-WXE5WCTM.js.map +0 -1
- package/dist/chunk-X23BGIYA.cjs +0 -37
- package/dist/chunk-X23BGIYA.cjs.map +0 -1
- package/dist/chunk-XEW4FTR2.js +0 -98
- package/dist/chunk-XEW4FTR2.js.map +0 -1
- package/dist/chunk-XIOI4IYW.js +0 -167
- package/dist/chunk-XIOI4IYW.js.map +0 -1
- package/dist/chunk-XLVPJ37V.cjs +0 -44
- package/dist/chunk-XLVPJ37V.cjs.map +0 -1
- package/dist/chunk-XOHAXXZA.cjs +0 -51
- package/dist/chunk-XOHAXXZA.cjs.map +0 -1
- package/dist/chunk-Y4NRIHK6.cjs +0 -313
- package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
- package/dist/chunk-Y4YMMKL3.js +0 -23
- package/dist/chunk-Y4YMMKL3.js.map +0 -1
- package/dist/chunk-YJNYBVE3.cjs +0 -14
- package/dist/chunk-YJNYBVE3.cjs.map +0 -1
- package/dist/chunk-Z762QNQP.cjs +0 -60
- package/dist/chunk-Z762QNQP.cjs.map +0 -1
- package/dist/chunk-ZG5KMBOF.js +0 -669
- package/dist/chunk-ZG5KMBOF.js.map +0 -1
- package/dist/chunk-ZKONQEFA.js +0 -344
- package/dist/chunk-ZKONQEFA.js.map +0 -1
- package/dist/chunk-ZR5X7QMH.js +0 -39
- package/dist/chunk-ZR5X7QMH.js.map +0 -1
- package/dist/chunk-ZW4BJQ26.js +0 -84
- package/dist/chunk-ZW4BJQ26.js.map +0 -1
- package/dist/climbs-BhlWuu0x.d.ts +0 -70
- package/dist/climbs-DgBFwySV.d.cts +0 -70
- package/dist/data/index.cjs.map +0 -1
- package/dist/data/index.js.map +0 -1
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/geo/index.cjs.map +0 -1
- package/dist/geo/index.js.map +0 -1
- package/dist/icons/index.cjs.map +0 -1
- package/dist/icons/index.js.map +0 -1
- package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
- package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
- package/dist/layers/index.cjs.map +0 -1
- package/dist/layers/index.js.map +0 -1
- package/dist/map-client/index.cjs.map +0 -1
- package/dist/map-client/index.js.map +0 -1
- package/dist/markerSprite-DGBQF6PO.cjs +0 -49
- package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
- package/dist/markerSprite-DZLTR6F6.js +0 -8
- package/dist/markerSprite-DZLTR6F6.js.map +0 -1
- package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
- package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
- package/dist/paint-BgUcj8l7.d.cts +0 -118
- package/dist/paint-Dx_qGNE_.d.ts +0 -118
- package/dist/profile/index.cjs.map +0 -1
- package/dist/profile/index.js.map +0 -1
- package/dist/seams/index.cjs.map +0 -1
- package/dist/seams/index.js.map +0 -1
- package/dist/search/index.cjs.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
- package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
- package/dist/searchHighlight-MHAQZVWG.js +0 -12
- package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
- package/dist/strings-30RSdIat.d.cts +0 -552
- package/dist/strings-DPTIbzT5.d.ts +0 -552
- package/dist/stripeImage-CQUXM2YI.js +0 -14
- package/dist/stripeImage-CQUXM2YI.js.map +0 -1
- package/dist/stripeImage-R43OPA6U.cjs +0 -39
- package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
- package/dist/style/index.cjs.map +0 -1
- package/dist/style/index.js.map +0 -1
- package/dist/types-B034JMjl.d.ts +0 -973
- package/dist/types-B2NDLxQA.d.cts +0 -21
- package/dist/types-B2NDLxQA.d.ts +0 -21
- package/dist/types-C8aX5KMU.d.cts +0 -973
- package/dist/units/index.cjs.map +0 -1
- package/dist/units/index.js.map +0 -1
- package/dist/view/index.cjs.map +0 -1
- package/dist/view/index.js.map +0 -1
package/dist/video/index.js
CHANGED
|
@@ -1,2173 +1,1689 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { CAMERA_FPS } from
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (startMs === null) {
|
|
177
|
-
startMs = timeMs;
|
|
178
|
-
}
|
|
179
|
-
const elapsed = timeMs - startMs;
|
|
180
|
-
const fraction = totalMs <= 0 ? 1 : Math.min(1, elapsed / totalMs);
|
|
181
|
-
const index = Math.round(fraction * lastIndex);
|
|
182
|
-
const pose = poses[index] ?? poses[lastIndex];
|
|
183
|
-
if (pose) {
|
|
184
|
-
map.jumpTo(pose);
|
|
185
|
-
}
|
|
186
|
-
const marker = markers?.[index] ?? markers?.[lastIndex];
|
|
187
|
-
if (marker) {
|
|
188
|
-
map.setMarker(marker);
|
|
189
|
-
}
|
|
190
|
-
onProgress?.({ fraction, phase: "recording" });
|
|
191
|
-
if (fraction >= 1) {
|
|
192
|
-
finish();
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
frameHandle = schedule(step);
|
|
196
|
-
};
|
|
197
|
-
signal.addEventListener("abort", onAbort);
|
|
198
|
-
try {
|
|
199
|
-
frameHandle = schedule(step);
|
|
200
|
-
} catch (cause) {
|
|
201
|
-
finish({ cause });
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// src/video/profileOverlay/rules/contract.ts
|
|
207
|
-
var speedKilometersPerHour = (metersPerSecond) => metersPerSecond != null && Number.isFinite(metersPerSecond) ? convertSpeed(metersPerSecond, "meter-per-second", "kilometer-per-hour") : null;
|
|
208
|
-
var formatClimbBadge = (category, avgGradePercent, options) => {
|
|
209
|
-
const label = category === "hc" ? "HC" : `CAT ${category}`;
|
|
210
|
-
if (avgGradePercent === null || !Number.isFinite(avgGradePercent)) {
|
|
211
|
-
return label;
|
|
212
|
-
}
|
|
213
|
-
const grade = formatProportion(convertProportion(avgGradePercent, "percent", "ratio"), options, {
|
|
214
|
-
maximumFractionDigits: 1
|
|
215
|
-
});
|
|
216
|
-
return `${label} \xB7 ${grade}`;
|
|
217
|
-
};
|
|
218
|
-
var titleCase = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
219
|
-
var humanizeCategory = (value) => {
|
|
220
|
-
if (value === null) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
const spaced = value.replace(/[_-]+/g, " ").trim();
|
|
224
|
-
return spaced.length > 0 ? titleCase(spaced) : null;
|
|
225
|
-
};
|
|
226
|
-
var joinCategories = (surface, waytype) => {
|
|
227
|
-
const left = humanizeCategory(surface);
|
|
228
|
-
const right = humanizeCategory(waytype);
|
|
229
|
-
if (left && right) {
|
|
230
|
-
return `${left} \xB7 ${right}`;
|
|
231
|
-
}
|
|
232
|
-
return left ?? right;
|
|
233
|
-
};
|
|
234
|
-
var AXIS_MAX_TICKS = 6;
|
|
235
|
-
var axisDistanceTicks = (totalMeters, length) => {
|
|
236
|
-
if (!Number.isFinite(totalMeters) || totalMeters <= 0) {
|
|
237
|
-
return [];
|
|
238
|
-
}
|
|
239
|
-
const totalUnits = convertLength(totalMeters, "meter", distanceUnitFor(length));
|
|
240
|
-
return distanceTicks(
|
|
241
|
-
{ from: 0, to: totalMeters },
|
|
242
|
-
{ length },
|
|
243
|
-
Math.min(AXIS_MAX_TICKS + 1, totalUnits)
|
|
244
|
-
).filter((tick) => tick.value > 0 && tick.value < totalUnits * 0.97).map((tick) => tick.meters);
|
|
245
|
-
};
|
|
246
|
-
var formatAxisDistance = (meters, options, withUnit) => formatDistance(meters, options, { maximumFractionDigits: 0, withUnit });
|
|
247
|
-
|
|
248
|
-
// src/video/profileOverlay/rules/curve.ts
|
|
249
|
-
var elevationDomainFor = (minElevation, maxElevation) => extentDomain(minElevation, maxElevation);
|
|
250
|
-
var emptyCurve = () => ({
|
|
251
|
-
hasMultipleSegments: false,
|
|
252
|
-
highPointX: null,
|
|
253
|
-
maxElevation: null,
|
|
254
|
-
minElevation: null,
|
|
255
|
-
points: [],
|
|
256
|
-
totalAscentM: null,
|
|
257
|
-
totalKm: null
|
|
1
|
+
import { i as warmPosesThrough, r as PER_FRAME_IDLE_TIMEOUT_MS, t as MapLibreViewClient } from "../chunk-DjnYQBCN.js";
|
|
2
|
+
import { a as containerExtension, i as bitrateForOutput, r as aspectRatio, t as BITRATE_MBPS_MAX } from "../chunk-C8HdaHpu.js";
|
|
3
|
+
import { d as convertLength, f as convertProportion, i as MILLISECONDS_PER_SECOND, l as convertDataSize, m as convertSpeed, r as METERS_PER_KILOMETER } from "../chunk-DsDYVJQC.js";
|
|
4
|
+
import { a as errorFrom, t as MountayaElementsError } from "../chunk-Cl1etdlu.js";
|
|
5
|
+
import { h as formatSlope, l as formatElevation, m as formatProportion, r as distanceUnitFor, s as formatDistance, v as formatSpeed } from "../chunk-D1fe-0c_.js";
|
|
6
|
+
import { a as extentDomain, i as distanceTicks, n as STEEPNESS_THRESHOLDS, r as classifySteepness } from "../chunk-px4e99cy.js";
|
|
7
|
+
import { s as upperCase } from "../chunk-C5q1sgSa.js";
|
|
8
|
+
import { r as CAMERA_FPS } from "../chunk-C-IlmkDl.js";
|
|
9
|
+
import { n as videoOverlayStringsFor } from "../chunk-BfktMVmI.js";
|
|
10
|
+
import { LngLat, Marker, restoreNow, setNow } from "maplibre-gl";
|
|
11
|
+
const MAX_TILE_CACHE_SIZE = 2048;
|
|
12
|
+
const VIDEO_FOCUS_MARKER_FILL = "#ffffff";
|
|
13
|
+
const VIDEO_FOCUS_MARKER_STROKE = "#1a1a1a";
|
|
14
|
+
const VIDEO_FOCUS_MARKER_GLYPH_COLOR = "#334155";
|
|
15
|
+
const VIDEO_FOCUS_MARKER_GLYPH_RATIO = .62;
|
|
16
|
+
const VIDEO_FOCUS_MARKER_HALO_OPACITY = .35;
|
|
17
|
+
const VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS = 1600;
|
|
18
|
+
const WATERMARK_INSET_PX = 20;
|
|
19
|
+
const WATERMARK_WIDTH_PX = 480;
|
|
20
|
+
const WATERMARK_REFERENCE_SHORT_SIDE = 1080;
|
|
21
|
+
const WATERMARK_MIN_SCALE = .5;
|
|
22
|
+
const resolutionShortSidePx = {
|
|
23
|
+
"720p": 720,
|
|
24
|
+
"1080p": 1080,
|
|
25
|
+
"1440p": 1440,
|
|
26
|
+
"2160p": 2160
|
|
27
|
+
};
|
|
28
|
+
const toEven = (value) => {
|
|
29
|
+
const rounded = Math.round(value);
|
|
30
|
+
return Math.max(2, rounded % 2 === 0 ? rounded : rounded + 1);
|
|
31
|
+
};
|
|
32
|
+
const resolveDimensions = (output) => {
|
|
33
|
+
const shortSide = resolutionShortSidePx[output.resolution];
|
|
34
|
+
const ratio = aspectRatio(output.aspect);
|
|
35
|
+
if (ratio >= 1) return {
|
|
36
|
+
height: toEven(shortSide),
|
|
37
|
+
width: toEven(shortSide * ratio)
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
height: toEven(shortSide / ratio),
|
|
41
|
+
width: toEven(shortSide)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const resolveBitrateBps = (output) => {
|
|
45
|
+
const requested = output.bitrateMbps ?? bitrateForOutput(output.resolution, output.fps, "high");
|
|
46
|
+
return Math.round(convertDataSize(Math.min(BITRATE_MBPS_MAX, Math.max(1, requested)), "megabit", "bit"));
|
|
47
|
+
};
|
|
48
|
+
const watermarkScale = (width, height) => Math.max(WATERMARK_MIN_SCALE, Math.min(width, height) / WATERMARK_REFERENCE_SHORT_SIDE);
|
|
49
|
+
const flipRowsInPlace = (pixels, width, height, rowScratch) => {
|
|
50
|
+
const rowBytes = width * 4;
|
|
51
|
+
const half = Math.floor(height / 2);
|
|
52
|
+
for (let row = 0; row < half; row += 1) {
|
|
53
|
+
const topStart = row * rowBytes;
|
|
54
|
+
const bottomStart = (height - 1 - row) * rowBytes;
|
|
55
|
+
rowScratch.set(pixels.subarray(topStart, topStart + rowBytes));
|
|
56
|
+
pixels.copyWithin(topStart, bottomStart, bottomStart + rowBytes);
|
|
57
|
+
pixels.set(rowScratch, bottomStart);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const isBufferAllBlack = (buffer) => {
|
|
61
|
+
for (let index = 0; index < buffer.length; index += 4) if (buffer[index] !== 0 || buffer[index + 1] !== 0 || buffer[index + 2] !== 0) return false;
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
const createCanvasFrameCapture = (canvas) => {
|
|
65
|
+
const gl = canvas.getContext("webgl2") ?? canvas.getContext("webgl");
|
|
66
|
+
if (!gl) throw new MountayaElementsError("Video recorder: the map canvas exposes no WebGL context to read frames from.");
|
|
67
|
+
let scratchRow = /* @__PURE__ */ new Uint8Array(0);
|
|
68
|
+
return { capture: (out, width, height) => {
|
|
69
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, out);
|
|
70
|
+
const rowBytes = width * 4;
|
|
71
|
+
if (scratchRow.length !== rowBytes) scratchRow = new Uint8Array(rowBytes);
|
|
72
|
+
flipRowsInPlace(out, width, height, scratchRow);
|
|
73
|
+
} };
|
|
74
|
+
};
|
|
75
|
+
const PREVIEW_FALLBACK_FPS = 60;
|
|
76
|
+
const previewPoses = (args) => {
|
|
77
|
+
const { cancelFrame, map, markers, onProgress, planDurationMs, poses, requestFrame, signal } = args;
|
|
78
|
+
const schedule = requestFrame ?? ((callback) => requestAnimationFrame(callback));
|
|
79
|
+
const unschedule = cancelFrame ?? ((handle) => cancelAnimationFrame(handle));
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
if (poses.length === 0 || signal.aborted) {
|
|
82
|
+
resolve();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const lastIndex = poses.length - 1;
|
|
86
|
+
const totalMs = planDurationMs && planDurationMs > 0 ? planDurationMs : poses.length / PREVIEW_FALLBACK_FPS * MILLISECONDS_PER_SECOND;
|
|
87
|
+
let startMs = null;
|
|
88
|
+
let frameHandle = 0;
|
|
89
|
+
let settled = false;
|
|
90
|
+
const finish = (failure) => {
|
|
91
|
+
if (settled) return;
|
|
92
|
+
settled = true;
|
|
93
|
+
signal.removeEventListener("abort", onAbort);
|
|
94
|
+
let thrown = failure;
|
|
95
|
+
try {
|
|
96
|
+
map.setMarker(null);
|
|
97
|
+
} catch (cause) {
|
|
98
|
+
thrown ??= { cause };
|
|
99
|
+
}
|
|
100
|
+
if (thrown) reject(thrown.cause);
|
|
101
|
+
else resolve();
|
|
102
|
+
};
|
|
103
|
+
const onAbort = () => {
|
|
104
|
+
unschedule(frameHandle);
|
|
105
|
+
finish();
|
|
106
|
+
};
|
|
107
|
+
const step = (timeMs) => {
|
|
108
|
+
try {
|
|
109
|
+
advance(timeMs);
|
|
110
|
+
} catch (cause) {
|
|
111
|
+
finish({ cause });
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const advance = (timeMs) => {
|
|
115
|
+
if (signal.aborted) {
|
|
116
|
+
finish();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (startMs === null) startMs = timeMs;
|
|
120
|
+
const elapsed = timeMs - startMs;
|
|
121
|
+
const fraction = totalMs <= 0 ? 1 : Math.min(1, elapsed / totalMs);
|
|
122
|
+
const index = Math.round(fraction * lastIndex);
|
|
123
|
+
const pose = poses[index] ?? poses[lastIndex];
|
|
124
|
+
if (pose) map.jumpTo(pose);
|
|
125
|
+
const marker = markers?.[index] ?? markers?.[lastIndex];
|
|
126
|
+
if (marker) map.setMarker(marker);
|
|
127
|
+
onProgress?.({
|
|
128
|
+
fraction,
|
|
129
|
+
phase: "recording"
|
|
130
|
+
});
|
|
131
|
+
if (fraction >= 1) {
|
|
132
|
+
finish();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
frameHandle = schedule(step);
|
|
136
|
+
};
|
|
137
|
+
signal.addEventListener("abort", onAbort);
|
|
138
|
+
try {
|
|
139
|
+
frameHandle = schedule(step);
|
|
140
|
+
} catch (cause) {
|
|
141
|
+
finish({ cause });
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const speedKilometersPerHour = (metersPerSecond) => metersPerSecond != null && Number.isFinite(metersPerSecond) ? convertSpeed(metersPerSecond, "meter-per-second", "kilometer-per-hour") : null;
|
|
146
|
+
const formatClimbBadge = (category, avgGradePercent, options) => {
|
|
147
|
+
const label = category === "hc" ? "HC" : `CAT ${category}`;
|
|
148
|
+
if (avgGradePercent === null || !Number.isFinite(avgGradePercent)) return label;
|
|
149
|
+
return `${label} · ${formatProportion(convertProportion(avgGradePercent, "percent", "ratio"), options, { maximumFractionDigits: 1 })}`;
|
|
150
|
+
};
|
|
151
|
+
const titleCase = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
152
|
+
const humanizeCategory = (value) => {
|
|
153
|
+
if (value === null) return null;
|
|
154
|
+
const spaced = value.replace(/[_-]+/g, " ").trim();
|
|
155
|
+
return spaced.length > 0 ? titleCase(spaced) : null;
|
|
156
|
+
};
|
|
157
|
+
const joinCategories = (surface, waytype) => {
|
|
158
|
+
const left = humanizeCategory(surface);
|
|
159
|
+
const right = humanizeCategory(waytype);
|
|
160
|
+
if (left && right) return `${left} · ${right}`;
|
|
161
|
+
return left ?? right;
|
|
162
|
+
};
|
|
163
|
+
const axisDistanceTicks = (totalMeters, length) => {
|
|
164
|
+
if (!Number.isFinite(totalMeters) || totalMeters <= 0) return [];
|
|
165
|
+
const totalUnits = convertLength(totalMeters, "meter", distanceUnitFor(length));
|
|
166
|
+
return distanceTicks({
|
|
167
|
+
from: 0,
|
|
168
|
+
to: totalMeters
|
|
169
|
+
}, { length }, Math.min(7, totalUnits)).filter((tick) => tick.value > 0 && tick.value < totalUnits * .97).map((tick) => tick.meters);
|
|
170
|
+
};
|
|
171
|
+
const formatAxisDistance = (meters, options, withUnit) => formatDistance(meters, options, {
|
|
172
|
+
maximumFractionDigits: 0,
|
|
173
|
+
withUnit
|
|
258
174
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
let totalAscentM = null;
|
|
269
|
-
const names = /* @__PURE__ */ new Set();
|
|
270
|
-
for (const sample of samples) {
|
|
271
|
-
if (sample.elevation !== null) {
|
|
272
|
-
if (sample.elevation < minElevation) {
|
|
273
|
-
minElevation = sample.elevation;
|
|
274
|
-
}
|
|
275
|
-
if (sample.elevation > maxElevation) {
|
|
276
|
-
maxElevation = sample.elevation;
|
|
277
|
-
summit = sample;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (sample.ascentM !== null && (totalAscentM === null || sample.ascentM > totalAscentM)) {
|
|
281
|
-
totalAscentM = sample.ascentM;
|
|
282
|
-
}
|
|
283
|
-
if (sample.distanceKm > totalKm) {
|
|
284
|
-
totalKm = sample.distanceKm;
|
|
285
|
-
}
|
|
286
|
-
if (sample.segmentName !== null) {
|
|
287
|
-
names.add(sample.segmentName);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const hasMultipleSegments = names.size > 1;
|
|
291
|
-
if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation)) {
|
|
292
|
-
return {
|
|
293
|
-
hasMultipleSegments,
|
|
294
|
-
highPointX: null,
|
|
295
|
-
maxElevation: null,
|
|
296
|
-
minElevation: null,
|
|
297
|
-
points: [],
|
|
298
|
-
totalAscentM,
|
|
299
|
-
totalKm
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
const domain = elevationDomainFor(minElevation, maxElevation);
|
|
303
|
-
const span = domain.max - domain.min;
|
|
304
|
-
const points = [];
|
|
305
|
-
for (const sample of samples) {
|
|
306
|
-
if (sample.elevation === null) {
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
const y = (sample.elevation - domain.min) / span;
|
|
310
|
-
points.push({ slopeDeg: sample.slopeDeg, x: alongFlight(sample, totalKm), y });
|
|
311
|
-
}
|
|
312
|
-
return {
|
|
313
|
-
hasMultipleSegments,
|
|
314
|
-
// Placed once the walk is over: the extent it is read against is the walk's own result.
|
|
315
|
-
highPointX: summit ? alongFlight(summit, totalKm) : null,
|
|
316
|
-
maxElevation,
|
|
317
|
-
minElevation,
|
|
318
|
-
points,
|
|
319
|
-
totalAscentM,
|
|
320
|
-
totalKm
|
|
321
|
-
};
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
// src/video/profileOverlay/rules/fonts.ts
|
|
325
|
-
var OVERLAY_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
|
|
326
|
-
var OVERLAY_FONT_FACES = [];
|
|
327
|
-
var ensureOverlayFonts = async () => {
|
|
328
|
-
if (typeof document === "undefined") {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const fonts = document.fonts;
|
|
332
|
-
if (typeof fonts?.load !== "function") {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
await Promise.all(OVERLAY_FONT_FACES.map((face) => fonts.load(face))).catch(() => {
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
// src/video/profileOverlay/rules/draw.ts
|
|
340
|
-
var OVERLAY_REFERENCE_SHORT_SIDE = 1080;
|
|
341
|
-
var overlayScale = (width, height) => Math.max(0.5, Math.min(width, height) / OVERLAY_REFERENCE_SHORT_SIDE);
|
|
342
|
-
var overlayPalette = {
|
|
343
|
-
accent: "#3b82f6",
|
|
344
|
-
accentDim: "rgba(59, 130, 246, 0.35)",
|
|
345
|
-
accentHalo: "rgba(59, 130, 246, 0.22)",
|
|
346
|
-
axisText: "rgba(245, 247, 250, 0.45)",
|
|
347
|
-
badgeCat: "#f5f7fa",
|
|
348
|
-
badgeDarkText: "#0b0e11",
|
|
349
|
-
badgeHc: "#dc2626",
|
|
350
|
-
hairline: "rgba(255, 255, 255, 0.18)",
|
|
351
|
-
hairlineStrong: "rgba(255, 255, 255, 0.35)",
|
|
352
|
-
labelText: "rgba(245, 247, 250, 0.55)",
|
|
353
|
-
panel: "rgba(15, 18, 22, 0.72)",
|
|
354
|
-
primaryText: "#f5f7fa",
|
|
355
|
-
secondaryText: "rgba(245, 247, 250, 0.66)"
|
|
356
|
-
};
|
|
357
|
-
var CURVE_COVERED_FILL_ALPHA = 0.55;
|
|
358
|
-
var CURVE_AHEAD_FILL_ALPHA = 0.18;
|
|
359
|
-
var steepnessBandColors = {
|
|
360
|
-
"25-30": "#f97316",
|
|
361
|
-
"30-35": "#ea580c",
|
|
362
|
-
"35-40": "#dc2626",
|
|
363
|
-
"40-45": "#b91c1c",
|
|
364
|
-
"45+": "#7f1d1d",
|
|
365
|
-
gentle: "#22c55e",
|
|
366
|
-
moderate: "#eab308"
|
|
367
|
-
};
|
|
368
|
-
var GENTLE_SLOPE_DEGREES = 12;
|
|
369
|
-
var slopeBandColor = (degrees) => {
|
|
370
|
-
if (degrees === null || !Number.isFinite(degrees)) {
|
|
371
|
-
return overlayPalette.secondaryText;
|
|
372
|
-
}
|
|
373
|
-
const magnitude = Math.abs(degrees);
|
|
374
|
-
if (magnitude < GENTLE_SLOPE_DEGREES) {
|
|
375
|
-
return steepnessBandColors.gentle;
|
|
376
|
-
}
|
|
377
|
-
if (magnitude < STEEPNESS_THRESHOLDS[0]) {
|
|
378
|
-
return steepnessBandColors.moderate;
|
|
379
|
-
}
|
|
380
|
-
const band = classifySteepness(magnitude);
|
|
381
|
-
return band ? steepnessBandColors[band] : steepnessBandColors.gentle;
|
|
382
|
-
};
|
|
383
|
-
var slopeBandTextColor = (degrees) => {
|
|
384
|
-
if (degrees === null || !Number.isFinite(degrees)) {
|
|
385
|
-
return overlayPalette.badgeDarkText;
|
|
386
|
-
}
|
|
387
|
-
return Math.abs(degrees) < STEEPNESS_THRESHOLDS[0] ? overlayPalette.badgeDarkText : overlayPalette.primaryText;
|
|
388
|
-
};
|
|
389
|
-
var drawChip = (ctx, text, x, topY, scale, spec, align = "left") => {
|
|
390
|
-
const font = overlayFont(700, spec.fontPx, scale);
|
|
391
|
-
const pad = spec.padPx * scale;
|
|
392
|
-
const height = spec.heightPx * scale;
|
|
393
|
-
const width = measureTextWidth(ctx, text, font) + pad * 2;
|
|
394
|
-
const left = align === "left" ? x : x - width;
|
|
395
|
-
fillRoundedRect(ctx, left, topY, width, height, height / 2, spec.bg);
|
|
396
|
-
drawText(ctx, text, left + pad, topY + height * 0.7, {
|
|
397
|
-
align: "left",
|
|
398
|
-
color: spec.fg,
|
|
399
|
-
font
|
|
400
|
-
});
|
|
401
|
-
return width;
|
|
402
|
-
};
|
|
403
|
-
var roundedRectPath = (ctx, x, y, width, height, radius) => {
|
|
404
|
-
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
405
|
-
ctx.beginPath();
|
|
406
|
-
ctx.moveTo(x + r, y);
|
|
407
|
-
ctx.arcTo(x + width, y, x + width, y + height, r);
|
|
408
|
-
ctx.arcTo(x + width, y + height, x, y + height, r);
|
|
409
|
-
ctx.arcTo(x, y + height, x, y, r);
|
|
410
|
-
ctx.arcTo(x, y, x + width, y, r);
|
|
411
|
-
ctx.closePath();
|
|
412
|
-
};
|
|
413
|
-
var fillRoundedRect = (ctx, x, y, width, height, radius, color) => {
|
|
414
|
-
roundedRectPath(ctx, x, y, width, height, radius);
|
|
415
|
-
ctx.fillStyle = color;
|
|
416
|
-
ctx.fill();
|
|
417
|
-
};
|
|
418
|
-
var drawText = (ctx, text, x, y, style) => {
|
|
419
|
-
ctx.font = style.font;
|
|
420
|
-
ctx.fillStyle = style.color;
|
|
421
|
-
ctx.textAlign = style.align;
|
|
422
|
-
ctx.textBaseline = "alphabetic";
|
|
423
|
-
ctx.fillText(text, x, y);
|
|
424
|
-
};
|
|
425
|
-
var measureTextWidth = (ctx, text, font) => {
|
|
426
|
-
ctx.font = font;
|
|
427
|
-
return ctx.measureText(text).width;
|
|
428
|
-
};
|
|
429
|
-
var overlayFont = (weight, px, scale) => `${weight} ${Math.round(px * scale)}px ${OVERLAY_FONT_FAMILY}`;
|
|
430
|
-
var MICRO_LABEL_TRACKING_PX = 1.4;
|
|
431
|
-
var microLabelFont = (scale) => overlayFont(700, 12, scale);
|
|
432
|
-
var trackMicroLabel = (ctx, scale, on) => {
|
|
433
|
-
if ("letterSpacing" in ctx) {
|
|
434
|
-
ctx.letterSpacing = on ? `${(MICRO_LABEL_TRACKING_PX * scale).toFixed(2)}px` : "0px";
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
var microLabelText = (text, language) => language === void 0 ? text.toUpperCase() : upperCase(text, language);
|
|
438
|
-
var measureMicroLabel = (ctx, text, scale, language) => {
|
|
439
|
-
trackMicroLabel(ctx, scale, true);
|
|
440
|
-
const width = measureTextWidth(ctx, microLabelText(text, language), microLabelFont(scale));
|
|
441
|
-
trackMicroLabel(ctx, scale, false);
|
|
442
|
-
return width;
|
|
443
|
-
};
|
|
444
|
-
var drawMicroLabel = (ctx, text, x, y, scale, color, align = "left", language) => {
|
|
445
|
-
trackMicroLabel(ctx, scale, true);
|
|
446
|
-
drawText(ctx, microLabelText(text, language), x, y, {
|
|
447
|
-
align,
|
|
448
|
-
color,
|
|
449
|
-
font: microLabelFont(scale)
|
|
450
|
-
});
|
|
451
|
-
trackMicroLabel(ctx, scale, false);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// src/video/profileOverlay/rules/staticLayer.ts
|
|
455
|
-
var CURVE_STROKE_BLEED_PX = 6;
|
|
456
|
-
var AXIS_STRIP_PX = 24;
|
|
457
|
-
var REFERENCE_CURVE_HEIGHT = 108;
|
|
458
|
-
var BAND_BAR_DIM_ALPHA = 0.35;
|
|
459
|
-
var defaultCanvasFactory = () => document.createElement("canvas");
|
|
460
|
-
var traceCurvePath = (ctx, points, rect, originX = 0, originY = 0) => {
|
|
461
|
-
const toX = (fraction) => originX + fraction * rect.w;
|
|
462
|
-
const toY = (normalized) => originY + rect.h - normalized * rect.h;
|
|
463
|
-
ctx.beginPath();
|
|
464
|
-
ctx.moveTo(toX(points[0]?.x ?? 0), originY + rect.h);
|
|
465
|
-
for (const point of points) {
|
|
466
|
-
ctx.lineTo(toX(point.x), toY(point.y));
|
|
467
|
-
}
|
|
468
|
-
ctx.lineTo(toX(points[points.length - 1]?.x ?? 1), originY + rect.h);
|
|
469
|
-
ctx.closePath();
|
|
470
|
-
};
|
|
471
|
-
var traceRidgePath = (ctx, points, rect, originX, originY) => {
|
|
472
|
-
const toX = (fraction) => originX + fraction * rect.w;
|
|
473
|
-
const toY = (normalized) => originY + rect.h - normalized * rect.h;
|
|
474
|
-
ctx.beginPath();
|
|
475
|
-
ctx.moveTo(toX(points[0]?.x ?? 0), toY(points[0]?.y ?? 0));
|
|
476
|
-
for (const point of points) {
|
|
477
|
-
ctx.lineTo(toX(point.x), toY(point.y));
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
var paintCurveLayer = (ctx, points, rect, originX, originY, fillAlpha, ridgeColor, ridgeWidth) => {
|
|
481
|
-
ctx.save();
|
|
482
|
-
traceCurvePath(ctx, points, rect, originX, originY);
|
|
483
|
-
ctx.clip();
|
|
484
|
-
ctx.globalAlpha = fillAlpha;
|
|
485
|
-
for (let index = 0; index < points.length - 1; index += 1) {
|
|
486
|
-
const point = points[index];
|
|
487
|
-
const next = points[index + 1];
|
|
488
|
-
if (!point || !next) {
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
const x0 = originX + point.x * rect.w;
|
|
492
|
-
const x1 = originX + next.x * rect.w;
|
|
493
|
-
if (x1 <= x0) {
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
ctx.fillStyle = slopeBandColor(point.slopeDeg);
|
|
497
|
-
ctx.fillRect(x0, originY, x1 - x0 + 0.5, rect.h);
|
|
498
|
-
}
|
|
499
|
-
ctx.restore();
|
|
500
|
-
traceRidgePath(ctx, points, rect, originX, originY);
|
|
501
|
-
ctx.lineJoin = "round";
|
|
502
|
-
ctx.lineWidth = ridgeWidth;
|
|
503
|
-
ctx.strokeStyle = ridgeColor;
|
|
504
|
-
ctx.stroke();
|
|
505
|
-
};
|
|
506
|
-
var paintAxisStrip = (ctx, curve, rect, originX, baselineY, format, palette, scale) => {
|
|
507
|
-
if (curve.totalKm === null || curve.totalKm <= 0) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
const totalMeters = curve.totalKm * METERS_PER_KILOMETER;
|
|
511
|
-
const ticks = axisDistanceTicks(totalMeters, format.length);
|
|
512
|
-
const labelFont = overlayFont(400, 11, scale);
|
|
513
|
-
for (let index = 0; index < ticks.length; index += 1) {
|
|
514
|
-
const meters = ticks[index] ?? 0;
|
|
515
|
-
const x = originX + meters / totalMeters * rect.w;
|
|
516
|
-
ctx.fillStyle = palette.hairline;
|
|
517
|
-
ctx.fillRect(x - Math.max(0.5, 0.5 * scale), baselineY, Math.max(1, 1 * scale), 6 * scale);
|
|
518
|
-
ctx.font = labelFont;
|
|
519
|
-
ctx.fillStyle = palette.axisText;
|
|
520
|
-
ctx.textAlign = "center";
|
|
521
|
-
ctx.textBaseline = "alphabetic";
|
|
522
|
-
ctx.fillText(
|
|
523
|
-
formatAxisDistance(meters, format, index === ticks.length - 1),
|
|
524
|
-
x,
|
|
525
|
-
baselineY + 18 * scale
|
|
526
|
-
);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
var paintSummitMarker = (ctx, curve, rect, originX, originY, palette, scale, summitLabel) => {
|
|
530
|
-
if (curve.highPointX === null || summitLabel.length === 0) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
const x = originX + curve.highPointX * rect.w;
|
|
534
|
-
let summitY = curve.points.length === 0 ? 1 : 0;
|
|
535
|
-
for (const point of curve.points) {
|
|
536
|
-
summitY = Math.max(summitY, point.y);
|
|
537
|
-
}
|
|
538
|
-
const ridgeY = originY + rect.h - summitY * rect.h;
|
|
539
|
-
ctx.fillStyle = palette.primaryText;
|
|
540
|
-
ctx.fillRect(x - Math.max(0.5, 1 * scale), ridgeY, Math.max(1, 2 * scale), 10 * scale);
|
|
541
|
-
const flip = curve.highPointX > 0.82;
|
|
542
|
-
ctx.font = overlayFont(700, 13, scale);
|
|
543
|
-
ctx.fillStyle = palette.primaryText;
|
|
544
|
-
ctx.textAlign = flip ? "right" : "left";
|
|
545
|
-
ctx.textBaseline = "alphabetic";
|
|
546
|
-
ctx.fillText(summitLabel, x + (flip ? -8 : 8) * scale, ridgeY + 16 * scale);
|
|
547
|
-
};
|
|
548
|
-
var bakeCurveLayers = (curve, rect, palette, format, scale, summitLabel, createCanvas = defaultCanvasFactory) => {
|
|
549
|
-
if (typeof document === "undefined") {
|
|
550
|
-
return null;
|
|
551
|
-
}
|
|
552
|
-
const strokeScale = rect.h > 0 ? rect.h / REFERENCE_CURVE_HEIGHT : 1;
|
|
553
|
-
const bleed = Math.ceil(CURVE_STROKE_BLEED_PX * strokeScale);
|
|
554
|
-
const axisStrip = Math.ceil(AXIS_STRIP_PX * scale);
|
|
555
|
-
const layerHeight = Math.max(1, Math.ceil(rect.h + bleed + axisStrip));
|
|
556
|
-
const layerWidth = Math.max(1, Math.ceil(rect.w));
|
|
557
|
-
const dim = createCanvas();
|
|
558
|
-
dim.width = layerWidth;
|
|
559
|
-
dim.height = layerHeight;
|
|
560
|
-
const dimContext = dim.getContext("2d");
|
|
561
|
-
const bright = createCanvas();
|
|
562
|
-
bright.width = layerWidth;
|
|
563
|
-
bright.height = layerHeight;
|
|
564
|
-
const brightContext = bright.getContext("2d");
|
|
565
|
-
if (!dimContext || !brightContext) {
|
|
566
|
-
return null;
|
|
567
|
-
}
|
|
568
|
-
const ridgeWidth = Math.max(1, 3 * strokeScale);
|
|
569
|
-
const brightRidgeWidth = Math.max(1, 3.5 * strokeScale);
|
|
570
|
-
paintCurveLayer(
|
|
571
|
-
dimContext,
|
|
572
|
-
curve.points,
|
|
573
|
-
rect,
|
|
574
|
-
0,
|
|
575
|
-
bleed,
|
|
576
|
-
CURVE_AHEAD_FILL_ALPHA,
|
|
577
|
-
palette.accentDim,
|
|
578
|
-
ridgeWidth
|
|
579
|
-
);
|
|
580
|
-
paintAxisStrip(dimContext, curve, rect, 0, bleed + rect.h, format, palette, scale);
|
|
581
|
-
paintSummitMarker(dimContext, curve, rect, 0, bleed, palette, scale, summitLabel);
|
|
582
|
-
paintCurveLayer(
|
|
583
|
-
brightContext,
|
|
584
|
-
curve.points,
|
|
585
|
-
rect,
|
|
586
|
-
0,
|
|
587
|
-
bleed,
|
|
588
|
-
CURVE_COVERED_FILL_ALPHA,
|
|
589
|
-
palette.accent,
|
|
590
|
-
brightRidgeWidth
|
|
591
|
-
);
|
|
592
|
-
return { axisStrip, bleed, bright, dim };
|
|
593
|
-
};
|
|
594
|
-
var coloursOf = (palette) => Object.entries(palette).sort(([left], [right]) => left < right ? -1 : 1).join("|");
|
|
595
|
-
var paintedWith = (baked, palette) => baked.palette === palette || baked.colours === coloursOf(palette);
|
|
596
|
-
var layerCache = /* @__PURE__ */ new WeakMap();
|
|
597
|
-
var layersKey = (rect, format) => `${rect.x}x${rect.y}x${rect.w}x${rect.h}|${format.length}|${format.slope}|${format.language}`;
|
|
598
|
-
var acquireCurveLayers = (curve, rect, palette, format, scale, summitLabel) => {
|
|
599
|
-
const key = layersKey(rect, format);
|
|
600
|
-
const cached = layerCache.get(curve);
|
|
601
|
-
if (cached && cached.key === key && paintedWith(cached, palette)) {
|
|
602
|
-
return cached.layers;
|
|
603
|
-
}
|
|
604
|
-
const layers = bakeCurveLayers(curve, rect, palette, format, scale, summitLabel);
|
|
605
|
-
layerCache.set(curve, { colours: coloursOf(palette), key, layers, palette });
|
|
606
|
-
return layers;
|
|
607
|
-
};
|
|
608
|
-
var paintBandBar = (ctx, curve, x, y, width, height, alpha, palette) => {
|
|
609
|
-
ctx.save();
|
|
610
|
-
const r = height / 2;
|
|
611
|
-
ctx.beginPath();
|
|
612
|
-
ctx.moveTo(x + r, y);
|
|
613
|
-
ctx.arcTo(x + width, y, x + width, y + height, r);
|
|
614
|
-
ctx.arcTo(x + width, y + height, x, y + height, r);
|
|
615
|
-
ctx.arcTo(x, y + height, x, y, r);
|
|
616
|
-
ctx.arcTo(x, y, x + width, y, r);
|
|
617
|
-
ctx.closePath();
|
|
618
|
-
ctx.clip();
|
|
619
|
-
ctx.globalAlpha = alpha;
|
|
620
|
-
const points = curve.points;
|
|
621
|
-
if (points.length >= 2) {
|
|
622
|
-
for (let index = 0; index < points.length - 1; index += 1) {
|
|
623
|
-
const point = points[index];
|
|
624
|
-
const next = points[index + 1];
|
|
625
|
-
if (!point || !next) {
|
|
626
|
-
continue;
|
|
627
|
-
}
|
|
628
|
-
const x0 = x + point.x * width;
|
|
629
|
-
const x1 = x + next.x * width;
|
|
630
|
-
if (x1 <= x0) {
|
|
631
|
-
continue;
|
|
632
|
-
}
|
|
633
|
-
ctx.fillStyle = slopeBandColor(point.slopeDeg);
|
|
634
|
-
ctx.fillRect(x0, y, x1 - x0 + 0.5, height);
|
|
635
|
-
}
|
|
636
|
-
} else {
|
|
637
|
-
ctx.fillStyle = palette.hairline;
|
|
638
|
-
ctx.fillRect(x, y, width, height);
|
|
639
|
-
}
|
|
640
|
-
ctx.globalAlpha = 1;
|
|
641
|
-
if (curve.highPointX !== null) {
|
|
642
|
-
ctx.fillStyle = palette.primaryText;
|
|
643
|
-
ctx.fillRect(x + curve.highPointX * width - 1, y, 2, height);
|
|
644
|
-
}
|
|
645
|
-
ctx.restore();
|
|
646
|
-
};
|
|
647
|
-
var bandBarCache = /* @__PURE__ */ new WeakMap();
|
|
648
|
-
var acquireBandBar = (curve, widthPx, heightPx, palette, createCanvas = defaultCanvasFactory) => {
|
|
649
|
-
if (typeof document === "undefined") {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
const key = `${Math.ceil(widthPx)}x${Math.ceil(heightPx)}`;
|
|
653
|
-
const cached = bandBarCache.get(curve);
|
|
654
|
-
if (cached && cached.key === key && paintedWith(cached, palette)) {
|
|
655
|
-
return cached.layers;
|
|
656
|
-
}
|
|
657
|
-
const width = Math.max(1, Math.ceil(widthPx));
|
|
658
|
-
const height = Math.max(1, Math.ceil(heightPx));
|
|
659
|
-
const build = (alpha) => {
|
|
660
|
-
const canvas = createCanvas();
|
|
661
|
-
canvas.width = width;
|
|
662
|
-
canvas.height = height;
|
|
663
|
-
const ctx = canvas.getContext("2d");
|
|
664
|
-
if (!ctx) {
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
paintBandBar(ctx, curve, 0, 0, width, height, alpha, palette);
|
|
668
|
-
return canvas;
|
|
669
|
-
};
|
|
670
|
-
const dim = build(BAND_BAR_DIM_ALPHA);
|
|
671
|
-
const bright = build(1);
|
|
672
|
-
const layers = dim && bright ? { bright, dim } : null;
|
|
673
|
-
bandBarCache.set(curve, { colours: coloursOf(palette), key, layers, palette });
|
|
674
|
-
return layers;
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
// src/video/profileOverlay/rules/types.ts
|
|
678
|
-
var clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
679
|
-
|
|
680
|
-
// src/video/profileOverlay/rules/graphDesign.ts
|
|
681
|
-
var ridgeYAt = (points, fraction) => {
|
|
682
|
-
if (points.length === 0) {
|
|
683
|
-
return 0;
|
|
684
|
-
}
|
|
685
|
-
let low = 0;
|
|
686
|
-
let high = points.length - 1;
|
|
687
|
-
while (low < high) {
|
|
688
|
-
const mid = low + high >> 1;
|
|
689
|
-
if ((points[mid]?.x ?? 0) < fraction) {
|
|
690
|
-
low = mid + 1;
|
|
691
|
-
} else {
|
|
692
|
-
high = mid;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
const after = low;
|
|
696
|
-
const before = low > 0 ? low - 1 : 0;
|
|
697
|
-
const afterGap = Math.abs((points[after]?.x ?? 0) - fraction);
|
|
698
|
-
const beforeGap = Math.abs((points[before]?.x ?? 0) - fraction);
|
|
699
|
-
return (beforeGap <= afterGap ? points[before]?.y : points[after]?.y) ?? 0;
|
|
700
|
-
};
|
|
701
|
-
var ZERO_WIDTH_JOINER = "\u200D";
|
|
702
|
-
var ellipsize = (ctx, text, font, maxWidth) => {
|
|
703
|
-
if (maxWidth <= 0) {
|
|
704
|
-
return "";
|
|
705
|
-
}
|
|
706
|
-
let cuts = ellipsizedCuts.get(ctx);
|
|
707
|
-
if (cuts === void 0) {
|
|
708
|
-
cuts = /* @__PURE__ */ new Map();
|
|
709
|
-
ellipsizedCuts.set(ctx, cuts);
|
|
710
|
-
}
|
|
711
|
-
const key = `${font}\0${maxWidth}\0${text}`;
|
|
712
|
-
const known = cuts.get(key);
|
|
713
|
-
if (known !== void 0) {
|
|
714
|
-
return known;
|
|
715
|
-
}
|
|
716
|
-
if (cuts.size >= ELLIPSIZED_CUTS_MAX) {
|
|
717
|
-
cuts.clear();
|
|
718
|
-
}
|
|
719
|
-
const cut = cutToFit(ctx, text, font, maxWidth);
|
|
720
|
-
cuts.set(key, cut);
|
|
721
|
-
return cut;
|
|
722
|
-
};
|
|
723
|
-
var ELLIPSIZED_CUTS_MAX = 256;
|
|
724
|
-
var ellipsizedCuts = /* @__PURE__ */ new WeakMap();
|
|
725
|
-
var cutToFit = (ctx, text, font, maxWidth) => {
|
|
726
|
-
if (measureTextWidth(ctx, text, font) <= maxWidth) {
|
|
727
|
-
return text;
|
|
728
|
-
}
|
|
729
|
-
const ellipsis = "\u2026";
|
|
730
|
-
const characters = Array.from(text);
|
|
731
|
-
let trimmed = text;
|
|
732
|
-
while (characters.length > 1 && measureTextWidth(ctx, `${trimmed}${ellipsis}`, font) > maxWidth) {
|
|
733
|
-
characters.pop();
|
|
734
|
-
while (characters.length > 1 && characters.at(-1) === ZERO_WIDTH_JOINER) {
|
|
735
|
-
characters.pop();
|
|
736
|
-
}
|
|
737
|
-
trimmed = characters.join("");
|
|
738
|
-
}
|
|
739
|
-
return `${trimmed}${ellipsis}`;
|
|
740
|
-
};
|
|
741
|
-
var BADGE_CHIP_HEIGHT_PX = 24;
|
|
742
|
-
var GRADIENT_CHIP_HEIGHT_PX = 34;
|
|
743
|
-
var climbBadgeSpec = (category) => {
|
|
744
|
-
const severe = category === "hc" || category === "1";
|
|
745
|
-
return {
|
|
746
|
-
bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
|
|
747
|
-
fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
|
|
748
|
-
fontPx: 13,
|
|
749
|
-
heightPx: BADGE_CHIP_HEIGHT_PX,
|
|
750
|
-
padPx: 10
|
|
751
|
-
};
|
|
752
|
-
};
|
|
753
|
-
var drawCurve = (ctx, covered, curve, rect, format, scale) => {
|
|
754
|
-
const points = curve.points;
|
|
755
|
-
const coveredWidth = covered * rect.w;
|
|
756
|
-
const summitLabel = formatElevation(curve.maxElevation, format);
|
|
757
|
-
const layers = acquireCurveLayers(curve, rect, overlayPalette, format, scale, summitLabel);
|
|
758
|
-
if (layers) {
|
|
759
|
-
const top = rect.y - layers.bleed;
|
|
760
|
-
ctx.drawImage(layers.dim, rect.x, top);
|
|
761
|
-
ctx.save();
|
|
762
|
-
ctx.beginPath();
|
|
763
|
-
ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
|
|
764
|
-
ctx.clip();
|
|
765
|
-
ctx.drawImage(layers.bright, rect.x, top);
|
|
766
|
-
ctx.restore();
|
|
767
|
-
} else {
|
|
768
|
-
paintCurveLayer(
|
|
769
|
-
ctx,
|
|
770
|
-
points,
|
|
771
|
-
rect,
|
|
772
|
-
rect.x,
|
|
773
|
-
rect.y,
|
|
774
|
-
CURVE_AHEAD_FILL_ALPHA,
|
|
775
|
-
overlayPalette.accentDim,
|
|
776
|
-
Math.max(1, 3 * scale)
|
|
777
|
-
);
|
|
778
|
-
paintAxisStrip(ctx, curve, rect, rect.x, rect.y + rect.h, format, overlayPalette, scale);
|
|
779
|
-
paintSummitMarker(ctx, curve, rect, rect.x, rect.y, overlayPalette, scale, summitLabel);
|
|
780
|
-
ctx.save();
|
|
781
|
-
ctx.beginPath();
|
|
782
|
-
ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
|
|
783
|
-
ctx.clip();
|
|
784
|
-
paintCurveLayer(
|
|
785
|
-
ctx,
|
|
786
|
-
points,
|
|
787
|
-
rect,
|
|
788
|
-
rect.x,
|
|
789
|
-
rect.y,
|
|
790
|
-
CURVE_COVERED_FILL_ALPHA,
|
|
791
|
-
overlayPalette.accent,
|
|
792
|
-
Math.max(1, 3.5 * scale)
|
|
793
|
-
);
|
|
794
|
-
ctx.restore();
|
|
795
|
-
}
|
|
796
|
-
ctx.beginPath();
|
|
797
|
-
ctx.moveTo(rect.x, rect.y + rect.h);
|
|
798
|
-
ctx.lineTo(rect.x + rect.w, rect.y + rect.h);
|
|
799
|
-
ctx.lineWidth = Math.max(1, 1 * scale);
|
|
800
|
-
ctx.strokeStyle = overlayPalette.hairlineStrong;
|
|
801
|
-
ctx.stroke();
|
|
802
|
-
const dotX = rect.x + covered * rect.w;
|
|
803
|
-
const dotY = rect.y + rect.h - ridgeYAt(points, covered) * rect.h;
|
|
804
|
-
ctx.beginPath();
|
|
805
|
-
ctx.arc(dotX, dotY, Math.max(2, 11 * scale), 0, Math.PI * 2);
|
|
806
|
-
ctx.fillStyle = overlayPalette.accentHalo;
|
|
807
|
-
ctx.fill();
|
|
808
|
-
ctx.beginPath();
|
|
809
|
-
ctx.arc(dotX, dotY, Math.max(1.5, 5.5 * scale), 0, Math.PI * 2);
|
|
810
|
-
ctx.fillStyle = overlayPalette.accent;
|
|
811
|
-
ctx.fill();
|
|
812
|
-
ctx.lineWidth = Math.max(1, 2 * scale);
|
|
813
|
-
ctx.strokeStyle = overlayPalette.primaryText;
|
|
814
|
-
ctx.stroke();
|
|
815
|
-
};
|
|
816
|
-
var graphReadouts = (sample, curve, format) => ({
|
|
817
|
-
ascent: formatElevation(sample.ascentM, format),
|
|
818
|
-
category: joinCategories(sample.surface, sample.waytype),
|
|
819
|
-
distance: formatDistance(sample.distanceKm * METERS_PER_KILOMETER, format),
|
|
820
|
-
elevation: formatElevation(sample.elevation, format),
|
|
821
|
-
remaining: curve.totalKm !== null ? formatDistance(
|
|
822
|
-
Math.max(0, curve.totalKm - sample.distanceKm) * METERS_PER_KILOMETER,
|
|
823
|
-
format
|
|
824
|
-
) : "",
|
|
825
|
-
slope: formatSlope(sample.slopeDeg, format),
|
|
826
|
-
speed: formatSpeed(speedKilometersPerHour(sample.speed), format),
|
|
827
|
-
toSummit: sample.climbEndKm !== null ? formatDistance(
|
|
828
|
-
Math.max(0, sample.climbEndKm - sample.distanceKm) * METERS_PER_KILOMETER,
|
|
829
|
-
format
|
|
830
|
-
) : "",
|
|
831
|
-
totalAscent: formatElevation(curve.totalAscentM, format)
|
|
175
|
+
const elevationDomainFor = (minElevation, maxElevation) => extentDomain(minElevation, maxElevation);
|
|
176
|
+
const emptyCurve = () => ({
|
|
177
|
+
hasMultipleSegments: false,
|
|
178
|
+
highPointX: null,
|
|
179
|
+
maxElevation: null,
|
|
180
|
+
minElevation: null,
|
|
181
|
+
points: [],
|
|
182
|
+
totalAscentM: null,
|
|
183
|
+
totalKm: null
|
|
832
184
|
});
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
};
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
185
|
+
const alongFlight = (sample, totalKm) => totalKm !== null && totalKm > 0 ? sample.distanceKm / totalKm : sample.progress;
|
|
186
|
+
const buildProfileCurve = (samples) => {
|
|
187
|
+
if (samples.length === 0) return emptyCurve();
|
|
188
|
+
let minElevation = Number.POSITIVE_INFINITY;
|
|
189
|
+
let maxElevation = Number.NEGATIVE_INFINITY;
|
|
190
|
+
let totalKm = 0;
|
|
191
|
+
let summit = null;
|
|
192
|
+
let totalAscentM = null;
|
|
193
|
+
const names = /* @__PURE__ */ new Set();
|
|
194
|
+
for (const sample of samples) {
|
|
195
|
+
if (sample.elevation !== null) {
|
|
196
|
+
if (sample.elevation < minElevation) minElevation = sample.elevation;
|
|
197
|
+
if (sample.elevation > maxElevation) {
|
|
198
|
+
maxElevation = sample.elevation;
|
|
199
|
+
summit = sample;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (sample.ascentM !== null && (totalAscentM === null || sample.ascentM > totalAscentM)) totalAscentM = sample.ascentM;
|
|
203
|
+
if (sample.distanceKm > totalKm) totalKm = sample.distanceKm;
|
|
204
|
+
if (sample.segmentName !== null) names.add(sample.segmentName);
|
|
205
|
+
}
|
|
206
|
+
const hasMultipleSegments = names.size > 1;
|
|
207
|
+
if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation)) return {
|
|
208
|
+
hasMultipleSegments,
|
|
209
|
+
highPointX: null,
|
|
210
|
+
maxElevation: null,
|
|
211
|
+
minElevation: null,
|
|
212
|
+
points: [],
|
|
213
|
+
totalAscentM,
|
|
214
|
+
totalKm
|
|
215
|
+
};
|
|
216
|
+
const domain = elevationDomainFor(minElevation, maxElevation);
|
|
217
|
+
const span = domain.max - domain.min;
|
|
218
|
+
const points = [];
|
|
219
|
+
for (const sample of samples) {
|
|
220
|
+
if (sample.elevation === null) continue;
|
|
221
|
+
const y = (sample.elevation - domain.min) / span;
|
|
222
|
+
points.push({
|
|
223
|
+
slopeDeg: sample.slopeDeg,
|
|
224
|
+
x: alongFlight(sample, totalKm),
|
|
225
|
+
y
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
hasMultipleSegments,
|
|
230
|
+
highPointX: summit ? alongFlight(summit, totalKm) : null,
|
|
231
|
+
maxElevation,
|
|
232
|
+
minElevation,
|
|
233
|
+
points,
|
|
234
|
+
totalAscentM,
|
|
235
|
+
totalKm
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const OVERLAY_FONT_FAMILY = "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif";
|
|
239
|
+
const OVERLAY_FONT_FACES = [];
|
|
240
|
+
const ensureOverlayFonts = async () => {
|
|
241
|
+
if (typeof document === "undefined") return;
|
|
242
|
+
const fonts = document.fonts;
|
|
243
|
+
if (typeof fonts?.load !== "function") return;
|
|
244
|
+
await Promise.all(OVERLAY_FONT_FACES.map((face) => fonts.load(face))).catch(() => {});
|
|
245
|
+
};
|
|
246
|
+
const OVERLAY_REFERENCE_SHORT_SIDE = 1080;
|
|
247
|
+
const overlayScale = (width, height) => Math.max(.5, Math.min(width, height) / OVERLAY_REFERENCE_SHORT_SIDE);
|
|
248
|
+
const overlayPalette = {
|
|
249
|
+
accent: "#3b82f6",
|
|
250
|
+
accentDim: "rgba(59, 130, 246, 0.35)",
|
|
251
|
+
accentHalo: "rgba(59, 130, 246, 0.22)",
|
|
252
|
+
axisText: "rgba(245, 247, 250, 0.45)",
|
|
253
|
+
badgeCat: "#f5f7fa",
|
|
254
|
+
badgeDarkText: "#0b0e11",
|
|
255
|
+
badgeHc: "#dc2626",
|
|
256
|
+
hairline: "rgba(255, 255, 255, 0.18)",
|
|
257
|
+
hairlineStrong: "rgba(255, 255, 255, 0.35)",
|
|
258
|
+
labelText: "rgba(245, 247, 250, 0.55)",
|
|
259
|
+
panel: "rgba(15, 18, 22, 0.72)",
|
|
260
|
+
primaryText: "#f5f7fa",
|
|
261
|
+
secondaryText: "rgba(245, 247, 250, 0.66)"
|
|
262
|
+
};
|
|
263
|
+
const CURVE_COVERED_FILL_ALPHA = .55;
|
|
264
|
+
const CURVE_AHEAD_FILL_ALPHA = .18;
|
|
265
|
+
const steepnessBandColors = {
|
|
266
|
+
"25-30": "#f97316",
|
|
267
|
+
"30-35": "#ea580c",
|
|
268
|
+
"35-40": "#dc2626",
|
|
269
|
+
"40-45": "#b91c1c",
|
|
270
|
+
"45+": "#7f1d1d",
|
|
271
|
+
gentle: "#22c55e",
|
|
272
|
+
moderate: "#eab308"
|
|
273
|
+
};
|
|
274
|
+
const GENTLE_SLOPE_DEGREES = 12;
|
|
275
|
+
const slopeBandColor = (degrees) => {
|
|
276
|
+
if (degrees === null || !Number.isFinite(degrees)) return overlayPalette.secondaryText;
|
|
277
|
+
const magnitude = Math.abs(degrees);
|
|
278
|
+
if (magnitude < GENTLE_SLOPE_DEGREES) return steepnessBandColors.gentle;
|
|
279
|
+
if (magnitude < STEEPNESS_THRESHOLDS[0]) return steepnessBandColors.moderate;
|
|
280
|
+
const band = classifySteepness(magnitude);
|
|
281
|
+
return band ? steepnessBandColors[band] : steepnessBandColors.gentle;
|
|
282
|
+
};
|
|
283
|
+
const slopeBandTextColor = (degrees) => {
|
|
284
|
+
if (degrees === null || !Number.isFinite(degrees)) return overlayPalette.badgeDarkText;
|
|
285
|
+
return Math.abs(degrees) < STEEPNESS_THRESHOLDS[0] ? overlayPalette.badgeDarkText : overlayPalette.primaryText;
|
|
286
|
+
};
|
|
287
|
+
const drawChip = (ctx, text, x, topY, scale, spec, align = "left") => {
|
|
288
|
+
const font = overlayFont(700, spec.fontPx, scale);
|
|
289
|
+
const pad = spec.padPx * scale;
|
|
290
|
+
const height = spec.heightPx * scale;
|
|
291
|
+
const width = measureTextWidth(ctx, text, font) + pad * 2;
|
|
292
|
+
const left = align === "left" ? x : x - width;
|
|
293
|
+
fillRoundedRect(ctx, left, topY, width, height, height / 2, spec.bg);
|
|
294
|
+
drawText(ctx, text, left + pad, topY + height * .7, {
|
|
295
|
+
align: "left",
|
|
296
|
+
color: spec.fg,
|
|
297
|
+
font
|
|
298
|
+
});
|
|
299
|
+
return width;
|
|
300
|
+
};
|
|
301
|
+
const roundedRectPath = (ctx, x, y, width, height, radius) => {
|
|
302
|
+
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
303
|
+
ctx.beginPath();
|
|
304
|
+
ctx.moveTo(x + r, y);
|
|
305
|
+
ctx.arcTo(x + width, y, x + width, y + height, r);
|
|
306
|
+
ctx.arcTo(x + width, y + height, x, y + height, r);
|
|
307
|
+
ctx.arcTo(x, y + height, x, y, r);
|
|
308
|
+
ctx.arcTo(x, y, x + width, y, r);
|
|
309
|
+
ctx.closePath();
|
|
310
|
+
};
|
|
311
|
+
const fillRoundedRect = (ctx, x, y, width, height, radius, color) => {
|
|
312
|
+
roundedRectPath(ctx, x, y, width, height, radius);
|
|
313
|
+
ctx.fillStyle = color;
|
|
314
|
+
ctx.fill();
|
|
315
|
+
};
|
|
316
|
+
const drawText = (ctx, text, x, y, style) => {
|
|
317
|
+
ctx.font = style.font;
|
|
318
|
+
ctx.fillStyle = style.color;
|
|
319
|
+
ctx.textAlign = style.align;
|
|
320
|
+
ctx.textBaseline = "alphabetic";
|
|
321
|
+
ctx.fillText(text, x, y);
|
|
322
|
+
};
|
|
323
|
+
const measureTextWidth = (ctx, text, font) => {
|
|
324
|
+
ctx.font = font;
|
|
325
|
+
return ctx.measureText(text).width;
|
|
326
|
+
};
|
|
327
|
+
const overlayFont = (weight, px, scale) => `${weight} ${Math.round(px * scale)}px ${OVERLAY_FONT_FAMILY}`;
|
|
328
|
+
const MICRO_LABEL_TRACKING_PX = 1.4;
|
|
329
|
+
const microLabelFont = (scale) => overlayFont(700, 12, scale);
|
|
330
|
+
const trackMicroLabel = (ctx, scale, on) => {
|
|
331
|
+
if ("letterSpacing" in ctx) ctx.letterSpacing = on ? `${(MICRO_LABEL_TRACKING_PX * scale).toFixed(2)}px` : "0px";
|
|
332
|
+
};
|
|
333
|
+
const microLabelText = (text, language) => language === void 0 ? text.toUpperCase() : upperCase(text, language);
|
|
334
|
+
const measureMicroLabel = (ctx, text, scale, language) => {
|
|
335
|
+
trackMicroLabel(ctx, scale, true);
|
|
336
|
+
const width = measureTextWidth(ctx, microLabelText(text, language), microLabelFont(scale));
|
|
337
|
+
trackMicroLabel(ctx, scale, false);
|
|
338
|
+
return width;
|
|
339
|
+
};
|
|
340
|
+
const drawMicroLabel = (ctx, text, x, y, scale, color, align = "left", language) => {
|
|
341
|
+
trackMicroLabel(ctx, scale, true);
|
|
342
|
+
drawText(ctx, microLabelText(text, language), x, y, {
|
|
343
|
+
align,
|
|
344
|
+
color,
|
|
345
|
+
font: microLabelFont(scale)
|
|
346
|
+
});
|
|
347
|
+
trackMicroLabel(ctx, scale, false);
|
|
348
|
+
};
|
|
349
|
+
const CURVE_STROKE_BLEED_PX = 6;
|
|
350
|
+
const AXIS_STRIP_PX = 24;
|
|
351
|
+
const REFERENCE_CURVE_HEIGHT = 108;
|
|
352
|
+
const BAND_BAR_DIM_ALPHA = .35;
|
|
353
|
+
const defaultCanvasFactory = () => document.createElement("canvas");
|
|
354
|
+
const traceCurvePath = (ctx, points, rect, originX = 0, originY = 0) => {
|
|
355
|
+
const toX = (fraction) => originX + fraction * rect.w;
|
|
356
|
+
const toY = (normalized) => originY + rect.h - normalized * rect.h;
|
|
357
|
+
ctx.beginPath();
|
|
358
|
+
ctx.moveTo(toX(points[0]?.x ?? 0), originY + rect.h);
|
|
359
|
+
for (const point of points) ctx.lineTo(toX(point.x), toY(point.y));
|
|
360
|
+
ctx.lineTo(toX(points[points.length - 1]?.x ?? 1), originY + rect.h);
|
|
361
|
+
ctx.closePath();
|
|
362
|
+
};
|
|
363
|
+
const traceRidgePath = (ctx, points, rect, originX, originY) => {
|
|
364
|
+
const toX = (fraction) => originX + fraction * rect.w;
|
|
365
|
+
const toY = (normalized) => originY + rect.h - normalized * rect.h;
|
|
366
|
+
ctx.beginPath();
|
|
367
|
+
ctx.moveTo(toX(points[0]?.x ?? 0), toY(points[0]?.y ?? 0));
|
|
368
|
+
for (const point of points) ctx.lineTo(toX(point.x), toY(point.y));
|
|
369
|
+
};
|
|
370
|
+
const paintCurveLayer = (ctx, points, rect, originX, originY, fillAlpha, ridgeColor, ridgeWidth) => {
|
|
371
|
+
ctx.save();
|
|
372
|
+
traceCurvePath(ctx, points, rect, originX, originY);
|
|
373
|
+
ctx.clip();
|
|
374
|
+
ctx.globalAlpha = fillAlpha;
|
|
375
|
+
for (let index = 0; index < points.length - 1; index += 1) {
|
|
376
|
+
const point = points[index];
|
|
377
|
+
const next = points[index + 1];
|
|
378
|
+
if (!point || !next) continue;
|
|
379
|
+
const x0 = originX + point.x * rect.w;
|
|
380
|
+
const x1 = originX + next.x * rect.w;
|
|
381
|
+
if (x1 <= x0) continue;
|
|
382
|
+
ctx.fillStyle = slopeBandColor(point.slopeDeg);
|
|
383
|
+
ctx.fillRect(x0, originY, x1 - x0 + .5, rect.h);
|
|
384
|
+
}
|
|
385
|
+
ctx.restore();
|
|
386
|
+
traceRidgePath(ctx, points, rect, originX, originY);
|
|
387
|
+
ctx.lineJoin = "round";
|
|
388
|
+
ctx.lineWidth = ridgeWidth;
|
|
389
|
+
ctx.strokeStyle = ridgeColor;
|
|
390
|
+
ctx.stroke();
|
|
391
|
+
};
|
|
392
|
+
const paintAxisStrip = (ctx, curve, rect, originX, baselineY, format, palette, scale) => {
|
|
393
|
+
if (curve.totalKm === null || curve.totalKm <= 0) return;
|
|
394
|
+
const totalMeters = curve.totalKm * METERS_PER_KILOMETER;
|
|
395
|
+
const ticks = axisDistanceTicks(totalMeters, format.length);
|
|
396
|
+
const labelFont = overlayFont(400, 11, scale);
|
|
397
|
+
for (let index = 0; index < ticks.length; index += 1) {
|
|
398
|
+
const meters = ticks[index] ?? 0;
|
|
399
|
+
const x = originX + meters / totalMeters * rect.w;
|
|
400
|
+
ctx.fillStyle = palette.hairline;
|
|
401
|
+
ctx.fillRect(x - Math.max(.5, .5 * scale), baselineY, Math.max(1, 1 * scale), 6 * scale);
|
|
402
|
+
ctx.font = labelFont;
|
|
403
|
+
ctx.fillStyle = palette.axisText;
|
|
404
|
+
ctx.textAlign = "center";
|
|
405
|
+
ctx.textBaseline = "alphabetic";
|
|
406
|
+
ctx.fillText(formatAxisDistance(meters, format, index === ticks.length - 1), x, baselineY + 18 * scale);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
const paintSummitMarker = (ctx, curve, rect, originX, originY, palette, scale, summitLabel) => {
|
|
410
|
+
if (curve.highPointX === null || summitLabel.length === 0) return;
|
|
411
|
+
const x = originX + curve.highPointX * rect.w;
|
|
412
|
+
let summitY = curve.points.length === 0 ? 1 : 0;
|
|
413
|
+
for (const point of curve.points) summitY = Math.max(summitY, point.y);
|
|
414
|
+
const ridgeY = originY + rect.h - summitY * rect.h;
|
|
415
|
+
ctx.fillStyle = palette.primaryText;
|
|
416
|
+
ctx.fillRect(x - Math.max(.5, 1 * scale), ridgeY, Math.max(1, 2 * scale), 10 * scale);
|
|
417
|
+
const flip = curve.highPointX > .82;
|
|
418
|
+
ctx.font = overlayFont(700, 13, scale);
|
|
419
|
+
ctx.fillStyle = palette.primaryText;
|
|
420
|
+
ctx.textAlign = flip ? "right" : "left";
|
|
421
|
+
ctx.textBaseline = "alphabetic";
|
|
422
|
+
ctx.fillText(summitLabel, x + (flip ? -8 : 8) * scale, ridgeY + 16 * scale);
|
|
423
|
+
};
|
|
424
|
+
const bakeCurveLayers = (curve, rect, palette, format, scale, summitLabel, createCanvas = defaultCanvasFactory) => {
|
|
425
|
+
if (typeof document === "undefined") return null;
|
|
426
|
+
const strokeScale = rect.h > 0 ? rect.h / REFERENCE_CURVE_HEIGHT : 1;
|
|
427
|
+
const bleed = Math.ceil(CURVE_STROKE_BLEED_PX * strokeScale);
|
|
428
|
+
const axisStrip = Math.ceil(AXIS_STRIP_PX * scale);
|
|
429
|
+
const layerHeight = Math.max(1, Math.ceil(rect.h + bleed + axisStrip));
|
|
430
|
+
const layerWidth = Math.max(1, Math.ceil(rect.w));
|
|
431
|
+
const dim = createCanvas();
|
|
432
|
+
dim.width = layerWidth;
|
|
433
|
+
dim.height = layerHeight;
|
|
434
|
+
const dimContext = dim.getContext("2d");
|
|
435
|
+
const bright = createCanvas();
|
|
436
|
+
bright.width = layerWidth;
|
|
437
|
+
bright.height = layerHeight;
|
|
438
|
+
const brightContext = bright.getContext("2d");
|
|
439
|
+
if (!dimContext || !brightContext) return null;
|
|
440
|
+
const ridgeWidth = Math.max(1, 3 * strokeScale);
|
|
441
|
+
const brightRidgeWidth = Math.max(1, 3.5 * strokeScale);
|
|
442
|
+
paintCurveLayer(dimContext, curve.points, rect, 0, bleed, CURVE_AHEAD_FILL_ALPHA, palette.accentDim, ridgeWidth);
|
|
443
|
+
paintAxisStrip(dimContext, curve, rect, 0, bleed + rect.h, format, palette, scale);
|
|
444
|
+
paintSummitMarker(dimContext, curve, rect, 0, bleed, palette, scale, summitLabel);
|
|
445
|
+
paintCurveLayer(brightContext, curve.points, rect, 0, bleed, CURVE_COVERED_FILL_ALPHA, palette.accent, brightRidgeWidth);
|
|
446
|
+
return {
|
|
447
|
+
axisStrip,
|
|
448
|
+
bleed,
|
|
449
|
+
bright,
|
|
450
|
+
dim
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
const coloursOf = (palette) => Object.entries(palette).sort(([left], [right]) => left < right ? -1 : 1).join("|");
|
|
454
|
+
const paintedWith = (baked, palette) => baked.palette === palette || baked.colours === coloursOf(palette);
|
|
455
|
+
const layerCache = /* @__PURE__ */ new WeakMap();
|
|
456
|
+
const layersKey = (rect, format) => `${rect.x}x${rect.y}x${rect.w}x${rect.h}|${format.length}|${format.slope}|${format.language}`;
|
|
457
|
+
const acquireCurveLayers = (curve, rect, palette, format, scale, summitLabel) => {
|
|
458
|
+
const key = layersKey(rect, format);
|
|
459
|
+
const cached = layerCache.get(curve);
|
|
460
|
+
if (cached && cached.key === key && paintedWith(cached, palette)) return cached.layers;
|
|
461
|
+
const layers = bakeCurveLayers(curve, rect, palette, format, scale, summitLabel);
|
|
462
|
+
layerCache.set(curve, {
|
|
463
|
+
colours: coloursOf(palette),
|
|
464
|
+
key,
|
|
465
|
+
layers,
|
|
466
|
+
palette
|
|
467
|
+
});
|
|
468
|
+
return layers;
|
|
469
|
+
};
|
|
470
|
+
const paintBandBar = (ctx, curve, x, y, width, height, alpha, palette) => {
|
|
471
|
+
ctx.save();
|
|
472
|
+
const r = height / 2;
|
|
473
|
+
ctx.beginPath();
|
|
474
|
+
ctx.moveTo(x + r, y);
|
|
475
|
+
ctx.arcTo(x + width, y, x + width, y + height, r);
|
|
476
|
+
ctx.arcTo(x + width, y + height, x, y + height, r);
|
|
477
|
+
ctx.arcTo(x, y + height, x, y, r);
|
|
478
|
+
ctx.arcTo(x, y, x + width, y, r);
|
|
479
|
+
ctx.closePath();
|
|
480
|
+
ctx.clip();
|
|
481
|
+
ctx.globalAlpha = alpha;
|
|
482
|
+
const points = curve.points;
|
|
483
|
+
if (points.length >= 2) for (let index = 0; index < points.length - 1; index += 1) {
|
|
484
|
+
const point = points[index];
|
|
485
|
+
const next = points[index + 1];
|
|
486
|
+
if (!point || !next) continue;
|
|
487
|
+
const x0 = x + point.x * width;
|
|
488
|
+
const x1 = x + next.x * width;
|
|
489
|
+
if (x1 <= x0) continue;
|
|
490
|
+
ctx.fillStyle = slopeBandColor(point.slopeDeg);
|
|
491
|
+
ctx.fillRect(x0, y, x1 - x0 + .5, height);
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
ctx.fillStyle = palette.hairline;
|
|
495
|
+
ctx.fillRect(x, y, width, height);
|
|
496
|
+
}
|
|
497
|
+
ctx.globalAlpha = 1;
|
|
498
|
+
if (curve.highPointX !== null) {
|
|
499
|
+
ctx.fillStyle = palette.primaryText;
|
|
500
|
+
ctx.fillRect(x + curve.highPointX * width - 1, y, 2, height);
|
|
501
|
+
}
|
|
502
|
+
ctx.restore();
|
|
503
|
+
};
|
|
504
|
+
const bandBarCache = /* @__PURE__ */ new WeakMap();
|
|
505
|
+
const acquireBandBar = (curve, widthPx, heightPx, palette, createCanvas = defaultCanvasFactory) => {
|
|
506
|
+
if (typeof document === "undefined") return null;
|
|
507
|
+
const key = `${Math.ceil(widthPx)}x${Math.ceil(heightPx)}`;
|
|
508
|
+
const cached = bandBarCache.get(curve);
|
|
509
|
+
if (cached && cached.key === key && paintedWith(cached, palette)) return cached.layers;
|
|
510
|
+
const width = Math.max(1, Math.ceil(widthPx));
|
|
511
|
+
const height = Math.max(1, Math.ceil(heightPx));
|
|
512
|
+
const build = (alpha) => {
|
|
513
|
+
const canvas = createCanvas();
|
|
514
|
+
canvas.width = width;
|
|
515
|
+
canvas.height = height;
|
|
516
|
+
const ctx = canvas.getContext("2d");
|
|
517
|
+
if (!ctx) return null;
|
|
518
|
+
paintBandBar(ctx, curve, 0, 0, width, height, alpha, palette);
|
|
519
|
+
return canvas;
|
|
520
|
+
};
|
|
521
|
+
const dim = build(BAND_BAR_DIM_ALPHA);
|
|
522
|
+
const bright = build(1);
|
|
523
|
+
const layers = dim && bright ? {
|
|
524
|
+
bright,
|
|
525
|
+
dim
|
|
526
|
+
} : null;
|
|
527
|
+
bandBarCache.set(curve, {
|
|
528
|
+
colours: coloursOf(palette),
|
|
529
|
+
key,
|
|
530
|
+
layers,
|
|
531
|
+
palette
|
|
532
|
+
});
|
|
533
|
+
return layers;
|
|
534
|
+
};
|
|
535
|
+
const clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
536
|
+
const ridgeYAt = (points, fraction) => {
|
|
537
|
+
if (points.length === 0) return 0;
|
|
538
|
+
let low = 0;
|
|
539
|
+
let high = points.length - 1;
|
|
540
|
+
while (low < high) {
|
|
541
|
+
const mid = low + high >> 1;
|
|
542
|
+
if ((points[mid]?.x ?? 0) < fraction) low = mid + 1;
|
|
543
|
+
else high = mid;
|
|
544
|
+
}
|
|
545
|
+
const after = low;
|
|
546
|
+
const before = low > 0 ? low - 1 : 0;
|
|
547
|
+
const afterGap = Math.abs((points[after]?.x ?? 0) - fraction);
|
|
548
|
+
return (Math.abs((points[before]?.x ?? 0) - fraction) <= afterGap ? points[before]?.y : points[after]?.y) ?? 0;
|
|
549
|
+
};
|
|
550
|
+
const ZERO_WIDTH_JOINER = "";
|
|
551
|
+
const ellipsize = (ctx, text, font, maxWidth) => {
|
|
552
|
+
if (maxWidth <= 0) return "";
|
|
553
|
+
let cuts = ellipsizedCuts.get(ctx);
|
|
554
|
+
if (cuts === void 0) {
|
|
555
|
+
cuts = /* @__PURE__ */ new Map();
|
|
556
|
+
ellipsizedCuts.set(ctx, cuts);
|
|
557
|
+
}
|
|
558
|
+
const key = `${font}\u0000${maxWidth}\u0000${text}`;
|
|
559
|
+
const known = cuts.get(key);
|
|
560
|
+
if (known !== void 0) return known;
|
|
561
|
+
if (cuts.size >= ELLIPSIZED_CUTS_MAX) cuts.clear();
|
|
562
|
+
const cut = cutToFit(ctx, text, font, maxWidth);
|
|
563
|
+
cuts.set(key, cut);
|
|
564
|
+
return cut;
|
|
565
|
+
};
|
|
566
|
+
const ELLIPSIZED_CUTS_MAX = 256;
|
|
567
|
+
const ellipsizedCuts = /* @__PURE__ */ new WeakMap();
|
|
568
|
+
const cutToFit = (ctx, text, font, maxWidth) => {
|
|
569
|
+
if (measureTextWidth(ctx, text, font) <= maxWidth) return text;
|
|
570
|
+
const ellipsis = "…";
|
|
571
|
+
const characters = Array.from(text);
|
|
572
|
+
let trimmed = text;
|
|
573
|
+
while (characters.length > 1 && measureTextWidth(ctx, `${trimmed}${ellipsis}`, font) > maxWidth) {
|
|
574
|
+
characters.pop();
|
|
575
|
+
while (characters.length > 1 && characters.at(-1) === ZERO_WIDTH_JOINER) characters.pop();
|
|
576
|
+
trimmed = characters.join("");
|
|
577
|
+
}
|
|
578
|
+
return `${trimmed}${ellipsis}`;
|
|
579
|
+
};
|
|
580
|
+
const BADGE_CHIP_HEIGHT_PX = 24;
|
|
581
|
+
const GRADIENT_CHIP_HEIGHT_PX = 34;
|
|
582
|
+
const climbBadgeSpec = (category) => {
|
|
583
|
+
const severe = category === "hc" || category === "1";
|
|
584
|
+
return {
|
|
585
|
+
bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
|
|
586
|
+
fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
|
|
587
|
+
fontPx: 13,
|
|
588
|
+
heightPx: BADGE_CHIP_HEIGHT_PX,
|
|
589
|
+
padPx: 10
|
|
590
|
+
};
|
|
591
|
+
};
|
|
592
|
+
const drawCurve = (ctx, covered, curve, rect, format, scale) => {
|
|
593
|
+
const points = curve.points;
|
|
594
|
+
const coveredWidth = covered * rect.w;
|
|
595
|
+
const summitLabel = formatElevation(curve.maxElevation, format);
|
|
596
|
+
const layers = acquireCurveLayers(curve, rect, overlayPalette, format, scale, summitLabel);
|
|
597
|
+
if (layers) {
|
|
598
|
+
const top = rect.y - layers.bleed;
|
|
599
|
+
ctx.drawImage(layers.dim, rect.x, top);
|
|
600
|
+
ctx.save();
|
|
601
|
+
ctx.beginPath();
|
|
602
|
+
ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
|
|
603
|
+
ctx.clip();
|
|
604
|
+
ctx.drawImage(layers.bright, rect.x, top);
|
|
605
|
+
ctx.restore();
|
|
606
|
+
} else {
|
|
607
|
+
paintCurveLayer(ctx, points, rect, rect.x, rect.y, CURVE_AHEAD_FILL_ALPHA, overlayPalette.accentDim, Math.max(1, 3 * scale));
|
|
608
|
+
paintAxisStrip(ctx, curve, rect, rect.x, rect.y + rect.h, format, overlayPalette, scale);
|
|
609
|
+
paintSummitMarker(ctx, curve, rect, rect.x, rect.y, overlayPalette, scale, summitLabel);
|
|
610
|
+
ctx.save();
|
|
611
|
+
ctx.beginPath();
|
|
612
|
+
ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
|
|
613
|
+
ctx.clip();
|
|
614
|
+
paintCurveLayer(ctx, points, rect, rect.x, rect.y, CURVE_COVERED_FILL_ALPHA, overlayPalette.accent, Math.max(1, 3.5 * scale));
|
|
615
|
+
ctx.restore();
|
|
616
|
+
}
|
|
617
|
+
ctx.beginPath();
|
|
618
|
+
ctx.moveTo(rect.x, rect.y + rect.h);
|
|
619
|
+
ctx.lineTo(rect.x + rect.w, rect.y + rect.h);
|
|
620
|
+
ctx.lineWidth = Math.max(1, 1 * scale);
|
|
621
|
+
ctx.strokeStyle = overlayPalette.hairlineStrong;
|
|
622
|
+
ctx.stroke();
|
|
623
|
+
const dotX = rect.x + covered * rect.w;
|
|
624
|
+
const dotY = rect.y + rect.h - ridgeYAt(points, covered) * rect.h;
|
|
625
|
+
ctx.beginPath();
|
|
626
|
+
ctx.arc(dotX, dotY, Math.max(2, 11 * scale), 0, Math.PI * 2);
|
|
627
|
+
ctx.fillStyle = overlayPalette.accentHalo;
|
|
628
|
+
ctx.fill();
|
|
629
|
+
ctx.beginPath();
|
|
630
|
+
ctx.arc(dotX, dotY, Math.max(1.5, 5.5 * scale), 0, Math.PI * 2);
|
|
631
|
+
ctx.fillStyle = overlayPalette.accent;
|
|
632
|
+
ctx.fill();
|
|
633
|
+
ctx.lineWidth = Math.max(1, 2 * scale);
|
|
634
|
+
ctx.strokeStyle = overlayPalette.primaryText;
|
|
635
|
+
ctx.stroke();
|
|
636
|
+
};
|
|
637
|
+
const graphReadouts = (sample, curve, format) => ({
|
|
638
|
+
ascent: formatElevation(sample.ascentM, format),
|
|
639
|
+
category: joinCategories(sample.surface, sample.waytype),
|
|
640
|
+
distance: formatDistance(sample.distanceKm * METERS_PER_KILOMETER, format),
|
|
641
|
+
elevation: formatElevation(sample.elevation, format),
|
|
642
|
+
remaining: curve.totalKm !== null ? formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * METERS_PER_KILOMETER, format) : "",
|
|
643
|
+
slope: formatSlope(sample.slopeDeg, format),
|
|
644
|
+
speed: formatSpeed(speedKilometersPerHour(sample.speed), format),
|
|
645
|
+
toSummit: sample.climbEndKm !== null ? formatDistance(Math.max(0, sample.climbEndKm - sample.distanceKm) * METERS_PER_KILOMETER, format) : "",
|
|
646
|
+
totalAscent: formatElevation(curve.totalAscentM, format)
|
|
647
|
+
});
|
|
648
|
+
const gridLabel = (grid, text, x, baseline, align = "left") => {
|
|
649
|
+
drawMicroLabel(grid.ctx, text, x, baseline, grid.scale, overlayPalette.labelText, align);
|
|
650
|
+
};
|
|
651
|
+
const gridValue = (grid, text, x, baseline, align, px = 22) => {
|
|
652
|
+
drawText(grid.ctx, text, x, baseline, {
|
|
653
|
+
align,
|
|
654
|
+
color: overlayPalette.primaryText,
|
|
655
|
+
font: overlayFont(700, px, grid.scale)
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
const gradientChip = (grid, x, valueBaseline) => {
|
|
659
|
+
const { ctx, scale, slopeDeg, texts } = grid;
|
|
660
|
+
drawChip(ctx, texts.slope, x, valueBaseline - GRADIENT_CHIP_HEIGHT_PX * .7 * scale, scale, {
|
|
661
|
+
bg: slopeBandColor(slopeDeg),
|
|
662
|
+
fg: slopeBandTextColor(slopeDeg),
|
|
663
|
+
fontPx: 20,
|
|
664
|
+
heightPx: GRADIENT_CHIP_HEIGHT_PX,
|
|
665
|
+
padPx: 12
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
const dPlusValue = (grid, x, baseline) => {
|
|
669
|
+
const { ctx, scale, texts } = grid;
|
|
670
|
+
const runFont = overlayFont(700, 20, scale);
|
|
671
|
+
const run = `+${texts.ascent}`;
|
|
672
|
+
drawText(ctx, run, x, baseline, {
|
|
673
|
+
align: "left",
|
|
674
|
+
color: overlayPalette.primaryText,
|
|
675
|
+
font: runFont
|
|
676
|
+
});
|
|
677
|
+
if (texts.totalAscent.length > 0) drawText(ctx, ` / ${texts.totalAscent}`, x + measureTextWidth(ctx, run, runFont), baseline, {
|
|
678
|
+
align: "left",
|
|
679
|
+
color: overlayPalette.secondaryText,
|
|
680
|
+
font: overlayFont(400, 15, scale)
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
const drawOverline = (ctx, sample, curve, format, row) => {
|
|
684
|
+
const { baseline, covered, left, panelW, rightEdge, scale } = row;
|
|
685
|
+
const chipTop = baseline - 17 * scale;
|
|
686
|
+
if (curve.hasMultipleSegments && sample.segmentName !== null) {
|
|
687
|
+
const pillFont = overlayFont(700, 13, scale);
|
|
688
|
+
const pillPad = 10 * scale;
|
|
689
|
+
const label = ellipsize(ctx, sample.segmentName, pillFont, panelW / 2 - pillPad * 2);
|
|
690
|
+
drawChip(ctx, label, left, chipTop, scale, {
|
|
691
|
+
bg: overlayPalette.hairline,
|
|
692
|
+
fg: overlayPalette.primaryText,
|
|
693
|
+
fontPx: 13,
|
|
694
|
+
heightPx: BADGE_CHIP_HEIGHT_PX,
|
|
695
|
+
padPx: 10
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
const percentFont = overlayFont(700, 14, scale);
|
|
699
|
+
const percentText = formatProportion(covered, format);
|
|
700
|
+
drawText(ctx, percentText, rightEdge, baseline, {
|
|
701
|
+
align: "right",
|
|
702
|
+
color: overlayPalette.accent,
|
|
703
|
+
font: percentFont
|
|
704
|
+
});
|
|
705
|
+
if (sample.climbCategory !== null) drawChip(ctx, formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format), rightEdge - measureTextWidth(ctx, percentText, percentFont) - 14 * scale, chipTop, scale, climbBadgeSpec(sample.climbCategory), "right");
|
|
706
|
+
};
|
|
707
|
+
const drawLandscapeGrid = (grid) => {
|
|
708
|
+
const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
|
|
709
|
+
const slot2 = left + .34 * innerW;
|
|
710
|
+
const slot3 = left + .6 * innerW;
|
|
711
|
+
const labelRow1 = gridTop + 12 * scale;
|
|
712
|
+
const valueRow1 = gridTop + 44 * scale;
|
|
713
|
+
const labelRow2 = gridTop + 72 * scale;
|
|
714
|
+
const valueRow2 = gridTop + 98 * scale;
|
|
715
|
+
if (texts.elevation.length > 0) {
|
|
716
|
+
gridLabel(grid, labels.altitude, left, labelRow1);
|
|
717
|
+
gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
|
|
718
|
+
}
|
|
719
|
+
if (texts.slope.length > 0) {
|
|
720
|
+
gridLabel(grid, labels.gradient, slot2, labelRow1);
|
|
721
|
+
gradientChip(grid, slot2, valueRow1);
|
|
722
|
+
}
|
|
723
|
+
if (texts.speed.length > 0) {
|
|
724
|
+
gridLabel(grid, labels.speed, slot3, labelRow1);
|
|
725
|
+
gridValue(grid, texts.speed, slot3, valueRow1, "left");
|
|
726
|
+
}
|
|
727
|
+
if (texts.remaining.length > 0) {
|
|
728
|
+
gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
|
|
729
|
+
gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
|
|
730
|
+
}
|
|
731
|
+
if (texts.ascent.length > 0) {
|
|
732
|
+
gridLabel(grid, labels.dPlus, left, labelRow2);
|
|
733
|
+
dPlusValue(grid, left, valueRow2);
|
|
734
|
+
}
|
|
735
|
+
if (texts.distance.length > 0) {
|
|
736
|
+
gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
|
|
737
|
+
gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
|
|
738
|
+
}
|
|
739
|
+
if (texts.toSummit.length > 0) {
|
|
740
|
+
gridLabel(grid, labels.toSummit, slot2, labelRow2);
|
|
741
|
+
gridValue(grid, texts.toSummit, slot2, valueRow2, "left", 20);
|
|
742
|
+
} else if (texts.category) {
|
|
743
|
+
const captionFont = overlayFont(400, 15, scale);
|
|
744
|
+
const captionMax = rightEdge - (texts.distance.length > 0 ? measureTextWidth(ctx, texts.distance, overlayFont(700, 20, scale)) : 0) - 16 * scale - slot2;
|
|
745
|
+
drawText(ctx, ellipsize(ctx, texts.category, captionFont, captionMax), slot2, valueRow2, {
|
|
746
|
+
align: "left",
|
|
747
|
+
color: overlayPalette.secondaryText,
|
|
748
|
+
font: captionFont
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
const drawPortraitGrid = (grid) => {
|
|
753
|
+
const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
|
|
754
|
+
const slot2 = left + .42 * innerW;
|
|
755
|
+
const labelRow1 = gridTop + 12 * scale;
|
|
756
|
+
const valueRow1 = gridTop + 44 * scale;
|
|
757
|
+
const labelRow2 = gridTop + 72 * scale;
|
|
758
|
+
const valueRow2 = gridTop + 98 * scale;
|
|
759
|
+
const captionRow = gridTop + 126 * scale;
|
|
760
|
+
if (texts.elevation.length > 0) {
|
|
761
|
+
gridLabel(grid, labels.altitude, left, labelRow1);
|
|
762
|
+
gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
|
|
763
|
+
}
|
|
764
|
+
if (texts.slope.length > 0) {
|
|
765
|
+
gridLabel(grid, labels.gradient, slot2, labelRow1);
|
|
766
|
+
gradientChip(grid, slot2, valueRow1);
|
|
767
|
+
}
|
|
768
|
+
if (texts.remaining.length > 0) {
|
|
769
|
+
gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
|
|
770
|
+
gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
|
|
771
|
+
}
|
|
772
|
+
if (texts.ascent.length > 0) {
|
|
773
|
+
gridLabel(grid, labels.dPlus, left, labelRow2);
|
|
774
|
+
dPlusValue(grid, left, valueRow2);
|
|
775
|
+
}
|
|
776
|
+
if (texts.speed.length > 0) {
|
|
777
|
+
gridLabel(grid, labels.speed, slot2, labelRow2);
|
|
778
|
+
gridValue(grid, texts.speed, slot2, valueRow2, "left", 20);
|
|
779
|
+
}
|
|
780
|
+
if (texts.distance.length > 0) {
|
|
781
|
+
gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
|
|
782
|
+
gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
|
|
783
|
+
}
|
|
784
|
+
if (texts.toSummit.length > 0) {
|
|
785
|
+
gridLabel(grid, labels.toSummit, left, captionRow);
|
|
786
|
+
gridValue(grid, texts.toSummit, left + measureMicroLabel(ctx, labels.toSummit, scale) + 12 * scale, captionRow, "left", 16);
|
|
787
|
+
} else if (texts.category) {
|
|
788
|
+
const captionFont = overlayFont(400, 14, scale);
|
|
789
|
+
drawText(ctx, ellipsize(ctx, texts.category, captionFont, rightEdge - left), left, captionRow, {
|
|
790
|
+
align: "left",
|
|
791
|
+
color: overlayPalette.secondaryText,
|
|
792
|
+
font: captionFont
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
const graph = (ctx, sample, curve, dims, format) => {
|
|
797
|
+
const scale = overlayScale(dims.width, dims.height);
|
|
798
|
+
const portrait = dims.height > dims.width;
|
|
799
|
+
const square = dims.width === dims.height;
|
|
800
|
+
const covered = clamp01(alongFlight(sample, curve.totalKm));
|
|
801
|
+
const marginX = 28 * scale;
|
|
802
|
+
const marginBottom = (portrait ? 72 : square ? 40 : 28) * scale;
|
|
803
|
+
const panelW = dims.width - marginX * 2;
|
|
804
|
+
const panelH = (portrait ? 326 : 300) * scale;
|
|
805
|
+
const panelX = marginX;
|
|
806
|
+
const panelY = dims.height - marginBottom - panelH;
|
|
807
|
+
const radius = 20 * scale;
|
|
808
|
+
const pad = 24 * scale;
|
|
809
|
+
ctx.save();
|
|
810
|
+
fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
|
|
811
|
+
roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
|
|
812
|
+
ctx.lineWidth = Math.max(1, 1.5 * scale);
|
|
813
|
+
ctx.strokeStyle = overlayPalette.hairline;
|
|
814
|
+
ctx.stroke();
|
|
815
|
+
const left = panelX + pad;
|
|
816
|
+
const rightEdge = panelX + panelW - pad;
|
|
817
|
+
drawOverline(ctx, sample, curve, format, {
|
|
818
|
+
baseline: panelY + pad + 14 * scale,
|
|
819
|
+
covered,
|
|
820
|
+
left,
|
|
821
|
+
panelW,
|
|
822
|
+
rightEdge,
|
|
823
|
+
scale
|
|
824
|
+
});
|
|
825
|
+
const curveTop = panelY + pad + 26 * scale;
|
|
826
|
+
const curveH = 108 * scale;
|
|
827
|
+
const curveRect = {
|
|
828
|
+
h: curveH,
|
|
829
|
+
w: panelW - pad * 2,
|
|
830
|
+
x: panelX + pad,
|
|
831
|
+
y: curveTop
|
|
832
|
+
};
|
|
833
|
+
if (curve.points.length >= 2) drawCurve(ctx, covered, curve, curveRect, format, scale);
|
|
834
|
+
const grid = {
|
|
835
|
+
ctx,
|
|
836
|
+
gridTop: curveTop + curveH + 24 * scale,
|
|
837
|
+
innerW: panelW - pad * 2,
|
|
838
|
+
labels: videoOverlayStringsFor(format.language),
|
|
839
|
+
left,
|
|
840
|
+
rightEdge,
|
|
841
|
+
scale,
|
|
842
|
+
slopeDeg: sample.slopeDeg,
|
|
843
|
+
texts: graphReadouts(sample, curve, format)
|
|
844
|
+
};
|
|
845
|
+
if (portrait) drawPortraitGrid(grid);
|
|
846
|
+
else drawLandscapeGrid(grid);
|
|
847
|
+
ctx.restore();
|
|
848
|
+
};
|
|
849
|
+
const MINIMAL_PANEL_HEIGHT_PX = 56;
|
|
850
|
+
const minimal = (ctx, sample, curve, dims, format) => {
|
|
851
|
+
const scale = overlayScale(dims.width, dims.height);
|
|
852
|
+
const portrait = dims.height > dims.width;
|
|
853
|
+
const square = dims.width === dims.height;
|
|
854
|
+
const labels = videoOverlayStringsFor(format.language);
|
|
855
|
+
const marginX = 28 * scale;
|
|
856
|
+
const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
|
|
857
|
+
const panelH = MINIMAL_PANEL_HEIGHT_PX * scale;
|
|
858
|
+
const panelY = dims.height - marginBottom - panelH;
|
|
859
|
+
const pad = 16 * scale;
|
|
860
|
+
const gap = 12 * scale;
|
|
861
|
+
const remaining = curve.totalKm !== null ? formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * METERS_PER_KILOMETER, format) : "";
|
|
862
|
+
const valueText = remaining.length > 0 ? remaining : formatDistance(sample.distanceKm * METERS_PER_KILOMETER, format);
|
|
863
|
+
const valueLabel = remaining.length > 0 ? labels.toGo : labels.distance;
|
|
864
|
+
const valueFont = overlayFont(700, 24, scale);
|
|
865
|
+
const slopeText = formatSlope(sample.slopeDeg, format);
|
|
866
|
+
const badgeText = sample.climbCategory !== null ? formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format) : "";
|
|
867
|
+
const chipFont = overlayFont(700, 16, scale);
|
|
868
|
+
const chipWidth = slopeText.length > 0 ? measureTextWidth(ctx, slopeText, chipFont) + 20 * scale : 0;
|
|
869
|
+
const badgeFont = overlayFont(700, 12, scale);
|
|
870
|
+
const badgeWidth = badgeText.length > 0 ? measureTextWidth(ctx, badgeText, badgeFont) + 16 * scale : 0;
|
|
871
|
+
const valueWidth = measureTextWidth(ctx, valueText, valueFont);
|
|
872
|
+
const labelWidth = measureMicroLabel(ctx, valueLabel, scale);
|
|
873
|
+
let contentWidth = valueWidth + gap * .7 + labelWidth;
|
|
874
|
+
if (chipWidth > 0) contentWidth += chipWidth + gap;
|
|
875
|
+
if (badgeWidth > 0) contentWidth += badgeWidth + gap;
|
|
876
|
+
const panelW = contentWidth + pad * 2;
|
|
877
|
+
const panelX = marginX;
|
|
878
|
+
const radius = panelH / 2;
|
|
879
|
+
ctx.save();
|
|
880
|
+
fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
|
|
881
|
+
roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
|
|
882
|
+
ctx.lineWidth = Math.max(1, 1.5 * scale);
|
|
883
|
+
ctx.strokeStyle = overlayPalette.hairline;
|
|
884
|
+
ctx.stroke();
|
|
885
|
+
const baseline = panelY + panelH * .66;
|
|
886
|
+
let cursor = panelX + pad;
|
|
887
|
+
if (slopeText.length > 0) cursor += drawChip(ctx, slopeText, cursor, panelY + (panelH - 28 * scale) / 2, scale, {
|
|
888
|
+
bg: slopeBandColor(sample.slopeDeg),
|
|
889
|
+
fg: slopeBandTextColor(sample.slopeDeg),
|
|
890
|
+
fontPx: 16,
|
|
891
|
+
heightPx: 28,
|
|
892
|
+
padPx: 10
|
|
893
|
+
}) + gap;
|
|
894
|
+
drawText(ctx, valueText, cursor, baseline, {
|
|
895
|
+
align: "left",
|
|
896
|
+
color: overlayPalette.primaryText,
|
|
897
|
+
font: valueFont
|
|
898
|
+
});
|
|
899
|
+
cursor += valueWidth + gap * .7;
|
|
900
|
+
drawMicroLabel(ctx, valueLabel, cursor, baseline, scale, overlayPalette.labelText);
|
|
901
|
+
cursor += labelWidth + gap;
|
|
902
|
+
if (badgeText.length > 0) {
|
|
903
|
+
const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
|
|
904
|
+
drawChip(ctx, badgeText, cursor, panelY + (panelH - 20 * scale) / 2, scale, {
|
|
905
|
+
bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
|
|
906
|
+
fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
|
|
907
|
+
fontPx: 12,
|
|
908
|
+
heightPx: 20,
|
|
909
|
+
padPx: 8
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
ctx.restore();
|
|
913
|
+
};
|
|
914
|
+
const drawValueRow = (band) => {
|
|
915
|
+
const { bandY, ctx, format, innerW, labels, left, right, sample, scale } = band;
|
|
916
|
+
const labelRow = bandY + 26 * scale;
|
|
917
|
+
const valueRow = bandY + 56 * scale;
|
|
918
|
+
const valueFont = overlayFont(700, 22, scale);
|
|
919
|
+
const cell = (label, value, x, align) => {
|
|
920
|
+
if (value.length === 0) return;
|
|
921
|
+
drawMicroLabel(ctx, label, x, labelRow, scale, overlayPalette.labelText, align);
|
|
922
|
+
drawText(ctx, value, x, valueRow, {
|
|
923
|
+
align,
|
|
924
|
+
color: overlayPalette.primaryText,
|
|
925
|
+
font: valueFont
|
|
926
|
+
});
|
|
927
|
+
};
|
|
928
|
+
const ascentText = formatElevation(sample.ascentM, format);
|
|
929
|
+
cell(labels.distance, formatDistance(sample.distanceKm * METERS_PER_KILOMETER, format), left, "left");
|
|
930
|
+
cell(labels.dPlus, ascentText.length > 0 ? `+${ascentText}` : "", left + .22 * innerW, "left");
|
|
931
|
+
cell(labels.altitude, formatElevation(sample.elevation, format), left + .42 * innerW, "left");
|
|
932
|
+
const slopeText = formatSlope(sample.slopeDeg, format);
|
|
933
|
+
if (slopeText.length > 0) {
|
|
934
|
+
const slotSlope = left + .62 * innerW;
|
|
935
|
+
drawMicroLabel(ctx, labels.gradient, slotSlope, labelRow, scale, overlayPalette.labelText);
|
|
936
|
+
drawChip(ctx, slopeText, slotSlope, valueRow - 19 * scale, scale, {
|
|
937
|
+
bg: slopeBandColor(sample.slopeDeg),
|
|
938
|
+
fg: slopeBandTextColor(sample.slopeDeg),
|
|
939
|
+
fontPx: 16,
|
|
940
|
+
heightPx: 28,
|
|
941
|
+
padPx: 10
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
cell(labels.speed, formatSpeed(speedKilometersPerHour(sample.speed), format), right, "right");
|
|
945
|
+
};
|
|
946
|
+
const drawProgressBar = (band, covered) => {
|
|
947
|
+
const { bandY, ctx, curve, innerW, left, scale } = band;
|
|
948
|
+
const barY = bandY + 76 * scale;
|
|
949
|
+
const barH = 6 * scale;
|
|
950
|
+
const barW = innerW;
|
|
951
|
+
const fillWidth = barW * covered;
|
|
952
|
+
const bar = acquireBandBar(curve, barW, barH, overlayPalette);
|
|
953
|
+
if (bar) {
|
|
954
|
+
ctx.drawImage(bar.dim, left, barY);
|
|
955
|
+
if (fillWidth > 0) {
|
|
956
|
+
ctx.save();
|
|
957
|
+
ctx.beginPath();
|
|
958
|
+
ctx.rect(left, barY, fillWidth, barH);
|
|
959
|
+
ctx.clip();
|
|
960
|
+
ctx.drawImage(bar.bright, left, barY);
|
|
961
|
+
ctx.restore();
|
|
962
|
+
}
|
|
963
|
+
} else {
|
|
964
|
+
paintBandBar(ctx, curve, left, barY, barW, barH, BAND_BAR_DIM_ALPHA, overlayPalette);
|
|
965
|
+
if (fillWidth > 0) {
|
|
966
|
+
ctx.save();
|
|
967
|
+
ctx.beginPath();
|
|
968
|
+
ctx.rect(left, barY, fillWidth, barH);
|
|
969
|
+
ctx.clip();
|
|
970
|
+
paintBandBar(ctx, curve, left, barY, barW, barH, 1, overlayPalette);
|
|
971
|
+
ctx.restore();
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
const tickHeight = 12 * scale;
|
|
975
|
+
const tickWidth = 2 * scale;
|
|
976
|
+
const tickY = barY + barH / 2 - tickHeight / 2;
|
|
977
|
+
for (const tickX of [left, left + barW]) fillRoundedRect(ctx, tickX - tickWidth / 2, tickY, tickWidth, tickHeight, 0, overlayPalette.hairlineStrong);
|
|
978
|
+
const riderX = left + fillWidth;
|
|
979
|
+
const riderY = barY + barH / 2;
|
|
980
|
+
ctx.beginPath();
|
|
981
|
+
ctx.arc(riderX, riderY, Math.max(2, 9 * scale), 0, Math.PI * 2);
|
|
982
|
+
ctx.fillStyle = overlayPalette.accentHalo;
|
|
983
|
+
ctx.fill();
|
|
984
|
+
ctx.beginPath();
|
|
985
|
+
ctx.arc(riderX, riderY, Math.max(1.5, 5 * scale), 0, Math.PI * 2);
|
|
986
|
+
ctx.fillStyle = overlayPalette.accent;
|
|
987
|
+
ctx.fill();
|
|
988
|
+
ctx.lineWidth = Math.max(1, 1.5 * scale);
|
|
989
|
+
ctx.strokeStyle = overlayPalette.primaryText;
|
|
990
|
+
ctx.stroke();
|
|
991
|
+
};
|
|
992
|
+
const drawCaptionRow = (band, covered) => {
|
|
993
|
+
const { bandY, ctx, curve, format, labels, left, right, sample, scale } = band;
|
|
994
|
+
const captionRow = bandY + 114 * scale;
|
|
995
|
+
const captionFont = overlayFont(400, 14, scale);
|
|
996
|
+
const labelGap = 6 * scale;
|
|
997
|
+
if (sample.climbCategory !== null) {
|
|
998
|
+
const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
|
|
999
|
+
const badgeWidth = drawChip(ctx, formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format), left, captionRow - 15 * scale, scale, {
|
|
1000
|
+
bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
|
|
1001
|
+
fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
|
|
1002
|
+
fontPx: 12,
|
|
1003
|
+
heightPx: 20,
|
|
1004
|
+
padPx: 8
|
|
1005
|
+
});
|
|
1006
|
+
if (sample.climbEndKm !== null) {
|
|
1007
|
+
const labelX = left + badgeWidth + 10 * scale;
|
|
1008
|
+
drawMicroLabel(ctx, labels.toSummit, labelX, captionRow, scale, overlayPalette.labelText);
|
|
1009
|
+
drawText(ctx, formatDistance(Math.max(0, sample.climbEndKm - sample.distanceKm) * METERS_PER_KILOMETER, format), labelX + measureMicroLabel(ctx, labels.toSummit, scale) + labelGap, captionRow, {
|
|
1010
|
+
align: "left",
|
|
1011
|
+
color: overlayPalette.secondaryText,
|
|
1012
|
+
font: captionFont
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
} else {
|
|
1016
|
+
const categoryText = joinCategories(sample.surface, sample.waytype);
|
|
1017
|
+
if (categoryText) drawText(ctx, categoryText, left, captionRow, {
|
|
1018
|
+
align: "left",
|
|
1019
|
+
color: overlayPalette.secondaryText,
|
|
1020
|
+
font: captionFont
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
const accentFont = overlayFont(700, 14, scale);
|
|
1024
|
+
let cursor = right;
|
|
1025
|
+
if (curve.totalKm !== null) {
|
|
1026
|
+
const remainingText = formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * METERS_PER_KILOMETER, format);
|
|
1027
|
+
drawText(ctx, remainingText, cursor, captionRow, {
|
|
1028
|
+
align: "right",
|
|
1029
|
+
color: overlayPalette.primaryText,
|
|
1030
|
+
font: accentFont
|
|
1031
|
+
});
|
|
1032
|
+
cursor -= measureTextWidth(ctx, remainingText, accentFont) + labelGap;
|
|
1033
|
+
drawMicroLabel(ctx, labels.toGo, cursor, captionRow, scale, overlayPalette.labelText, "right");
|
|
1034
|
+
cursor -= measureMicroLabel(ctx, labels.toGo, scale);
|
|
1035
|
+
const middot = " · ";
|
|
1036
|
+
drawText(ctx, middot, cursor, captionRow, {
|
|
1037
|
+
align: "right",
|
|
1038
|
+
color: overlayPalette.secondaryText,
|
|
1039
|
+
font: accentFont
|
|
1040
|
+
});
|
|
1041
|
+
cursor -= measureTextWidth(ctx, middot, accentFont);
|
|
1042
|
+
}
|
|
1043
|
+
drawText(ctx, formatProportion(covered, format), cursor, captionRow, {
|
|
1044
|
+
align: "right",
|
|
1045
|
+
color: overlayPalette.accent,
|
|
1046
|
+
font: accentFont
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
const strip = (ctx, sample, curve, dims, format) => {
|
|
1050
|
+
const scale = overlayScale(dims.width, dims.height);
|
|
1051
|
+
const portrait = dims.height > dims.width;
|
|
1052
|
+
const square = dims.width === dims.height;
|
|
1053
|
+
const marginX = 24 * scale;
|
|
1054
|
+
const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
|
|
1055
|
+
const bandW = dims.width - marginX * 2;
|
|
1056
|
+
const bandH = 132 * scale;
|
|
1057
|
+
const bandX = marginX;
|
|
1058
|
+
const bandY = dims.height - marginBottom - bandH;
|
|
1059
|
+
const radius = 16 * scale;
|
|
1060
|
+
const pad = 22 * scale;
|
|
1061
|
+
const covered = clamp01(alongFlight(sample, curve.totalKm));
|
|
1062
|
+
ctx.save();
|
|
1063
|
+
fillRoundedRect(ctx, bandX, bandY, bandW, bandH, radius, overlayPalette.panel);
|
|
1064
|
+
const band = {
|
|
1065
|
+
bandY,
|
|
1066
|
+
ctx,
|
|
1067
|
+
curve,
|
|
1068
|
+
format,
|
|
1069
|
+
innerW: bandW - pad * 2,
|
|
1070
|
+
labels: videoOverlayStringsFor(format.language),
|
|
1071
|
+
left: bandX + pad,
|
|
1072
|
+
right: bandX + bandW - pad,
|
|
1073
|
+
sample,
|
|
1074
|
+
scale
|
|
1075
|
+
};
|
|
1076
|
+
drawValueRow(band);
|
|
1077
|
+
drawProgressBar(band, covered);
|
|
1078
|
+
drawCaptionRow(band, covered);
|
|
1079
|
+
roundedRectPath(ctx, bandX, bandY, bandW, bandH, radius);
|
|
1080
|
+
ctx.lineWidth = Math.max(1, 1.5 * scale);
|
|
1081
|
+
ctx.strokeStyle = overlayPalette.hairline;
|
|
1082
|
+
ctx.stroke();
|
|
1083
|
+
ctx.restore();
|
|
1084
|
+
};
|
|
1085
|
+
const profileOverlayDesigns = {
|
|
1086
|
+
graph,
|
|
1087
|
+
minimal,
|
|
1088
|
+
strip
|
|
1089
|
+
};
|
|
1090
|
+
const loadMediabunny = async () => {
|
|
1091
|
+
try {
|
|
1092
|
+
return await import("mediabunny");
|
|
1093
|
+
} catch (cause) {
|
|
1094
|
+
throw new MountayaElementsError("Recording needs the optional peer mediabunny, and it did not load. Install it if it is missing, or pass your own encoderFactory to the recorder. What the import threw is this error's cause.", { cause });
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
const codecFor = (format) => {
|
|
1098
|
+
switch (format) {
|
|
1099
|
+
case "webm-vp9": return "vp9";
|
|
1100
|
+
case "webm-vp8": return "vp8";
|
|
1101
|
+
default: return "avc";
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
const containerFor = async (format) => {
|
|
1105
|
+
const { Mp4OutputFormat, WebMOutputFormat } = await loadMediabunny();
|
|
1106
|
+
const extension = containerExtension(format);
|
|
1107
|
+
return {
|
|
1108
|
+
extension,
|
|
1109
|
+
format: extension === "webm" ? new WebMOutputFormat() : new Mp4OutputFormat()
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
const AVC_MACROBLOCK_PX = 16;
|
|
1113
|
+
const AVC_PROBE_FPS = Math.max(...CAMERA_FPS);
|
|
1114
|
+
const AVC_HIGH_LEVELS = [
|
|
1115
|
+
{
|
|
1116
|
+
codec: "avc1.64002a",
|
|
1117
|
+
macroblocksPerSecond: 522240
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
codec: "avc1.640033",
|
|
1121
|
+
macroblocksPerSecond: 983040
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
codec: "avc1.640034",
|
|
1125
|
+
macroblocksPerSecond: 2073600
|
|
1126
|
+
}
|
|
1387
1127
|
];
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
drawWidth,
|
|
1502
|
-
drawHeight
|
|
1503
|
-
);
|
|
1504
|
-
context.globalCompositeOperation = "source-in";
|
|
1505
|
-
context.fillStyle = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
|
|
1506
|
-
context.fillRect(0, 0, side, side);
|
|
1507
|
-
return canvas;
|
|
1508
|
-
} catch {
|
|
1509
|
-
return null;
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
var compositeWatermark = (context, watermark, frameWidth, frameHeight) => {
|
|
1513
|
-
if (!watermark) {
|
|
1514
|
-
return;
|
|
1515
|
-
}
|
|
1516
|
-
const inset = WATERMARK_INSET_PX * watermarkScale(frameWidth, frameHeight);
|
|
1517
|
-
context.drawImage(watermark, inset, inset);
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
|
-
// src/video/rules/videoRecorder.ts
|
|
1521
|
-
var cancelledResult = (extension) => ({
|
|
1522
|
-
blob: null,
|
|
1523
|
-
cancelled: true,
|
|
1524
|
-
extension
|
|
1128
|
+
const avcProbeCodec = (dimensions) => {
|
|
1129
|
+
const macroblocks = Math.ceil(dimensions.width / AVC_MACROBLOCK_PX) * Math.ceil(dimensions.height / AVC_MACROBLOCK_PX);
|
|
1130
|
+
return (AVC_HIGH_LEVELS.find(({ macroblocksPerSecond }) => macroblocks * AVC_PROBE_FPS <= macroblocksPerSecond) ?? AVC_HIGH_LEVELS.at(-1))?.codec ?? "avc1.640034";
|
|
1131
|
+
};
|
|
1132
|
+
const resolveHardwareAcceleration = async (format, dimensions) => {
|
|
1133
|
+
if (typeof VideoEncoder === "undefined" || codecFor(format) !== "avc") return "no-preference";
|
|
1134
|
+
try {
|
|
1135
|
+
return (await VideoEncoder.isConfigSupported({
|
|
1136
|
+
codec: avcProbeCodec(dimensions),
|
|
1137
|
+
hardwareAcceleration: "prefer-hardware",
|
|
1138
|
+
height: dimensions.height,
|
|
1139
|
+
width: dimensions.width
|
|
1140
|
+
})).supported === true ? "prefer-hardware" : "no-preference";
|
|
1141
|
+
} catch {
|
|
1142
|
+
return "no-preference";
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
const createVideoEncoder = async (canvas, dimensions, output) => {
|
|
1146
|
+
const { BufferTarget, CanvasSource, Output } = await loadMediabunny();
|
|
1147
|
+
const container = await containerFor(output.format);
|
|
1148
|
+
const target = new BufferTarget();
|
|
1149
|
+
const muxer = new Output({
|
|
1150
|
+
format: container.format,
|
|
1151
|
+
target
|
|
1152
|
+
});
|
|
1153
|
+
const hardwareAcceleration = await resolveHardwareAcceleration(output.format, dimensions);
|
|
1154
|
+
const source = new CanvasSource(canvas, {
|
|
1155
|
+
bitrate: resolveBitrateBps(output),
|
|
1156
|
+
bitrateMode: "variable",
|
|
1157
|
+
codec: codecFor(output.format),
|
|
1158
|
+
hardwareAcceleration,
|
|
1159
|
+
latencyMode: "quality"
|
|
1160
|
+
});
|
|
1161
|
+
muxer.addVideoTrack(source, { frameRate: output.fps });
|
|
1162
|
+
await muxer.start();
|
|
1163
|
+
return {
|
|
1164
|
+
addFrame: (timestampSeconds, durationSeconds) => source.add(timestampSeconds, durationSeconds),
|
|
1165
|
+
cancel: () => muxer.cancel(),
|
|
1166
|
+
extension: container.extension,
|
|
1167
|
+
finalize: async () => {
|
|
1168
|
+
await muxer.finalize();
|
|
1169
|
+
const buffer = target.buffer ?? /* @__PURE__ */ new ArrayBuffer(0);
|
|
1170
|
+
const mimeType = await muxer.getMimeType();
|
|
1171
|
+
return new Blob([buffer], { type: mimeType });
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
};
|
|
1175
|
+
const WATERMARK_URL = "data:image/svg+xml,%3Csvg fill='none' height='58' viewBox='0 0 138 58' width='138' xmlns='http://www.w3.org/2000/svg'%3E%3Cg filter='url(%23filter0_d_2_311)' opacity='0.9'%3E%3Cpath d='M22.6748 16.2338C26.3612 16.2338 29.3494 19.2222 29.3496 22.9086C29.3496 24.3563 28.9225 25.509 28.168 26.6127L22.6973 21.0385L17.2021 26.6361C16.4372 25.5235 16 24.3614 16 22.9086C16.0002 19.2223 18.9885 16.2339 22.6748 16.2338Z' fill='url(%23paint0_linear_2_311)'/%3E%3Cpath d='M22.7593 21.1075L28.1636 26.6134C26.9967 28.3197 25.0463 29.9084 22.6714 32.2833C22.5466 32.1585 22.4219 32.0368 22.2993 31.9161C21.9246 31.4137 21.522 30.5283 21.522 29.1368C21.5224 27.0753 23.9446 26.2887 23.9448 24.0782C23.9448 22.3917 23.1936 21.5524 22.7593 21.1075Z' fill='url(%23paint1_linear_2_311)'/%3E%3Cpath d='M49.5544 30H47.2489L46.2159 23.1734L43.0871 29.985H42.5331L39.4043 23.1734L38.3713 30H36.0658L37.7126 19.5205H39.9732L42.8176 25.9579L45.662 19.5205H47.9376L49.5544 30ZM54.8955 30.2395C52.3954 30.2395 50.5241 28.3981 50.5241 25.9579C50.5241 23.5177 52.3954 21.6913 54.8955 21.6913C57.3957 21.6913 59.267 23.5177 59.267 25.9579C59.267 28.3981 57.3957 30.2395 54.8955 30.2395ZM54.8955 28.1736C56.1531 28.1736 57.0513 27.2753 57.0513 25.9579C57.0513 24.6555 56.1531 23.7422 54.8955 23.7422C53.638 23.7422 52.7398 24.6555 52.7398 25.9579C52.7398 27.2753 53.638 28.1736 54.8955 28.1736ZM64.5265 30.2395C62.251 30.2395 60.7239 28.7724 60.7239 26.5867V21.9158H62.9097V26.3471C62.9097 27.4999 63.5235 28.1736 64.5265 28.1736C65.5445 28.1736 66.1433 27.4849 66.1433 26.3471V21.9158H68.3291V26.5867C68.3291 28.7724 66.817 30.2395 64.5265 30.2395ZM74.9134 21.7362C76.7547 21.7362 77.9075 23.0536 77.9075 25.1046V30H75.7218V25.4639C75.7218 24.2363 75.2577 23.6524 74.3145 23.6524C73.1917 23.6524 72.5031 24.4608 72.5031 25.7633V30H70.3174V21.9158H71.8144L72.2336 22.9189C72.8474 22.2003 73.8205 21.7362 74.9134 21.7362ZM83.8017 28.0538H84.7898V30H83.2329C81.4513 30 80.3585 28.9071 80.3585 27.1256V23.6824H78.9063V23.2033L82.0951 19.8199H82.5143V21.9158H84.7449V23.6824H82.5442V26.8262C82.5442 27.6047 82.9933 28.0538 83.8017 28.0538ZM92.7962 21.9158H94.428V30H92.7213L92.5267 29.2664C91.8381 29.8802 90.9398 30.2395 89.9069 30.2395C87.4816 30.2395 85.6702 28.3981 85.6702 25.9579C85.6702 23.5177 87.4816 21.6913 89.9069 21.6913C90.9548 21.6913 91.868 22.0655 92.5716 22.6793L92.7962 21.9158ZM90.0865 28.1736C91.359 28.1736 92.2872 27.2304 92.2872 25.9579C92.2872 24.6854 91.359 23.7422 90.0865 23.7422C88.814 23.7422 87.8858 24.6854 87.8858 25.9579C87.8858 27.2155 88.814 28.1736 90.0865 28.1736ZM102.129 21.9158H104.45L100.932 29.8952C99.9586 32.0959 99.1053 32.9193 97.2938 32.9193H96.3956V30.9581H97.1441C98.2071 30.9581 98.4765 30.6737 98.9706 29.4461L99.0005 29.3862L95.5722 21.9158H97.9526L100.108 26.9011L102.129 21.9158ZM111.802 21.9158H113.434V30H111.727L111.532 29.2664C110.844 29.8802 109.946 30.2395 108.913 30.2395C106.487 30.2395 104.676 28.3981 104.676 25.9579C104.676 23.5177 106.487 21.6913 108.913 21.6913C109.961 21.6913 110.874 22.0655 111.577 22.6793L111.802 21.9158ZM109.092 28.1736C110.365 28.1736 111.293 27.2304 111.293 25.9579C111.293 24.6854 110.365 23.7422 109.092 23.7422C107.82 23.7422 106.892 24.6854 106.892 25.9579C106.892 27.2155 107.82 28.1736 109.092 28.1736Z' fill='white'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter color-interpolation-filters='sRGB' filterUnits='userSpaceOnUse' height='66.6055' id='filter0_d_2_311' width='148.581' x='-8.2904' y='-8.2904'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' result='hardAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' /%3E%3CfeOffset/%3E%3CfeGaussianBlur stdDeviation='12.1452'/%3E%3CfeComposite in2='hardAlpha' operator='out'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/%3E%3CfeBlend in2='BackgroundImageFix' mode='normal' result='effect1_dropShadow_2_311'/%3E%3CfeBlend in='SourceGraphic' in2='effect1_dropShadow_2_311' mode='normal' result='shape'/%3E%3C/filter%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint0_linear_2_311' x1='23.7246' x2='22.8662' y1='40.8919' y2='18.575'%3E%3Cstop stop-color='%23090B0E'/%3E%3Cstop offset='1' stop-color='white'/%3E%3C/linearGradient%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint1_linear_2_311' x1='25.8586' x2='22.8826' y1='24.4393' y2='33.6651'%3E%3Cstop stop-color='white'/%3E%3Cstop offset='1' stop-color='%23DDDBDC' stop-opacity='0.6'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E";
|
|
1176
|
+
const WATERMARK_INTRINSIC_WIDTH = 138;
|
|
1177
|
+
const WATERMARK_INTRINSIC_HEIGHT = 58;
|
|
1178
|
+
const loadWatermarkCanvas = async (shortSidePx, url = WATERMARK_URL) => {
|
|
1179
|
+
try {
|
|
1180
|
+
const image = new Image();
|
|
1181
|
+
image.crossOrigin = "anonymous";
|
|
1182
|
+
await new Promise((resolve, reject) => {
|
|
1183
|
+
image.onload = () => resolve();
|
|
1184
|
+
image.onerror = () => reject(/* @__PURE__ */ new Error("watermark load failed"));
|
|
1185
|
+
image.src = url;
|
|
1186
|
+
});
|
|
1187
|
+
const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : WATERMARK_INTRINSIC_WIDTH;
|
|
1188
|
+
const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : WATERMARK_INTRINSIC_HEIGHT;
|
|
1189
|
+
const scale = 480 * watermarkScale(shortSidePx, shortSidePx) / intrinsicWidth;
|
|
1190
|
+
const width = Math.max(1, Math.round(intrinsicWidth * scale));
|
|
1191
|
+
const height = Math.max(1, Math.round(intrinsicHeight * scale));
|
|
1192
|
+
const canvas = document.createElement("canvas");
|
|
1193
|
+
canvas.width = width;
|
|
1194
|
+
canvas.height = height;
|
|
1195
|
+
const context = canvas.getContext("2d", { alpha: true });
|
|
1196
|
+
if (!context) return null;
|
|
1197
|
+
context.drawImage(image, 0, 0, width, height);
|
|
1198
|
+
return canvas;
|
|
1199
|
+
} catch {
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
const loadFocusGlyphCanvas = async (url, sizePx) => {
|
|
1204
|
+
try {
|
|
1205
|
+
const image = new Image();
|
|
1206
|
+
image.crossOrigin = "anonymous";
|
|
1207
|
+
await new Promise((resolve, reject) => {
|
|
1208
|
+
image.onload = () => resolve();
|
|
1209
|
+
image.onerror = () => reject(/* @__PURE__ */ new Error("focus glyph load failed"));
|
|
1210
|
+
image.src = url;
|
|
1211
|
+
});
|
|
1212
|
+
const side = Math.max(1, Math.round(sizePx));
|
|
1213
|
+
const canvas = document.createElement("canvas");
|
|
1214
|
+
canvas.width = side;
|
|
1215
|
+
canvas.height = side;
|
|
1216
|
+
const context = canvas.getContext("2d", { alpha: true });
|
|
1217
|
+
if (!context) return null;
|
|
1218
|
+
const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : side;
|
|
1219
|
+
const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : side;
|
|
1220
|
+
const scale = Math.min(side / intrinsicWidth, side / intrinsicHeight);
|
|
1221
|
+
const drawWidth = intrinsicWidth * scale;
|
|
1222
|
+
const drawHeight = intrinsicHeight * scale;
|
|
1223
|
+
context.drawImage(image, (side - drawWidth) / 2, (side - drawHeight) / 2, drawWidth, drawHeight);
|
|
1224
|
+
context.globalCompositeOperation = "source-in";
|
|
1225
|
+
context.fillStyle = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
|
|
1226
|
+
context.fillRect(0, 0, side, side);
|
|
1227
|
+
return canvas;
|
|
1228
|
+
} catch {
|
|
1229
|
+
return null;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
const compositeWatermark = (context, watermark, frameWidth, frameHeight) => {
|
|
1233
|
+
if (!watermark) return;
|
|
1234
|
+
const inset = 20 * watermarkScale(frameWidth, frameHeight);
|
|
1235
|
+
context.drawImage(watermark, inset, inset);
|
|
1236
|
+
};
|
|
1237
|
+
const cancelledResult = (extension) => ({
|
|
1238
|
+
blob: null,
|
|
1239
|
+
cancelled: true,
|
|
1240
|
+
extension
|
|
1525
1241
|
});
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1242
|
+
const cancelledRecording = (output) => cancelledResult(containerExtension(output.format));
|
|
1243
|
+
const unavailableResult = (extension) => ({
|
|
1244
|
+
blob: null,
|
|
1245
|
+
cancelled: true,
|
|
1246
|
+
extension,
|
|
1247
|
+
reason: "unavailable"
|
|
1532
1248
|
});
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1249
|
+
const failedResult = (extension, cause) => ({
|
|
1250
|
+
blob: null,
|
|
1251
|
+
cancelled: false,
|
|
1252
|
+
error: errorFrom(cause, "Recording failed."),
|
|
1253
|
+
extension
|
|
1538
1254
|
});
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
}
|
|
1631
|
-
compositeWatermark(context, watermarkCanvas, dimensions.width, dimensions.height);
|
|
1632
|
-
}
|
|
1633
|
-
};
|
|
1634
|
-
};
|
|
1635
|
-
var settleDelay = (ms, signal) => new Promise((resolve) => {
|
|
1636
|
-
if (signal.aborted || ms <= 0) {
|
|
1637
|
-
resolve();
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
|
-
const onAbort = () => {
|
|
1641
|
-
clearTimeout(timeout);
|
|
1642
|
-
resolve();
|
|
1643
|
-
};
|
|
1644
|
-
const timeout = setTimeout(() => {
|
|
1645
|
-
signal.removeEventListener("abort", onAbort);
|
|
1646
|
-
resolve();
|
|
1647
|
-
}, ms);
|
|
1648
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
1255
|
+
const discardPartial = async (encoder) => {
|
|
1256
|
+
try {
|
|
1257
|
+
await encoder?.cancel();
|
|
1258
|
+
} catch {}
|
|
1259
|
+
};
|
|
1260
|
+
const assertPixelCount = (member, pixels) => {
|
|
1261
|
+
if (!Number.isInteger(pixels) || pixels < 1) throw new MountayaElementsError(`createCanvasSurface: ${member} is ${String(pixels)}; pass a whole number of pixels, 1 or more.`);
|
|
1262
|
+
};
|
|
1263
|
+
const createCanvasSurface = async (options) => {
|
|
1264
|
+
const { captureSize, dimensions, focusGlyphUrl, fps, profile, watermark = true } = options;
|
|
1265
|
+
assertPixelCount("dimensions.width", dimensions.width);
|
|
1266
|
+
assertPixelCount("dimensions.height", dimensions.height);
|
|
1267
|
+
assertPixelCount("captureSize.width", captureSize.width);
|
|
1268
|
+
assertPixelCount("captureSize.height", captureSize.height);
|
|
1269
|
+
if (fps !== void 0 && (!Number.isFinite(fps) || fps <= 0)) throw new MountayaElementsError(`createCanvasSurface: fps is ${String(fps)}; pass a number of frames per second above 0, or omit it for a halo that holds still.`);
|
|
1270
|
+
const canvas = document.createElement("canvas");
|
|
1271
|
+
canvas.width = dimensions.width;
|
|
1272
|
+
canvas.height = dimensions.height;
|
|
1273
|
+
const context = canvas.getContext("2d", { alpha: true });
|
|
1274
|
+
if (!context) return null;
|
|
1275
|
+
context.fillStyle = "#000000";
|
|
1276
|
+
context.fillRect(0, 0, dimensions.width, dimensions.height);
|
|
1277
|
+
const blit = document.createElement("canvas");
|
|
1278
|
+
blit.width = captureSize.width;
|
|
1279
|
+
blit.height = captureSize.height;
|
|
1280
|
+
const blitContext = blit.getContext("2d", { alpha: true });
|
|
1281
|
+
if (!blitContext) return null;
|
|
1282
|
+
const frameImage = blitContext.createImageData(captureSize.width, captureSize.height);
|
|
1283
|
+
const watermarkCanvas = watermark ? await loadWatermarkCanvas(Math.min(dimensions.width, dimensions.height), WATERMARK_URL) : null;
|
|
1284
|
+
const profileRenderer = profile ? profileOverlayDesigns[profile.design] : null;
|
|
1285
|
+
const profileCurve = profile ? buildProfileCurve(profile.samples) : null;
|
|
1286
|
+
if (profile) await ensureOverlayFonts();
|
|
1287
|
+
const scaleX = dimensions.width / captureSize.width;
|
|
1288
|
+
const scaleY = dimensions.height / captureSize.height;
|
|
1289
|
+
const dotScale = watermarkScale(dimensions.width, dimensions.height);
|
|
1290
|
+
const dotRadius = 15 * dotScale;
|
|
1291
|
+
const dotStrokeWidth = 2 * dotScale;
|
|
1292
|
+
const haloMaxRadius = 34 * dotScale;
|
|
1293
|
+
const focusGlyphSize = Math.max(1, Math.round(dotRadius * 2 * VIDEO_FOCUS_MARKER_GLYPH_RATIO));
|
|
1294
|
+
const focusGlyph = focusGlyphUrl ? await loadFocusGlyphCanvas(focusGlyphUrl, focusGlyphSize) : null;
|
|
1295
|
+
const frameMs = fps === void 0 ? 0 : MILLISECONDS_PER_SECOND / fps;
|
|
1296
|
+
return {
|
|
1297
|
+
canvas,
|
|
1298
|
+
paintFrame: (pixels, marker, index) => {
|
|
1299
|
+
frameImage.data.set(pixels);
|
|
1300
|
+
blitContext.putImageData(frameImage, 0, 0);
|
|
1301
|
+
context.drawImage(blit, 0, 0, dimensions.width, dimensions.height);
|
|
1302
|
+
if (marker) {
|
|
1303
|
+
const x = marker.x * scaleX;
|
|
1304
|
+
const y = marker.y * scaleY;
|
|
1305
|
+
const phase = index * frameMs % VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS / VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS;
|
|
1306
|
+
const haloRadius = dotRadius + (haloMaxRadius - dotRadius) * phase;
|
|
1307
|
+
const haloAlpha = VIDEO_FOCUS_MARKER_HALO_OPACITY * (1 - phase);
|
|
1308
|
+
context.save();
|
|
1309
|
+
context.globalAlpha = haloAlpha;
|
|
1310
|
+
context.beginPath();
|
|
1311
|
+
context.arc(x, y, haloRadius, 0, Math.PI * 2);
|
|
1312
|
+
context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
|
|
1313
|
+
context.fill();
|
|
1314
|
+
context.restore();
|
|
1315
|
+
context.beginPath();
|
|
1316
|
+
context.arc(x, y, dotRadius, 0, Math.PI * 2);
|
|
1317
|
+
context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
|
|
1318
|
+
context.fill();
|
|
1319
|
+
context.lineWidth = dotStrokeWidth;
|
|
1320
|
+
context.strokeStyle = VIDEO_FOCUS_MARKER_STROKE;
|
|
1321
|
+
context.stroke();
|
|
1322
|
+
if (focusGlyph) context.drawImage(focusGlyph, x - focusGlyph.width / 2, y - focusGlyph.height / 2);
|
|
1323
|
+
}
|
|
1324
|
+
if (profile && profileRenderer && profileCurve) {
|
|
1325
|
+
const sample = profile.samples[index];
|
|
1326
|
+
if (sample) profileRenderer(context, sample, profileCurve, dimensions, profile.format);
|
|
1327
|
+
}
|
|
1328
|
+
compositeWatermark(context, watermarkCanvas, dimensions.width, dimensions.height);
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
};
|
|
1332
|
+
const settleDelay = (ms, signal) => new Promise((resolve) => {
|
|
1333
|
+
if (signal.aborted || ms <= 0) {
|
|
1334
|
+
resolve();
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
const onAbort = () => {
|
|
1338
|
+
clearTimeout(timeout);
|
|
1339
|
+
resolve();
|
|
1340
|
+
};
|
|
1341
|
+
const timeout = setTimeout(() => {
|
|
1342
|
+
signal.removeEventListener("abort", onAbort);
|
|
1343
|
+
resolve();
|
|
1344
|
+
}, ms);
|
|
1345
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1649
1346
|
});
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
};
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
glyph.style.position = "absolute";
|
|
1809
|
-
glyph.style.top = "50%";
|
|
1810
|
-
glyph.style.width = `${glyphSize}px`;
|
|
1811
|
-
const maskUrl = `url("${glyphUrl}")`;
|
|
1812
|
-
glyph.style.maskImage = maskUrl;
|
|
1813
|
-
glyph.style.webkitMaskImage = maskUrl;
|
|
1814
|
-
glyph.style.maskRepeat = "no-repeat";
|
|
1815
|
-
glyph.style.webkitMaskRepeat = "no-repeat";
|
|
1816
|
-
glyph.style.maskPosition = "center";
|
|
1817
|
-
glyph.style.webkitMaskPosition = "center";
|
|
1818
|
-
glyph.style.maskSize = "contain";
|
|
1819
|
-
glyph.style.webkitMaskSize = "contain";
|
|
1820
|
-
container.append(glyph);
|
|
1821
|
-
}
|
|
1822
|
-
return container;
|
|
1347
|
+
const captureSettledFrame = async (map, capture, pixels, width, height, signal) => {
|
|
1348
|
+
await map.waitForFrame(signal);
|
|
1349
|
+
capture.capture(pixels, width, height);
|
|
1350
|
+
let isBlack = isBufferAllBlack(pixels);
|
|
1351
|
+
for (let retry = 0; isBlack && retry < 2 && !signal.aborted; retry += 1) {
|
|
1352
|
+
await settleDelay(400, signal);
|
|
1353
|
+
await map.waitForFrame(signal);
|
|
1354
|
+
capture.capture(pixels, width, height);
|
|
1355
|
+
isBlack = isBufferAllBlack(pixels);
|
|
1356
|
+
}
|
|
1357
|
+
return isBlack;
|
|
1358
|
+
};
|
|
1359
|
+
const recordPoses = async (args) => {
|
|
1360
|
+
const { map, markers, onProgress, output, poses, profile, seams, signal } = args;
|
|
1361
|
+
const extension = containerExtension(output.format);
|
|
1362
|
+
let encoder = null;
|
|
1363
|
+
let clockFrozen = false;
|
|
1364
|
+
try {
|
|
1365
|
+
const dimensions = resolveDimensions(output);
|
|
1366
|
+
if (signal.aborted) return cancelledResult(extension);
|
|
1367
|
+
if (poses.length === 0) return unavailableResult(extension);
|
|
1368
|
+
if (!map.isDrawingBufferPreserved()) return unavailableResult(extension);
|
|
1369
|
+
const captureSize = map.captureCanvasSize();
|
|
1370
|
+
if (captureSize.width < 100 || captureSize.height < 100) return unavailableResult(extension);
|
|
1371
|
+
onProgress?.({
|
|
1372
|
+
fraction: 0,
|
|
1373
|
+
phase: "preparing"
|
|
1374
|
+
});
|
|
1375
|
+
const watermark = await args.organization().then((organization) => organization.white_label !== true, () => true);
|
|
1376
|
+
const surface = await (seams.createSurface ?? createCanvasSurface)({
|
|
1377
|
+
captureSize,
|
|
1378
|
+
dimensions,
|
|
1379
|
+
focusGlyphUrl: args.focusGlyphUrl,
|
|
1380
|
+
fps: output.fps,
|
|
1381
|
+
profile,
|
|
1382
|
+
watermark
|
|
1383
|
+
});
|
|
1384
|
+
if (!surface) return unavailableResult(extension);
|
|
1385
|
+
const capture = seams.createCapture();
|
|
1386
|
+
const pixels = new Uint8Array(captureSize.width * captureSize.height * 4);
|
|
1387
|
+
encoder = await (seams.encoderFactory ?? createVideoEncoder)(surface.canvas, dimensions, output);
|
|
1388
|
+
map.freezeClock(0);
|
|
1389
|
+
clockFrozen = true;
|
|
1390
|
+
const frameDurationSeconds = 1 / output.fps;
|
|
1391
|
+
const frameDurationMs = MILLISECONDS_PER_SECOND / output.fps;
|
|
1392
|
+
for (let index = 0; index < poses.length; index += 1) {
|
|
1393
|
+
if (signal.aborted) {
|
|
1394
|
+
await discardPartial(encoder);
|
|
1395
|
+
return cancelledResult(extension);
|
|
1396
|
+
}
|
|
1397
|
+
const pose = poses[index];
|
|
1398
|
+
if (!pose) continue;
|
|
1399
|
+
map.freezeClock(index * frameDurationMs);
|
|
1400
|
+
map.jumpTo(pose);
|
|
1401
|
+
const markerLngLat = markers?.[index];
|
|
1402
|
+
let marker = null;
|
|
1403
|
+
if (markerLngLat) {
|
|
1404
|
+
const [x, y] = map.project(markerLngLat);
|
|
1405
|
+
marker = {
|
|
1406
|
+
x,
|
|
1407
|
+
y
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
const isBlack = await captureSettledFrame(map, capture, pixels, captureSize.width, captureSize.height, signal);
|
|
1411
|
+
if (index === 0 && isBlack) {
|
|
1412
|
+
await discardPartial(encoder);
|
|
1413
|
+
return unavailableResult(extension);
|
|
1414
|
+
}
|
|
1415
|
+
surface.paintFrame(pixels, marker, index);
|
|
1416
|
+
await encoder.addFrame(index * frameDurationSeconds, frameDurationSeconds);
|
|
1417
|
+
onProgress?.({
|
|
1418
|
+
fraction: (index + 1) / poses.length,
|
|
1419
|
+
phase: "recording"
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
onProgress?.({
|
|
1423
|
+
fraction: 1,
|
|
1424
|
+
phase: "encoding"
|
|
1425
|
+
});
|
|
1426
|
+
return {
|
|
1427
|
+
blob: await encoder.finalize(),
|
|
1428
|
+
cancelled: false,
|
|
1429
|
+
extension: encoder.extension
|
|
1430
|
+
};
|
|
1431
|
+
} catch (cause) {
|
|
1432
|
+
await discardPartial(encoder);
|
|
1433
|
+
return failedResult(encoder?.extension ?? extension, cause);
|
|
1434
|
+
} finally {
|
|
1435
|
+
if (clockFrozen) map.restoreClock();
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
const buildVideoFocusMarkerElement = (glyphUrl) => {
|
|
1439
|
+
const dotDiameter = 30;
|
|
1440
|
+
const haloDiameter = 68;
|
|
1441
|
+
const container = document.createElement("div");
|
|
1442
|
+
container.setAttribute("data-mountaya-video-focus-marker", "");
|
|
1443
|
+
container.setAttribute("aria-hidden", "true");
|
|
1444
|
+
container.style.alignItems = "center";
|
|
1445
|
+
container.style.display = "flex";
|
|
1446
|
+
container.style.height = `${dotDiameter}px`;
|
|
1447
|
+
container.style.justifyContent = "center";
|
|
1448
|
+
container.style.pointerEvents = "none";
|
|
1449
|
+
container.style.position = "relative";
|
|
1450
|
+
container.style.width = `${dotDiameter}px`;
|
|
1451
|
+
const halo = document.createElement("div");
|
|
1452
|
+
halo.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
|
|
1453
|
+
halo.style.borderRadius = "50%";
|
|
1454
|
+
halo.style.height = `${haloDiameter}px`;
|
|
1455
|
+
halo.style.left = "50%";
|
|
1456
|
+
halo.style.marginLeft = `-34px`;
|
|
1457
|
+
halo.style.marginTop = `-34px`;
|
|
1458
|
+
halo.style.position = "absolute";
|
|
1459
|
+
halo.style.top = "50%";
|
|
1460
|
+
halo.style.width = `${haloDiameter}px`;
|
|
1461
|
+
const startScale = 15 / 34;
|
|
1462
|
+
if (typeof halo.animate === "function") halo.animate([{
|
|
1463
|
+
opacity: VIDEO_FOCUS_MARKER_HALO_OPACITY,
|
|
1464
|
+
transform: `scale(${startScale})`
|
|
1465
|
+
}, {
|
|
1466
|
+
opacity: 0,
|
|
1467
|
+
transform: "scale(1)"
|
|
1468
|
+
}], {
|
|
1469
|
+
duration: VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS,
|
|
1470
|
+
easing: "ease-out",
|
|
1471
|
+
iterations: Number.POSITIVE_INFINITY
|
|
1472
|
+
});
|
|
1473
|
+
const dot = document.createElement("div");
|
|
1474
|
+
dot.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
|
|
1475
|
+
dot.style.border = `2px solid ${VIDEO_FOCUS_MARKER_STROKE}`;
|
|
1476
|
+
dot.style.borderRadius = "50%";
|
|
1477
|
+
dot.style.boxSizing = "content-box";
|
|
1478
|
+
dot.style.height = `${dotDiameter}px`;
|
|
1479
|
+
dot.style.position = "relative";
|
|
1480
|
+
dot.style.width = `${dotDiameter}px`;
|
|
1481
|
+
container.append(halo, dot);
|
|
1482
|
+
if (glyphUrl) {
|
|
1483
|
+
const glyphSize = dotDiameter * VIDEO_FOCUS_MARKER_GLYPH_RATIO;
|
|
1484
|
+
const glyph = document.createElement("div");
|
|
1485
|
+
glyph.style.backgroundColor = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
|
|
1486
|
+
glyph.style.height = `${glyphSize}px`;
|
|
1487
|
+
glyph.style.left = "50%";
|
|
1488
|
+
glyph.style.marginLeft = `${-18.6 / 2}px`;
|
|
1489
|
+
glyph.style.marginTop = `${-18.6 / 2}px`;
|
|
1490
|
+
glyph.style.position = "absolute";
|
|
1491
|
+
glyph.style.top = "50%";
|
|
1492
|
+
glyph.style.width = `${glyphSize}px`;
|
|
1493
|
+
const maskUrl = `url("${glyphUrl}")`;
|
|
1494
|
+
glyph.style.maskImage = maskUrl;
|
|
1495
|
+
glyph.style.webkitMaskImage = maskUrl;
|
|
1496
|
+
glyph.style.maskRepeat = "no-repeat";
|
|
1497
|
+
glyph.style.webkitMaskRepeat = "no-repeat";
|
|
1498
|
+
glyph.style.maskPosition = "center";
|
|
1499
|
+
glyph.style.webkitMaskPosition = "center";
|
|
1500
|
+
glyph.style.maskSize = "contain";
|
|
1501
|
+
glyph.style.webkitMaskSize = "contain";
|
|
1502
|
+
container.append(glyph);
|
|
1503
|
+
}
|
|
1504
|
+
return container;
|
|
1823
1505
|
};
|
|
1824
1506
|
var VideoRunEngine = class {
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
* caller's cancel and the internal teardown). The run's controller signal is the
|
|
2007
|
-
* one the pipeline honors.
|
|
2008
|
-
*
|
|
2009
|
-
* The pose to restore is the camera the user left, which is not always the camera
|
|
2010
|
-
* now. A run that supersedes one still in flight finds the camera on a pose of that
|
|
2011
|
-
* flight, and the superseded run hands its restore over rather than performing it,
|
|
2012
|
-
* so the new run inherits the pose the superseded one took. Snapshotting the camera
|
|
2013
|
-
* here instead would park the map on a frame of a flight nobody is watching once
|
|
2014
|
-
* the new run settles.
|
|
2015
|
-
*
|
|
2016
|
-
* The listener on the caller's signal leaves with the run ({@link endVideoRun}
|
|
2017
|
-
* releases it). A caller that keeps one signal for a whole session would otherwise
|
|
2018
|
-
* hold a closure per run it ever started, each keeping its controller alive.
|
|
2019
|
-
*/
|
|
2020
|
-
beginVideoRun(signal) {
|
|
2021
|
-
const superseded = this.videoRun;
|
|
2022
|
-
superseded?.controller.abort();
|
|
2023
|
-
const controller = new AbortController();
|
|
2024
|
-
const abort = () => {
|
|
2025
|
-
controller.abort();
|
|
2026
|
-
};
|
|
2027
|
-
if (signal.aborted) {
|
|
2028
|
-
controller.abort();
|
|
2029
|
-
} else {
|
|
2030
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
2031
|
-
}
|
|
2032
|
-
const run = {
|
|
2033
|
-
controller,
|
|
2034
|
-
release: () => {
|
|
2035
|
-
signal.removeEventListener("abort", abort);
|
|
2036
|
-
},
|
|
2037
|
-
restorePose: superseded?.restorePose ?? this.getCameraPose()
|
|
2038
|
-
};
|
|
2039
|
-
this.videoRun = run;
|
|
2040
|
-
return run;
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* endVideoRun closes a video run started by beginVideoRun: it releases the run's
|
|
2044
|
-
* listener on the caller's signal whatever else happens, then restores the pre-run
|
|
2045
|
-
* camera and clears the session field, but only when the field still points at
|
|
2046
|
-
* this run. A superseding run already took the field and the pose to restore, so a
|
|
2047
|
-
* late teardown must not clobber it. Restoring through jumpTo lands the camera
|
|
2048
|
-
* exactly where the run began. Idempotent: dispose and the run's own settle may
|
|
2049
|
-
* both reach it.
|
|
2050
|
-
*/
|
|
2051
|
-
endVideoRun(run) {
|
|
2052
|
-
run.release();
|
|
2053
|
-
if (this.videoRun !== run) {
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
this.map.jumpTo({
|
|
2057
|
-
bearing: run.restorePose.bearing,
|
|
2058
|
-
center: run.restorePose.center,
|
|
2059
|
-
pitch: run.restorePose.pitch,
|
|
2060
|
-
zoom: run.restorePose.zoom
|
|
2061
|
-
});
|
|
2062
|
-
this.videoRun = null;
|
|
2063
|
-
}
|
|
2064
|
-
/**
|
|
2065
|
-
* buildRecordingMap adapts this MapLibre map to the RecordingMap the recorder
|
|
2066
|
-
* drives: the clock freeze/restore map onto maplibre's setNow/restoreNow, the
|
|
2067
|
-
* camera jump onto jumpTo, the canvas size onto the drawing buffer dimensions,
|
|
2068
|
-
* the preserve-buffer probe onto the WebGL context attribute, the coordinate→pixel
|
|
2069
|
-
* projection (so the recorder can composite the focus dot onto each frame after
|
|
2070
|
-
* the jump), and the per-frame wait onto waitForRecorderFrame. Built per record
|
|
2071
|
-
* call so it always reads the live map. There is no setMarker: the recorder draws
|
|
2072
|
-
* the dot into each output frame itself (a DOM marker is outside gl.readPixels), so
|
|
2073
|
-
* the map is never asked to place one during a record.
|
|
2074
|
-
*/
|
|
2075
|
-
buildRecordingMap() {
|
|
2076
|
-
return {
|
|
2077
|
-
captureCanvasSize: () => {
|
|
2078
|
-
const canvas = this.map.getCanvas();
|
|
2079
|
-
return { height: canvas.height, width: canvas.width };
|
|
2080
|
-
},
|
|
2081
|
-
freezeClock: (timeMs) => setNow(timeMs),
|
|
2082
|
-
isDrawingBufferPreserved: () => {
|
|
2083
|
-
const context = this.map.getCanvas().getContext("webgl2") ?? this.map.getCanvas().getContext("webgl");
|
|
2084
|
-
return context?.getContextAttributes()?.preserveDrawingBuffer === true;
|
|
2085
|
-
},
|
|
2086
|
-
jumpTo: (pose) => this.map.jumpTo(pose),
|
|
2087
|
-
project: (lngLat) => this.projectToCaptureBuffer(lngLat),
|
|
2088
|
-
restoreClock: () => restoreNow(),
|
|
2089
|
-
waitForFrame: (signal) => this.waitForRecorderFrame(signal)
|
|
2090
|
-
};
|
|
2091
|
-
}
|
|
2092
|
-
/**
|
|
2093
|
-
* projectToCaptureBuffer projects a [lng, lat] to its pixel in the WebGL CAPTURE
|
|
2094
|
-
* buffer's coordinate space (canvas.width/height, the device-pixel back buffer the
|
|
2095
|
-
* recorder reads), so the recorder can scale it onto the output frame the same way
|
|
2096
|
-
* it scales the captured pixels (captureSize → output dimensions). map.project
|
|
2097
|
-
* returns CSS container pixels, so the result is multiplied by the buffer/CSS ratio
|
|
2098
|
-
* (the device-pixel ratio the renderer drew at) on each axis. The recorder needs
|
|
2099
|
-
* capture-space pixels because the dot is a 2D-canvas composite, not a map marker:
|
|
2100
|
-
* there is no DOM marker in the frame the recorder reads.
|
|
2101
|
-
*/
|
|
2102
|
-
projectToCaptureBuffer(lngLat) {
|
|
2103
|
-
const point = this.map.project(lngLat);
|
|
2104
|
-
const canvas = this.map.getCanvas();
|
|
2105
|
-
const scaleX = canvas.clientWidth > 0 ? canvas.width / canvas.clientWidth : 1;
|
|
2106
|
-
const scaleY = canvas.clientHeight > 0 ? canvas.height / canvas.clientHeight : 1;
|
|
2107
|
-
return [point.x * scaleX, point.y * scaleY];
|
|
2108
|
-
}
|
|
2109
|
-
/**
|
|
2110
|
-
* waitForRecorderFrame triggers a repaint and resolves once the renderer has
|
|
2111
|
-
* reached tile-idle (every requested tile for this frame's viewport painted), so
|
|
2112
|
-
* the back buffer holds a complete frame before the recorder reads it, not a
|
|
2113
|
-
* partial frame with empty/black tiles still in flight. It is the per-frame
|
|
2114
|
-
* counterpart to waitForRender's idle gate: it resolves immediately when the map
|
|
2115
|
-
* already reports loaded() (the warm-tile fast path, and most frames take it, since the
|
|
2116
|
-
* pre-flight warm pass loaded the flight-zoom tiles and the enlarged cache keeps
|
|
2117
|
-
* them resident), else on the next "idle", else after PER_FRAME_IDLE_TIMEOUT_MS
|
|
2118
|
-
* so a stalled tile fetch cannot hang the run (a frame with a few late tiles
|
|
2119
|
-
* beats no recording). It resolves immediately if the signal is already aborted, and
|
|
2120
|
-
* at once on an abort made while it waits.
|
|
2121
|
-
* The idle listener is registered through the event engine (so dispose sweeps
|
|
2122
|
-
* it) and self-detaches on the first of idle/timeout; the wait never rejects.
|
|
2123
|
-
*/
|
|
2124
|
-
waitForRecorderFrame(signal) {
|
|
2125
|
-
return new Promise((resolve) => {
|
|
2126
|
-
if (signal.aborted) {
|
|
2127
|
-
resolve();
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2130
|
-
this.map.triggerRepaint();
|
|
2131
|
-
if (this.map.loaded()) {
|
|
2132
|
-
resolve();
|
|
2133
|
-
return;
|
|
2134
|
-
}
|
|
2135
|
-
let settled = false;
|
|
2136
|
-
let detach = () => {
|
|
2137
|
-
};
|
|
2138
|
-
const finish = () => {
|
|
2139
|
-
if (settled) {
|
|
2140
|
-
return;
|
|
2141
|
-
}
|
|
2142
|
-
settled = true;
|
|
2143
|
-
clearTimeout(timeout);
|
|
2144
|
-
detach();
|
|
2145
|
-
signal.removeEventListener("abort", finish);
|
|
2146
|
-
resolve();
|
|
2147
|
-
};
|
|
2148
|
-
const timeout = setTimeout(finish, PER_FRAME_IDLE_TIMEOUT_MS);
|
|
2149
|
-
signal.addEventListener("abort", finish, { once: true });
|
|
2150
|
-
detach = this.events.on("idle", finish);
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* warmPosesForRecording jumps the camera through a STRIDED subset of the flight
|
|
2155
|
-
* poses before the capture loop, awaiting tile readiness at each stop, so the
|
|
2156
|
-
* flight-zoom basemap, itinerary-vector, and DEM tiles every frame will need are
|
|
2157
|
-
* loaded (and, with the enlarged map tile cache, resident) before the first
|
|
2158
|
-
* capture. It is the run engine's twin of MapLibreClient.warmPoses, working
|
|
2159
|
-
* over the live map the run owns: it strides the poses (every Nth, capped so a
|
|
2160
|
-
* long route warms at most PREFLIGHT_WARM_MAX_STOPS viewports) and waits for the
|
|
2161
|
-
* renderer to settle at each stop, bounded per stop so a stalled tile fetch
|
|
2162
|
-
* cannot hang the warm pass. It honors `signal`: an abort stops the pass at the
|
|
2163
|
-
* next stop and resolves. Best-effort: it never rejects, so a warm that cannot
|
|
2164
|
-
* complete still lets the capture loop run.
|
|
2165
|
-
*/
|
|
2166
|
-
async warmPosesForRecording(poses, signal) {
|
|
2167
|
-
return warmPosesThrough(this.map, this.events, poses, signal);
|
|
2168
|
-
}
|
|
2169
|
-
};
|
|
1507
|
+
map;
|
|
1508
|
+
events;
|
|
1509
|
+
organization;
|
|
1510
|
+
videoRun = null;
|
|
1511
|
+
videoFocusMarker = null;
|
|
1512
|
+
focusGlyphUrl = null;
|
|
1513
|
+
disposed = false;
|
|
1514
|
+
constructor(map, events, organization) {
|
|
1515
|
+
this.map = map;
|
|
1516
|
+
this.events = events;
|
|
1517
|
+
this.organization = organization;
|
|
1518
|
+
}
|
|
1519
|
+
getCameraPose() {
|
|
1520
|
+
const center = this.map.getCenter();
|
|
1521
|
+
return {
|
|
1522
|
+
bearing: this.map.getBearing(),
|
|
1523
|
+
center: [center.lng, center.lat],
|
|
1524
|
+
pitch: this.map.getPitch(),
|
|
1525
|
+
zoom: this.map.getZoom()
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
async previewPoses(poses, options) {
|
|
1529
|
+
if (this.disposed) return;
|
|
1530
|
+
this.focusGlyphUrl = options.focusGlyphUrl ?? null;
|
|
1531
|
+
const run = this.beginVideoRun(options.signal);
|
|
1532
|
+
try {
|
|
1533
|
+
await previewPoses({
|
|
1534
|
+
map: {
|
|
1535
|
+
jumpTo: (pose) => this.map.jumpTo(pose),
|
|
1536
|
+
setMarker: (lngLat) => this.setVideoFocusMarker(lngLat)
|
|
1537
|
+
},
|
|
1538
|
+
markers: options.markers,
|
|
1539
|
+
onProgress: options.onProgress,
|
|
1540
|
+
planDurationMs: options.planDurationMs,
|
|
1541
|
+
poses,
|
|
1542
|
+
signal: run.controller.signal
|
|
1543
|
+
});
|
|
1544
|
+
} finally {
|
|
1545
|
+
this.endVideoRun(run);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
async recordPoses(poses, output, options) {
|
|
1549
|
+
if (this.disposed) return cancelledRecording(output);
|
|
1550
|
+
this.focusGlyphUrl = options.focusGlyphUrl ?? null;
|
|
1551
|
+
const run = this.beginVideoRun(options.signal);
|
|
1552
|
+
try {
|
|
1553
|
+
if (options.warmed !== true) await this.warmPosesForRecording(poses, run.controller.signal);
|
|
1554
|
+
return await recordPoses({
|
|
1555
|
+
focusGlyphUrl: this.focusGlyphUrl ?? void 0,
|
|
1556
|
+
map: this.buildRecordingMap(),
|
|
1557
|
+
markers: options.markers,
|
|
1558
|
+
onProgress: options.onProgress,
|
|
1559
|
+
output,
|
|
1560
|
+
poses,
|
|
1561
|
+
profile: options.profile,
|
|
1562
|
+
organization: this.organization,
|
|
1563
|
+
seams: {
|
|
1564
|
+
createCapture: () => createCanvasFrameCapture(this.map.getCanvas()),
|
|
1565
|
+
createSurface: createCanvasSurface
|
|
1566
|
+
},
|
|
1567
|
+
signal: run.controller.signal
|
|
1568
|
+
});
|
|
1569
|
+
} finally {
|
|
1570
|
+
this.endVideoRun(run);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
setVideoFocusMarker(lngLat) {
|
|
1574
|
+
if (this.disposed) return;
|
|
1575
|
+
if (!lngLat) {
|
|
1576
|
+
this.videoFocusMarker?.remove();
|
|
1577
|
+
this.videoFocusMarker = null;
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
const center = new LngLat(lngLat[0], lngLat[1]);
|
|
1581
|
+
if (this.videoFocusMarker) {
|
|
1582
|
+
this.videoFocusMarker.setLngLat(center);
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
this.videoFocusMarker = new Marker({
|
|
1586
|
+
anchor: "center",
|
|
1587
|
+
element: buildVideoFocusMarkerElement(this.focusGlyphUrl)
|
|
1588
|
+
}).setLngLat(center).addTo(this.map);
|
|
1589
|
+
}
|
|
1590
|
+
dispose() {
|
|
1591
|
+
if (this.videoRun) {
|
|
1592
|
+
const run = this.videoRun;
|
|
1593
|
+
run.controller.abort();
|
|
1594
|
+
this.endVideoRun(run);
|
|
1595
|
+
restoreNow();
|
|
1596
|
+
}
|
|
1597
|
+
this.videoFocusMarker?.remove();
|
|
1598
|
+
this.videoFocusMarker = null;
|
|
1599
|
+
this.disposed = true;
|
|
1600
|
+
}
|
|
1601
|
+
beginVideoRun(signal) {
|
|
1602
|
+
const superseded = this.videoRun;
|
|
1603
|
+
superseded?.controller.abort();
|
|
1604
|
+
const controller = new AbortController();
|
|
1605
|
+
const abort = () => {
|
|
1606
|
+
controller.abort();
|
|
1607
|
+
};
|
|
1608
|
+
if (signal.aborted) controller.abort();
|
|
1609
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
1610
|
+
const run = {
|
|
1611
|
+
controller,
|
|
1612
|
+
release: () => {
|
|
1613
|
+
signal.removeEventListener("abort", abort);
|
|
1614
|
+
},
|
|
1615
|
+
restorePose: superseded?.restorePose ?? this.getCameraPose()
|
|
1616
|
+
};
|
|
1617
|
+
this.videoRun = run;
|
|
1618
|
+
return run;
|
|
1619
|
+
}
|
|
1620
|
+
endVideoRun(run) {
|
|
1621
|
+
run.release();
|
|
1622
|
+
if (this.videoRun !== run) return;
|
|
1623
|
+
this.map.jumpTo({
|
|
1624
|
+
bearing: run.restorePose.bearing,
|
|
1625
|
+
center: run.restorePose.center,
|
|
1626
|
+
pitch: run.restorePose.pitch,
|
|
1627
|
+
zoom: run.restorePose.zoom
|
|
1628
|
+
});
|
|
1629
|
+
this.videoRun = null;
|
|
1630
|
+
}
|
|
1631
|
+
buildRecordingMap() {
|
|
1632
|
+
return {
|
|
1633
|
+
captureCanvasSize: () => {
|
|
1634
|
+
const canvas = this.map.getCanvas();
|
|
1635
|
+
return {
|
|
1636
|
+
height: canvas.height,
|
|
1637
|
+
width: canvas.width
|
|
1638
|
+
};
|
|
1639
|
+
},
|
|
1640
|
+
freezeClock: (timeMs) => setNow(timeMs),
|
|
1641
|
+
isDrawingBufferPreserved: () => {
|
|
1642
|
+
return (this.map.getCanvas().getContext("webgl2") ?? this.map.getCanvas().getContext("webgl"))?.getContextAttributes()?.preserveDrawingBuffer === true;
|
|
1643
|
+
},
|
|
1644
|
+
jumpTo: (pose) => this.map.jumpTo(pose),
|
|
1645
|
+
project: (lngLat) => this.projectToCaptureBuffer(lngLat),
|
|
1646
|
+
restoreClock: () => restoreNow(),
|
|
1647
|
+
waitForFrame: (signal) => this.waitForRecorderFrame(signal)
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
projectToCaptureBuffer(lngLat) {
|
|
1651
|
+
const point = this.map.project(lngLat);
|
|
1652
|
+
const canvas = this.map.getCanvas();
|
|
1653
|
+
const scaleX = canvas.clientWidth > 0 ? canvas.width / canvas.clientWidth : 1;
|
|
1654
|
+
const scaleY = canvas.clientHeight > 0 ? canvas.height / canvas.clientHeight : 1;
|
|
1655
|
+
return [point.x * scaleX, point.y * scaleY];
|
|
1656
|
+
}
|
|
1657
|
+
waitForRecorderFrame(signal) {
|
|
1658
|
+
return new Promise((resolve) => {
|
|
1659
|
+
if (signal.aborted) {
|
|
1660
|
+
resolve();
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
this.map.triggerRepaint();
|
|
1664
|
+
if (this.map.loaded()) {
|
|
1665
|
+
resolve();
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
let settled = false;
|
|
1669
|
+
let detach = () => {};
|
|
1670
|
+
const finish = () => {
|
|
1671
|
+
if (settled) return;
|
|
1672
|
+
settled = true;
|
|
1673
|
+
clearTimeout(timeout);
|
|
1674
|
+
detach();
|
|
1675
|
+
signal.removeEventListener("abort", finish);
|
|
1676
|
+
resolve();
|
|
1677
|
+
};
|
|
1678
|
+
const timeout = setTimeout(finish, PER_FRAME_IDLE_TIMEOUT_MS);
|
|
1679
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
1680
|
+
detach = this.events.on("idle", finish);
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
async warmPosesForRecording(poses, signal) {
|
|
1684
|
+
return warmPosesThrough(this.map, this.events, poses, signal);
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
export { MAX_TILE_CACHE_SIZE, MapLibreViewClient, OVERLAY_FONT_FAMILY, VideoRunEngine, WATERMARK_INSET_PX, WATERMARK_REFERENCE_SHORT_SIDE, WATERMARK_URL, WATERMARK_WIDTH_PX, alongFlight, buildProfileCurve, buildVideoFocusMarkerElement, createCanvasFrameCapture, createCanvasSurface, ensureOverlayFonts, previewPoses, profileOverlayDesigns, recordPoses, resolveBitrateBps, resolveDimensions, videoOverlayStringsFor };
|
|
2170
1688
|
|
|
2171
|
-
export { MAX_TILE_CACHE_SIZE, OVERLAY_FONT_FAMILY, VideoRunEngine, WATERMARK_INSET_PX, WATERMARK_REFERENCE_SHORT_SIDE, WATERMARK_URL, WATERMARK_WIDTH_PX, alongFlight, buildProfileCurve, buildVideoFocusMarkerElement, createCanvasFrameCapture, createCanvasSurface, ensureOverlayFonts, previewPoses, profileOverlayDesigns, recordPoses, resolveBitrateBps, resolveDimensions };
|
|
2172
|
-
//# sourceMappingURL=index.js.map
|
|
2173
1689
|
//# sourceMappingURL=index.js.map
|