zidane-gui 9.0.3 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/out/main/chunks/{dev-extension-D5os9z0A.js → dev-extension-CjcEOYly.js} +10 -9
- package/out/main/chunks/extension-watch-Bk_X4gTf.js +93 -0
- package/out/main/chunks/{history-pager-DUFgTrih.js → history-pager-B5iwhWqn.js} +44 -7
- package/out/main/chunks/idle-collect-ZgTY7fw2.js +33 -0
- package/out/main/chunks/{remote-hosts-DlvE2ELX.js → remote-hosts-DmiOiwKi.js} +41 -1
- package/out/main/chunks/{session-search-sql-BrNTuwjH.js → session-search-sql-BaBnjEgm.js} +4 -4
- package/out/main/chunks/{tool-results-sql-C0MqWcQc.js → tool-results-sql-CVleIS51.js} +1 -1
- package/out/main/chunks/transcript-sql-DfsO-a4Q.js +27 -0
- package/out/main/extension-worker.js +52 -0
- package/out/main/git-watch-worker.js +21 -0
- package/out/main/history-worker.js +6 -3
- package/out/main/index.js +7614 -4263
- package/out/main/session-search-worker.js +18 -13
- package/out/main/tool-results-worker.js +18 -13
- package/out/main/update-worker.js +6 -0
- package/out/main/usage-worker.js +4 -1
- package/out/preload/index.mjs +49 -6
- package/out/renderer/assets/2CHDFZHC-B7OS2WPy.js +76 -0
- package/out/renderer/assets/43YPWK3Q-C1KxyhBe.js +297 -0
- package/out/renderer/assets/45MVAN6X-uedsCyvs.js +227 -0
- package/out/renderer/assets/46GJKBLZ-DqRDtmyU.js +362 -0
- package/out/renderer/assets/5THPTBWS-2mBFupjU.js +21 -0
- package/out/renderer/assets/63WH7YNF-E23uJkxY.js +1519 -0
- package/out/renderer/assets/6DDU7VKX-BnYMT-fZ.js +139 -0
- package/out/renderer/assets/7WLXJQOR-C8MM6Bra.js +23 -0
- package/out/renderer/assets/CLQLV5VT-BsAy1F0L.js +1159 -0
- package/out/renderer/assets/CUSPXG5M-BndthcFo.js +233 -0
- package/out/renderer/assets/{CodeEditor-in2F3Rz-.js → CodeEditor-Bc2yVqNr.js} +404 -744
- package/out/renderer/assets/{ComposerEditor-DzKoxH6Z.js → ComposerEditor-B4wmjkXE.js} +6 -7
- package/out/renderer/assets/D3L7O4X2-LfFKkl0g.js +194 -0
- package/out/renderer/assets/D5TW5CPZ-BUXfpU2q.js +21 -0
- package/out/renderer/assets/DKTLEL5E-Dj3316cp.js +42 -0
- package/out/renderer/assets/{DiffsTab-Ceh4E5wW.js → DiffsTab-BHaJc7Ve.js} +43 -26
- package/out/renderer/assets/EGADTWYV-giCCF2cw.js +292 -0
- package/out/renderer/assets/EOJSJZXM-B9xc3U2A.js +1137 -0
- package/out/renderer/assets/{EditorWorkers-Bhv2OJRb.js → EditorWorkers-DABG5YG9.js} +9 -11
- package/out/renderer/assets/FTXIJQGB-BX14b7pN.js +13 -0
- package/out/renderer/assets/{FileIcon-CYgGSQ59.js → FileIcon-acads6Ac.js} +1 -1
- package/out/renderer/assets/{FilesTab-DESQMqGK.js → FilesTab-CyWw9vW2.js} +70 -28
- package/out/renderer/assets/G2OEIG6X-hZmo0wrY.js +519 -0
- package/out/renderer/assets/G3MDBVQH-qZ3yfAIw.js +25 -0
- package/out/renderer/assets/GXJ2T77W-Dx1MA_On.js +445 -0
- package/out/renderer/assets/HX3UMAK7-DcJt6NaE.js +177 -0
- package/out/renderer/assets/IU7WZTP6-BZMu2vL3.js +137 -0
- package/out/renderer/assets/J5J2NR2G-CbQLnnZq.js +673 -0
- package/out/renderer/assets/JRCWTJEL-xEOyWDIN.js +419 -0
- package/out/renderer/assets/KHUP5TOH-032p46g-.js +359 -0
- package/out/renderer/assets/L74FQTH5-CQ_54hNm.js +994 -0
- package/out/renderer/assets/LAV4ZXOS-DvhVMhLR.js +968 -0
- package/out/renderer/assets/LBIZYCRR-CMaDdulz.js +715 -0
- package/out/renderer/assets/LFFXNLRS-BjbqzBYN.js +377 -0
- package/out/renderer/assets/LLLWOAQD-B2zZRpRf.js +409 -0
- package/out/renderer/assets/LTYQZ5U5-DzI-7yJW.js +1223 -0
- package/out/renderer/assets/NDSCUZ25-C9oT6c6G.js +83 -0
- package/out/renderer/assets/NMN3IKWL-9IsXehWp.js +1042 -0
- package/out/renderer/assets/NMUA3R2D-B2ZuyfXA.js +1080 -0
- package/out/renderer/assets/NY5A6PPW-BzmvsXmE.js +523 -0
- package/out/renderer/assets/OHJ2EJXK-BEkFEoxu.js +85 -0
- package/out/renderer/assets/OU2GIT2H-DZQl_5qv.js +32 -0
- package/out/renderer/assets/PDMLSE6I-C3FMl6Ej.js +15 -0
- package/out/renderer/assets/PJ7X32S5-BQ3aTkUy.js +188 -0
- package/out/renderer/assets/RLLQ44NJ-Dq15CCQ6.js +248 -0
- package/out/renderer/assets/RVARI57O-DMrXgtoB.js +10 -0
- package/out/renderer/assets/S6DWMCK5-KeQNStMI.js +817 -0
- package/out/renderer/assets/STIOTUT7-ZnewWXB7.js +509 -0
- package/out/renderer/assets/SXSLPWUD-VIPmiOfk.js +120 -0
- package/out/renderer/assets/TR4WJQGX-CQ3dPMLJ.js +25 -0
- package/out/renderer/assets/UWRPUF3N-CtgKKvKe.js +1276 -0
- package/out/renderer/assets/VSWIZJ7B-BN-hZ_G_.js +205 -0
- package/out/renderer/assets/WM7NR6YK-CghasXna.js +193 -0
- package/out/renderer/assets/WXKV2YEK-C8qjO_OQ.js +499 -0
- package/out/renderer/assets/XLHPVVFU-CoRVO17g.js +56 -0
- package/out/renderer/assets/YNX532HU-DhZCm9iK.js +119 -0
- package/out/renderer/assets/YUPSMAUO-Brx2G_oh.js +39 -0
- package/out/renderer/assets/ZFRCZTLK-Cs8fJIgy.js +150 -0
- package/out/renderer/assets/ZZDR4CN3-DcTVOpcO.js +122 -0
- package/out/renderer/assets/andromeeda-Bx1G2cLE.js +293 -0
- package/out/renderer/assets/andromeeda-vBqMIOkk.js +293 -0
- package/out/renderer/assets/aurora-x-Cm7-xw-C.js +243 -0
- package/out/renderer/assets/aurora-x-DPl7s7lw.js +243 -0
- package/out/renderer/assets/ayu-dark-CwZzE4zG.js +207 -0
- package/out/renderer/assets/ayu-dark-DkHc-GR-.js +207 -0
- package/out/renderer/assets/ayu-light-D8NJUeg2.js +207 -0
- package/out/renderer/assets/ayu-light-DNVhSCsl.js +207 -0
- package/out/renderer/assets/ayu-mirage-C-lSBwzI.js +207 -0
- package/out/renderer/assets/ayu-mirage-JE49iZ2H.js +207 -0
- package/out/renderer/assets/catppuccin-frappe-DU1nAiyx.js +414 -0
- package/out/renderer/assets/catppuccin-frappe-DX6Q-ciL.js +414 -0
- package/out/renderer/assets/catppuccin-latte-CO9onEOF.js +414 -0
- package/out/renderer/assets/catppuccin-latte-CkSyOFfG.js +414 -0
- package/out/renderer/assets/catppuccin-macchiato-OyZDjojj.js +414 -0
- package/out/renderer/assets/catppuccin-macchiato-WINjU_Dw.js +414 -0
- package/out/renderer/assets/catppuccin-mocha-0z8-eFg0.js +414 -0
- package/out/renderer/assets/catppuccin-mocha-DRTSTdRR.js +414 -0
- package/out/renderer/assets/core-COuvbqNs.js +5186 -0
- package/out/renderer/assets/{highlight.worker-gURcNJD7.js → core-Drnj1qQL.js} +404 -4454
- package/out/renderer/assets/{core-xOIU6ifr.js → core-Z_paRVMb.js} +3208 -1946
- package/out/renderer/assets/dark-plus-BaggkchT.js +241 -0
- package/out/renderer/assets/dark-plus-Conw9IRY.js +241 -0
- package/out/renderer/assets/default-CzLFidVE.js +1890 -0
- package/out/renderer/assets/dracula-BKSZoV-6.js +227 -0
- package/out/renderer/assets/dracula-BpiXsqbq.js +227 -0
- package/out/renderer/assets/dracula-soft-BF0b4PXf.js +169 -0
- package/out/renderer/assets/dracula-soft-DIWOT7Wr.js +169 -0
- package/out/renderer/assets/engine-javascript-CtTomO8o.js +3238 -0
- package/out/renderer/assets/engine-javascript-DUvVq6Hk.js +3223 -0
- package/out/renderer/assets/engine-oniguruma-DKBWYAaE.js +482 -0
- package/out/renderer/assets/engine-oniguruma-mZf4aRKS.js +482 -0
- package/out/renderer/assets/everforest-dark-B3n4qCUZ.js +181 -0
- package/out/renderer/assets/everforest-dark-BXgth4bF.js +181 -0
- package/out/renderer/assets/everforest-light-BhaIwhYu.js +181 -0
- package/out/renderer/assets/everforest-light-cbpcbx0E.js +181 -0
- package/out/renderer/assets/{file-tabs-Cozt9Sho.js → file-tabs-BCf1cAWp.js} +10 -12
- package/out/renderer/assets/{ghostty-web-BTHoKwMc.js → ghostty-web-CdNv377h.js} +3 -1
- package/out/renderer/assets/github-dark-BESFF5XO.js +234 -0
- package/out/renderer/assets/github-dark-DNCSzN6m.js +234 -0
- package/out/renderer/assets/github-dark-default-DgFmzzcd.js +168 -0
- package/out/renderer/assets/github-dark-default-ffmDUf0z.js +168 -0
- package/out/renderer/assets/github-dark-dimmed-CLKTYZCg.js +225 -0
- package/out/renderer/assets/github-dark-dimmed-s1SLsKJt.js +225 -0
- package/out/renderer/assets/github-dark-high-contrast-CXehgwDU.js +225 -0
- package/out/renderer/assets/github-dark-high-contrast-KLlCEr3k.js +225 -0
- package/out/renderer/assets/github-light-U3PkvbB_.js +234 -0
- package/out/renderer/assets/github-light-default-BPzGUBgG.js +225 -0
- package/out/renderer/assets/github-light-default-xMLgS_bN.js +225 -0
- package/out/renderer/assets/github-light-high-contrast-C8D72_o0.js +225 -0
- package/out/renderer/assets/github-light-high-contrast-DQhuIFi9.js +225 -0
- package/out/renderer/assets/github-light-jtm9FPHO.js +234 -0
- package/out/renderer/assets/gruvbox-dark-hard-BAboCHnq.js +214 -0
- package/out/renderer/assets/gruvbox-dark-hard-woZR1aVf.js +214 -0
- package/out/renderer/assets/gruvbox-dark-medium-BsoEOmFF.js +214 -0
- package/out/renderer/assets/gruvbox-dark-medium-CNo7daJC.js +214 -0
- package/out/renderer/assets/gruvbox-dark-soft-CaJ_lf0b.js +214 -0
- package/out/renderer/assets/gruvbox-dark-soft-Cg271WAX.js +214 -0
- package/out/renderer/assets/gruvbox-light-hard-CEjA0x_J.js +214 -0
- package/out/renderer/assets/gruvbox-light-hard-D8Ufxp8E.js +214 -0
- package/out/renderer/assets/gruvbox-light-medium-BCS-MX7u.js +214 -0
- package/out/renderer/assets/gruvbox-light-medium-DZkNZdeM.js +214 -0
- package/out/renderer/assets/gruvbox-light-soft-CRdK2Ssn.js +214 -0
- package/out/renderer/assets/gruvbox-light-soft-DEEl98i-.js +214 -0
- package/out/renderer/assets/hastToHtml-AUrFnNH_.js +123 -0
- package/out/renderer/assets/highlight.worker-BYB12Fvh.js +1624 -0
- package/out/renderer/assets/highlights-Cjdp9LIq.js +292 -0
- package/out/renderer/assets/highlights-CpZm9DAR-DaBE50nC.js +2188 -0
- package/out/renderer/assets/highlights-DaYW35iB.js +313 -0
- package/out/renderer/assets/horizon-B492K9Ky.js +165 -0
- package/out/renderer/assets/horizon-DAZuC-xh.js +165 -0
- package/out/renderer/assets/horizon-bright-D2Sfzu7E.js +165 -0
- package/out/renderer/assets/horizon-bright-tGFWGsRc.js +165 -0
- package/out/renderer/assets/houston-BuwDhoUX.js +373 -0
- package/out/renderer/assets/houston-Cp9zzZds.js +373 -0
- package/out/renderer/assets/index-DhpOdP7M.js +882 -0
- package/out/renderer/assets/{index-DkE-xvCG.js → index-_dhRO6Oc.js} +1823 -384
- package/out/renderer/assets/{index-DrLLItLS.css → index-fNK5AY6Q.css} +202 -42
- package/out/renderer/assets/kanagawa-dragon-6NLBJhOz.js +229 -0
- package/out/renderer/assets/kanagawa-dragon-BF7rCHRT.js +229 -0
- package/out/renderer/assets/kanagawa-lotus-Cj8RDQcT.js +229 -0
- package/out/renderer/assets/kanagawa-lotus-uV7FMPcj.js +229 -0
- package/out/renderer/assets/kanagawa-wave-0rvDP1ei.js +229 -0
- package/out/renderer/assets/kanagawa-wave-B6IVm0GO.js +229 -0
- package/out/renderer/assets/{kit-BUt8oFlT.js → kit-E8-H6M0V.js} +45590 -39890
- package/out/renderer/assets/langs-BDUDFyts.js +1333 -0
- package/out/renderer/assets/langs-BtXnoosO.js +1331 -0
- package/out/renderer/assets/laserwave-DXWE1WnK.js +166 -0
- package/out/renderer/assets/laserwave-JLRBtymH.js +166 -0
- package/out/renderer/assets/lazy-DQmrNfMK.js +1188 -0
- package/out/renderer/assets/light-plus-DU2oMqtU.js +244 -0
- package/out/renderer/assets/light-plus-D_GZIzn-.js +244 -0
- package/out/renderer/assets/loader-byWkNl6P.js +83 -0
- package/out/renderer/assets/loader-q6EC19QI.js +80 -0
- package/out/renderer/assets/material-theme-C0rHRk_7.js +171 -0
- package/out/renderer/assets/material-theme-CKzpgSIj.js +171 -0
- package/out/renderer/assets/material-theme-darker-LxtgP-nI.js +171 -0
- package/out/renderer/assets/material-theme-darker-q1PJSGwC.js +171 -0
- package/out/renderer/assets/material-theme-lighter-Bo7q33GI.js +171 -0
- package/out/renderer/assets/material-theme-lighter-DIrXq_cm.js +171 -0
- package/out/renderer/assets/material-theme-ocean-DBoGA257.js +171 -0
- package/out/renderer/assets/material-theme-ocean-DKw0PiZ1.js +171 -0
- package/out/renderer/assets/material-theme-palenight-C6KqY_uf.js +171 -0
- package/out/renderer/assets/material-theme-palenight-DoLm5E7H.js +171 -0
- package/out/renderer/assets/min-dark-C29HEm34.js +166 -0
- package/out/renderer/assets/min-dark-C5zOB6s9.js +166 -0
- package/out/renderer/assets/min-light-BDAdB2zx.js +166 -0
- package/out/renderer/assets/min-light-CCfylF7u.js +166 -0
- package/out/renderer/assets/monokai-CgbJVDnk.js +246 -0
- package/out/renderer/assets/monokai-hi1UnAdE.js +246 -0
- package/out/renderer/assets/night-owl-Cy8ZrWil.js +238 -0
- package/out/renderer/assets/night-owl-Pfm14M0L.js +238 -0
- package/out/renderer/assets/night-owl-light-Cr6ug2dl.js +237 -0
- package/out/renderer/assets/night-owl-light-UewpB7JV.js +237 -0
- package/out/renderer/assets/nord-C68LX7oy.js +200 -0
- package/out/renderer/assets/nord-D68iK8nx.js +200 -0
- package/out/renderer/assets/one-dark-pro-DSih0ZZj.js +196 -0
- package/out/renderer/assets/one-dark-pro-DyTT0T_G.js +196 -0
- package/out/renderer/assets/one-light--fEa3idW.js +232 -0
- package/out/renderer/assets/one-light-BzGf0rQc.js +232 -0
- package/out/renderer/assets/{patch-parse.worker-BAW1QWyk.js → patch-parse.worker-siqPY9wG.js} +24 -4
- package/out/renderer/assets/pierre-dark-1Xh1-lMo.js +4 -0
- package/out/renderer/assets/pierre-dark-7z_hCG7W.js +364 -0
- package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-DjiH32kw.js +364 -0
- package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-GW6g2K_K.js +364 -0
- package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-LDfpPKjm.js +4 -0
- package/out/renderer/assets/pierre-dark-soft-1iBHdNO0.js +364 -0
- package/out/renderer/assets/pierre-dark-soft-C_k_gt55.js +4 -0
- package/out/renderer/assets/pierre-dark-soft-D5-n1AeJ.js +364 -0
- package/out/renderer/assets/pierre-dark-tritanopia-CeWJyYfV.js +4 -0
- package/out/renderer/assets/pierre-dark-tritanopia-ClMvjOGO.js +364 -0
- package/out/renderer/assets/pierre-dark-tritanopia-D9kXXcwP.js +364 -0
- package/out/renderer/assets/pierre-dark-vibrant-6Oqz1PbM.js +4 -0
- package/out/renderer/assets/pierre-dark-vibrant-C8yH51pK.js +364 -0
- package/out/renderer/assets/pierre-dark-vibrant-D_7rJXbX.js +364 -0
- package/out/renderer/assets/pierre-dark-yHUcpElV.js +364 -0
- package/out/renderer/assets/pierre-light-BIebL0yQ.js +4 -0
- package/out/renderer/assets/pierre-light-C34x-mcs.js +364 -0
- package/out/renderer/assets/pierre-light-C9v4GAHb.js +364 -0
- package/out/renderer/assets/pierre-light-protanopia-deuteranopia-BufD2-1n.js +4 -0
- package/out/renderer/assets/pierre-light-protanopia-deuteranopia-DUrvpW2C.js +364 -0
- package/out/renderer/assets/pierre-light-protanopia-deuteranopia-VwXWNPo2.js +364 -0
- package/out/renderer/assets/pierre-light-soft-BmDnpPlM.js +364 -0
- package/out/renderer/assets/pierre-light-soft-Cd6v49hf.js +4 -0
- package/out/renderer/assets/pierre-light-soft-DqFh0kZA.js +364 -0
- package/out/renderer/assets/pierre-light-tritanopia-BVCfgdSF.js +364 -0
- package/out/renderer/assets/pierre-light-tritanopia-RkA2q6k9.js +364 -0
- package/out/renderer/assets/pierre-light-tritanopia-VrCUn-Lh.js +4 -0
- package/out/renderer/assets/pierre-light-vibrant-C5BaqWq3.js +364 -0
- package/out/renderer/assets/pierre-light-vibrant-CCrCMYrB.js +364 -0
- package/out/renderer/assets/pierre-light-vibrant-ClZHsQXl.js +4 -0
- package/out/renderer/assets/{pierre-theme-Bj5EAt1L.js → pierre-theme-CsyO3esE.js} +1022 -913
- package/out/renderer/assets/plastic-7t7HzasC.js +207 -0
- package/out/renderer/assets/plastic-EgWoj0TX.js +207 -0
- package/out/renderer/assets/poimandres-Clm3QHf_.js +186 -0
- package/out/renderer/assets/poimandres-_9ZL-zjP.js +186 -0
- package/out/renderer/assets/red-BGLMOAQA.js +240 -0
- package/out/renderer/assets/red-C7WxuK4s.js +240 -0
- package/out/renderer/assets/rose-pine-CSYOOLQH.js +200 -0
- package/out/renderer/assets/rose-pine-DQTixAK4.js +200 -0
- package/out/renderer/assets/rose-pine-dawn-BsExWFpO.js +200 -0
- package/out/renderer/assets/rose-pine-dawn-DtnCKB3V.js +200 -0
- package/out/renderer/assets/rose-pine-moon-CIVzFPCR.js +200 -0
- package/out/renderer/assets/rose-pine-moon-DUVYttUm.js +200 -0
- package/out/renderer/assets/shiki-Ci4cdHsM-C6d-uTVf.js +681 -0
- package/out/renderer/assets/shiki-DxXti3Bm.js +651 -0
- package/out/renderer/assets/slack-dark-DqfBLzDN.js +156 -0
- package/out/renderer/assets/slack-dark-PDVLPqBV.js +156 -0
- package/out/renderer/assets/slack-ochin-BXb20b9s.js +167 -0
- package/out/renderer/assets/slack-ochin-Bkl8Akj-.js +167 -0
- package/out/renderer/assets/snazzy-light-B-XgRQqH.js +169 -0
- package/out/renderer/assets/snazzy-light-B_Pnr_t3.js +169 -0
- package/out/renderer/assets/solarized-dark-BExlwCgF.js +256 -0
- package/out/renderer/assets/solarized-dark-BWOkBqBk.js +256 -0
- package/out/renderer/assets/solarized-light-B0LC-9ef.js +256 -0
- package/out/renderer/assets/solarized-light-B7xKmc3j.js +256 -0
- package/out/renderer/assets/stream-tokenizer-DK9xp5M5-BkzgPytU.js +2641 -0
- package/out/renderer/assets/stream-tokenizer-sqhinrU5.js +131 -0
- package/out/renderer/assets/synthwave-84-Bz5LYLQI.js +766 -0
- package/out/renderer/assets/synthwave-84-DnB997dV.js +766 -0
- package/out/renderer/assets/themes-DGY5d--g.js +323 -0
- package/out/renderer/assets/themes-KOxcu5sY.js +322 -0
- package/out/renderer/assets/tokyo-night-BFQDXQF9.js +343 -0
- package/out/renderer/assets/tokyo-night-BKV2xFQO.js +343 -0
- package/out/renderer/assets/{useDetachCleanup-Bb7k1ePf.js → useDetachCleanup-DYbCqwX-.js} +95 -51
- package/out/renderer/assets/{useFolderChanges-B4X4n6NV.js → useFolderChanges-Y0OqX_nG.js} +406 -242
- package/out/renderer/assets/utils-BcG7Lqcy.js +90 -0
- package/out/renderer/assets/{vendor-BvslLX9q.js → vendor-BpwX-s_O.js} +16835 -16799
- package/out/renderer/assets/{vendor-editor-Bx3dRdBD.js → vendor-editor-Cx3SvGyZ.js} +2 -2
- package/out/renderer/assets/{vendor-motion-BLeNAEjH.js → vendor-motion-CD5Og8pC.js} +3 -3
- package/out/renderer/assets/{vendor-react-DltKc0Ts.js → vendor-react-bPTwWURR.js} +28 -12
- package/out/renderer/assets/vesper-BVtJs6jF.js +173 -0
- package/out/renderer/assets/vesper-BXSaHQeX.js +173 -0
- package/out/renderer/assets/vitesse-black-Bk4nGSr_.js +388 -0
- package/out/renderer/assets/vitesse-black-DjBh7jMr.js +388 -0
- package/out/renderer/assets/vitesse-dark-BSeRY0TR.js +388 -0
- package/out/renderer/assets/vitesse-dark-Czy_Ejt3.js +388 -0
- package/out/renderer/assets/vitesse-light-BpMpGmeY.js +388 -0
- package/out/renderer/assets/vitesse-light-Cv09MZGR.js +388 -0
- package/out/renderer/assets/worker-CswOd5_T.js +2367 -0
- package/out/renderer/index.html +8 -9
- package/package.json +13 -6
- package/out/main/chunks/transcript-sql-DbZ-a5wb.js +0 -43
- package/out/renderer/assets/index-DogoEzwx.js +0 -10868
- package/out/renderer/assets/vendor-shiki-ba8IDo5s.js +0 -459
- package/out/renderer/assets/worker-DNIQ0wG8.js +0 -12761
|
@@ -0,0 +1,2367 @@
|
|
|
1
|
+
class Diff {
|
|
2
|
+
diff(oldStr, newStr, options = {}) {
|
|
3
|
+
let callback;
|
|
4
|
+
if (typeof options === "function") {
|
|
5
|
+
callback = options;
|
|
6
|
+
options = {};
|
|
7
|
+
} else if ("callback" in options) {
|
|
8
|
+
callback = options.callback;
|
|
9
|
+
}
|
|
10
|
+
const oldString = this.castInput(oldStr, options);
|
|
11
|
+
const newString = this.castInput(newStr, options);
|
|
12
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
13
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
14
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
15
|
+
}
|
|
16
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
17
|
+
var _a;
|
|
18
|
+
const done = (value) => {
|
|
19
|
+
value = this.postProcess(value, options);
|
|
20
|
+
if (callback) {
|
|
21
|
+
setTimeout(function() {
|
|
22
|
+
callback(value);
|
|
23
|
+
}, 0);
|
|
24
|
+
return void 0;
|
|
25
|
+
} else {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
30
|
+
let editLength = 1;
|
|
31
|
+
let maxEditLength = newLen + oldLen;
|
|
32
|
+
if (options.maxEditLength != null) {
|
|
33
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
34
|
+
}
|
|
35
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
36
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
37
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
38
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
39
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
40
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
41
|
+
}
|
|
42
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
43
|
+
const execEditLength = () => {
|
|
44
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
45
|
+
let basePath;
|
|
46
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
47
|
+
if (removePath) {
|
|
48
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
49
|
+
}
|
|
50
|
+
let canAdd = false;
|
|
51
|
+
if (addPath) {
|
|
52
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
53
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
54
|
+
}
|
|
55
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
56
|
+
if (!canAdd && !canRemove) {
|
|
57
|
+
bestPath[diagonalPath] = void 0;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
61
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
62
|
+
} else {
|
|
63
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
64
|
+
}
|
|
65
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
66
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
67
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
68
|
+
} else {
|
|
69
|
+
bestPath[diagonalPath] = basePath;
|
|
70
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
71
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
72
|
+
}
|
|
73
|
+
if (newPos + 1 >= newLen) {
|
|
74
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
editLength++;
|
|
79
|
+
};
|
|
80
|
+
if (callback) {
|
|
81
|
+
(function exec() {
|
|
82
|
+
setTimeout(function() {
|
|
83
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
84
|
+
return callback(void 0);
|
|
85
|
+
}
|
|
86
|
+
if (!execEditLength()) {
|
|
87
|
+
exec();
|
|
88
|
+
}
|
|
89
|
+
}, 0);
|
|
90
|
+
})();
|
|
91
|
+
} else {
|
|
92
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
93
|
+
const ret = execEditLength();
|
|
94
|
+
if (ret) {
|
|
95
|
+
return ret;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
101
|
+
const last = path.lastComponent;
|
|
102
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
103
|
+
return {
|
|
104
|
+
oldPos: path.oldPos + oldPosInc,
|
|
105
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
oldPos: path.oldPos + oldPosInc,
|
|
110
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
115
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
116
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
117
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
118
|
+
newPos++;
|
|
119
|
+
oldPos++;
|
|
120
|
+
commonCount++;
|
|
121
|
+
if (options.oneChangePerToken) {
|
|
122
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
126
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
127
|
+
}
|
|
128
|
+
basePath.oldPos = oldPos;
|
|
129
|
+
return newPos;
|
|
130
|
+
}
|
|
131
|
+
equals(left, right, options) {
|
|
132
|
+
if (options.comparator) {
|
|
133
|
+
return options.comparator(left, right);
|
|
134
|
+
} else {
|
|
135
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
removeEmpty(array) {
|
|
139
|
+
const ret = [];
|
|
140
|
+
for (let i = 0; i < array.length; i++) {
|
|
141
|
+
if (array[i]) {
|
|
142
|
+
ret.push(array[i]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return ret;
|
|
146
|
+
}
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
148
|
+
castInput(value, options) {
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
152
|
+
tokenize(value, options) {
|
|
153
|
+
return Array.from(value);
|
|
154
|
+
}
|
|
155
|
+
join(chars) {
|
|
156
|
+
return chars.join("");
|
|
157
|
+
}
|
|
158
|
+
postProcess(changeObjects, options) {
|
|
159
|
+
return changeObjects;
|
|
160
|
+
}
|
|
161
|
+
get useLongestToken() {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
165
|
+
const components = [];
|
|
166
|
+
let nextComponent;
|
|
167
|
+
while (lastComponent) {
|
|
168
|
+
components.push(lastComponent);
|
|
169
|
+
nextComponent = lastComponent.previousComponent;
|
|
170
|
+
delete lastComponent.previousComponent;
|
|
171
|
+
lastComponent = nextComponent;
|
|
172
|
+
}
|
|
173
|
+
components.reverse();
|
|
174
|
+
const componentLen = components.length;
|
|
175
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
176
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
177
|
+
const component = components[componentPos];
|
|
178
|
+
if (!component.removed) {
|
|
179
|
+
if (!component.added && this.useLongestToken) {
|
|
180
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
181
|
+
value = value.map(function(value2, i) {
|
|
182
|
+
const oldValue = oldTokens[oldPos + i];
|
|
183
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
184
|
+
});
|
|
185
|
+
component.value = this.join(value);
|
|
186
|
+
} else {
|
|
187
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
188
|
+
}
|
|
189
|
+
newPos += component.count;
|
|
190
|
+
if (!component.added) {
|
|
191
|
+
oldPos += component.count;
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
195
|
+
oldPos += component.count;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return components;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
class CharacterDiff extends Diff {
|
|
202
|
+
}
|
|
203
|
+
const characterDiff = new CharacterDiff();
|
|
204
|
+
function diffChars(oldStr, newStr, options) {
|
|
205
|
+
return characterDiff.diff(oldStr, newStr, options);
|
|
206
|
+
}
|
|
207
|
+
const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
208
|
+
class WordsWithSpaceDiff extends Diff {
|
|
209
|
+
tokenize(value) {
|
|
210
|
+
const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
|
|
211
|
+
return value.match(regex) || [];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const wordsWithSpaceDiff = new WordsWithSpaceDiff();
|
|
215
|
+
function diffWordsWithSpace(oldStr, newStr, options) {
|
|
216
|
+
return wordsWithSpaceDiff.diff(oldStr, newStr, options);
|
|
217
|
+
}
|
|
218
|
+
const HEX_TRANSPARENT_RE = /^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i;
|
|
219
|
+
const ALPHA_ZERO_RE = /^0(?:\.0+)?%?$/;
|
|
220
|
+
function getFunctionalAlpha(color) {
|
|
221
|
+
const openParen = color.indexOf("(");
|
|
222
|
+
if (openParen <= 0 || !color.endsWith(")")) return;
|
|
223
|
+
const fn = color.slice(0, openParen).trim();
|
|
224
|
+
if (!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(fn)) return;
|
|
225
|
+
const inner = color.slice(openParen + 1, -1).trim();
|
|
226
|
+
if (inner.length === 0) return;
|
|
227
|
+
const slashIndex = inner.lastIndexOf("/");
|
|
228
|
+
if (slashIndex !== -1) return inner.slice(slashIndex + 1).trim();
|
|
229
|
+
if (/^(?:rgba|hsla)$/i.test(fn)) {
|
|
230
|
+
const parts = inner.split(",");
|
|
231
|
+
if (parts.length === 4) return parts[3]?.trim();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function parseHexRgba(color) {
|
|
235
|
+
const match = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(color.trim());
|
|
236
|
+
if (match == null) return null;
|
|
237
|
+
const hex = match[1];
|
|
238
|
+
let expanded;
|
|
239
|
+
let alpha = 1;
|
|
240
|
+
if (hex.length === 3) expanded = hex.split("").map((c) => c + c).join("");
|
|
241
|
+
else if (hex.length === 6) expanded = hex;
|
|
242
|
+
else {
|
|
243
|
+
expanded = hex.slice(0, 6);
|
|
244
|
+
alpha = parseInt(hex.slice(6, 8), 16) / 255;
|
|
245
|
+
}
|
|
246
|
+
return [
|
|
247
|
+
parseInt(expanded.slice(0, 2), 16),
|
|
248
|
+
parseInt(expanded.slice(2, 4), 16),
|
|
249
|
+
parseInt(expanded.slice(4, 6), 16),
|
|
250
|
+
alpha
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
function relativeLuminance(color) {
|
|
254
|
+
if (color == null) return null;
|
|
255
|
+
const rgba = parseHexRgba(color);
|
|
256
|
+
if (rgba == null) return null;
|
|
257
|
+
const r = rgba[0] / 255;
|
|
258
|
+
const g = rgba[1] / 255;
|
|
259
|
+
const b = rgba[2] / 255;
|
|
260
|
+
const channel = (v) => v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
261
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
262
|
+
}
|
|
263
|
+
function isFullyTransparent(color) {
|
|
264
|
+
if (color == null) return false;
|
|
265
|
+
const normalized = color.trim().toLowerCase();
|
|
266
|
+
if (normalized === "transparent") return true;
|
|
267
|
+
if (HEX_TRANSPARENT_RE.test(normalized)) return true;
|
|
268
|
+
const alpha = getFunctionalAlpha(normalized);
|
|
269
|
+
return alpha != null && ALPHA_ZERO_RE.test(alpha);
|
|
270
|
+
}
|
|
271
|
+
function hoverWouldEraseText(hover, bg, fg) {
|
|
272
|
+
if (bg == null || fg == null) return false;
|
|
273
|
+
const hoverL = relativeLuminance(hover);
|
|
274
|
+
const bgL = relativeLuminance(bg);
|
|
275
|
+
const fgL = relativeLuminance(fg);
|
|
276
|
+
if (hoverL == null || bgL == null || fgL == null) return false;
|
|
277
|
+
return Math.abs(hoverL - fgL) < Math.abs(hoverL - bgL);
|
|
278
|
+
}
|
|
279
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
280
|
+
function normalizeThemeColors(theme) {
|
|
281
|
+
const cached = cache.get(theme);
|
|
282
|
+
if (cached != null) return cached;
|
|
283
|
+
const originalColors = theme.colors ?? {};
|
|
284
|
+
const colors = { ...originalColors };
|
|
285
|
+
const editorBackground = originalColors["editor.background"] ?? theme.bg;
|
|
286
|
+
const editorForeground = originalColors["editor.foreground"] ?? theme.fg;
|
|
287
|
+
const sidebarBackground = originalColors["sideBar.background"] ?? editorBackground;
|
|
288
|
+
const sidebarForeground = originalColors["sideBar.foreground"] ?? editorForeground;
|
|
289
|
+
fill(colors, "editor.background", editorBackground);
|
|
290
|
+
fill(colors, "editor.foreground", editorForeground);
|
|
291
|
+
fill(colors, "sideBar.background", sidebarBackground);
|
|
292
|
+
fill(colors, "sideBar.foreground", sidebarForeground);
|
|
293
|
+
fill(colors, "input.background", originalColors["input.background"] ?? sidebarBackground);
|
|
294
|
+
fill(colors, "sideBarSectionHeader.foreground", originalColors["sideBarSectionHeader.foreground"] ?? sidebarForeground);
|
|
295
|
+
fill(colors, "list.activeSelectionForeground", originalColors["list.activeSelectionForeground"] ?? sidebarForeground);
|
|
296
|
+
fill(colors, "gitDecoration.addedResourceForeground", firstColor(originalColors["gitDecoration.addedResourceForeground"], originalColors["terminal.ansiGreen"], originalColors["editorGutter.addedBackground"]));
|
|
297
|
+
fill(colors, "gitDecoration.modifiedResourceForeground", firstColor(originalColors["gitDecoration.modifiedResourceForeground"], originalColors["terminal.ansiBlue"], originalColors["editorGutter.modifiedBackground"]));
|
|
298
|
+
fill(colors, "gitDecoration.deletedResourceForeground", firstColor(originalColors["gitDecoration.deletedResourceForeground"], originalColors["terminal.ansiRed"], originalColors["editorGutter.deletedBackground"]));
|
|
299
|
+
const focusRing = (isFullyTransparent(originalColors["list.focusOutline"]) ? void 0 : originalColors["list.focusOutline"]) ?? (isFullyTransparent(originalColors["focusBorder"]) ? void 0 : originalColors["focusBorder"]);
|
|
300
|
+
if (focusRing != null) colors["list.focusOutline"] = focusRing;
|
|
301
|
+
else delete colors["list.focusOutline"];
|
|
302
|
+
const hover = originalColors["list.hoverBackground"];
|
|
303
|
+
if (hover != null && (matchesSurface(hover, sidebarBackground) || hoverWouldEraseText(hover, sidebarBackground, sidebarForeground))) delete colors["list.hoverBackground"];
|
|
304
|
+
const result = Object.freeze({
|
|
305
|
+
...theme,
|
|
306
|
+
colors: Object.freeze(colors)
|
|
307
|
+
});
|
|
308
|
+
cache.set(theme, result);
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
function fill(colors, key, value) {
|
|
312
|
+
if (value != null && value !== "") colors[key] = value;
|
|
313
|
+
}
|
|
314
|
+
function firstColor(...candidates) {
|
|
315
|
+
for (const candidate of candidates) if (candidate != null && candidate !== "") return candidate;
|
|
316
|
+
}
|
|
317
|
+
function matchesSurface(color, surface) {
|
|
318
|
+
return surface != null && color.toLowerCase() === surface.toLowerCase();
|
|
319
|
+
}
|
|
320
|
+
(() => {
|
|
321
|
+
try {
|
|
322
|
+
return false;
|
|
323
|
+
} catch {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
})();
|
|
327
|
+
const DEFAULT_THEMES = {
|
|
328
|
+
dark: "pierre-dark",
|
|
329
|
+
light: "pierre-light"
|
|
330
|
+
};
|
|
331
|
+
const ResolvedLanguages = /* @__PURE__ */ new Map();
|
|
332
|
+
const ResolvingLanguages = /* @__PURE__ */ new Map();
|
|
333
|
+
const RegisteredCustomLanguages = /* @__PURE__ */ new Map();
|
|
334
|
+
const AttachedLanguages = /* @__PURE__ */ new Set();
|
|
335
|
+
function attachResolvedLanguages(resolvedLanguages, highlighter2) {
|
|
336
|
+
for (const resolvedLang of Array.isArray(resolvedLanguages) ? resolvedLanguages : [resolvedLanguages]) {
|
|
337
|
+
let lang = ResolvedLanguages.get(resolvedLang.name);
|
|
338
|
+
if (lang == null) {
|
|
339
|
+
lang = resolvedLang;
|
|
340
|
+
ResolvedLanguages.set(resolvedLang.name, lang);
|
|
341
|
+
}
|
|
342
|
+
highlighter2.attachLanguages([lang]);
|
|
343
|
+
AttachedLanguages.add(lang.name);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
let activeType;
|
|
347
|
+
let holds = 0;
|
|
348
|
+
var HighlighterDisposedError = class extends Error {
|
|
349
|
+
constructor() {
|
|
350
|
+
super("Highlighter is disposed");
|
|
351
|
+
this.name = "HighlighterDisposedError";
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
function resolveHighlighterType(type) {
|
|
355
|
+
return type ?? activeType ?? "shiki-js";
|
|
356
|
+
}
|
|
357
|
+
function assertHighlighterType(type) {
|
|
358
|
+
if (activeType != null && activeType !== type) throw new Error(`Cannot load the "${type}" highlighter while "${activeType}" is in use. Only one highlighter type can be active at a time; dispose every "${activeType}" instance (disposeHighlighter() disposes the shared one) before switching.`);
|
|
359
|
+
}
|
|
360
|
+
function acquireHighlighterType(type) {
|
|
361
|
+
assertHighlighterType(type);
|
|
362
|
+
activeType = type;
|
|
363
|
+
holds++;
|
|
364
|
+
}
|
|
365
|
+
function releaseHighlighterType() {
|
|
366
|
+
holds--;
|
|
367
|
+
if (holds === 0) activeType = void 0;
|
|
368
|
+
}
|
|
369
|
+
async function createHighlighter(type) {
|
|
370
|
+
const resolvedType = resolveHighlighterType(type);
|
|
371
|
+
acquireHighlighterType(resolvedType);
|
|
372
|
+
try {
|
|
373
|
+
if (resolvedType === "highlights") {
|
|
374
|
+
const { HighlightsHighlighter } = await import("./highlights-CpZm9DAR-DaBE50nC.js");
|
|
375
|
+
return new HighlightsHighlighter();
|
|
376
|
+
}
|
|
377
|
+
const { ShikiHighlighter } = await import("./shiki-Ci4cdHsM-C6d-uTVf.js");
|
|
378
|
+
return await ShikiHighlighter.create(resolvedType);
|
|
379
|
+
} finally {
|
|
380
|
+
releaseHighlighterType();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function attachResolvedThemes(themes, highlighter2) {
|
|
384
|
+
for (const theme of Array.isArray(themes) ? themes : [themes]) {
|
|
385
|
+
const resolved = typeof theme === "string" ? highlighter2.themeResolver.getResolvedThemes([theme])[0] : theme;
|
|
386
|
+
highlighter2.themeResolver.seedResolvedTheme(resolved.name, resolved);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const CUSTOM_EXTENSION_TO_FILE_FORMAT = /* @__PURE__ */ new Map();
|
|
390
|
+
let customExtensionsVersion = 0;
|
|
391
|
+
const EXTENSION_TO_FILE_FORMAT = {
|
|
392
|
+
"1c": "1c",
|
|
393
|
+
abap: "abap",
|
|
394
|
+
as: "actionscript-3",
|
|
395
|
+
ada: "ada",
|
|
396
|
+
adb: "ada",
|
|
397
|
+
ads: "ada",
|
|
398
|
+
adoc: "asciidoc",
|
|
399
|
+
asciidoc: "asciidoc",
|
|
400
|
+
"component.html": "angular-html",
|
|
401
|
+
"component.ts": "angular-ts",
|
|
402
|
+
conf: "nginx",
|
|
403
|
+
htaccess: "apache",
|
|
404
|
+
cls: "tex",
|
|
405
|
+
trigger: "apex",
|
|
406
|
+
apl: "apl",
|
|
407
|
+
applescript: "applescript",
|
|
408
|
+
scpt: "applescript",
|
|
409
|
+
ara: "ara",
|
|
410
|
+
asm: "asm",
|
|
411
|
+
s: "riscv",
|
|
412
|
+
astro: "astro",
|
|
413
|
+
awk: "awk",
|
|
414
|
+
bal: "ballerina",
|
|
415
|
+
sh: "zsh",
|
|
416
|
+
bash: "zsh",
|
|
417
|
+
bat: "cmd",
|
|
418
|
+
cmd: "cmd",
|
|
419
|
+
be: "berry",
|
|
420
|
+
beancount: "beancount",
|
|
421
|
+
bib: "bibtex",
|
|
422
|
+
bicep: "bicep",
|
|
423
|
+
"blade.php": "blade",
|
|
424
|
+
bsl: "bsl",
|
|
425
|
+
c: "c",
|
|
426
|
+
h: "objective-cpp",
|
|
427
|
+
cs: "csharp",
|
|
428
|
+
cpp: "cpp",
|
|
429
|
+
hpp: "cpp",
|
|
430
|
+
cc: "cpp",
|
|
431
|
+
cxx: "cpp",
|
|
432
|
+
hh: "cpp",
|
|
433
|
+
cdc: "cdc",
|
|
434
|
+
cairo: "cairo",
|
|
435
|
+
clar: "clarity",
|
|
436
|
+
clj: "clojure",
|
|
437
|
+
cljs: "clojure",
|
|
438
|
+
cljc: "clojure",
|
|
439
|
+
soy: "soy",
|
|
440
|
+
cmake: "cmake",
|
|
441
|
+
"CMakeLists.txt": "cmake",
|
|
442
|
+
cob: "cobol",
|
|
443
|
+
cbl: "cobol",
|
|
444
|
+
cobol: "cobol",
|
|
445
|
+
CODEOWNERS: "codeowners",
|
|
446
|
+
ql: "ql",
|
|
447
|
+
coffee: "coffeescript",
|
|
448
|
+
lisp: "lisp",
|
|
449
|
+
cl: "lisp",
|
|
450
|
+
lsp: "lisp",
|
|
451
|
+
log: "log",
|
|
452
|
+
v: "verilog",
|
|
453
|
+
cql: "cql",
|
|
454
|
+
cr: "crystal",
|
|
455
|
+
css: "css",
|
|
456
|
+
csv: "csv",
|
|
457
|
+
cue: "cue",
|
|
458
|
+
cypher: "cypher",
|
|
459
|
+
cyp: "cypher",
|
|
460
|
+
d: "d",
|
|
461
|
+
dart: "dart",
|
|
462
|
+
dax: "dax",
|
|
463
|
+
desktop: "desktop",
|
|
464
|
+
diff: "diff",
|
|
465
|
+
patch: "diff",
|
|
466
|
+
Dockerfile: "dockerfile",
|
|
467
|
+
dockerfile: "dockerfile",
|
|
468
|
+
env: "dotenv",
|
|
469
|
+
dm: "dream-maker",
|
|
470
|
+
edge: "edge",
|
|
471
|
+
el: "emacs-lisp",
|
|
472
|
+
ex: "elixir",
|
|
473
|
+
exs: "elixir",
|
|
474
|
+
elm: "elm",
|
|
475
|
+
erb: "erb",
|
|
476
|
+
erl: "erlang",
|
|
477
|
+
hrl: "erlang",
|
|
478
|
+
f: "fortran-fixed-form",
|
|
479
|
+
for: "fortran-fixed-form",
|
|
480
|
+
fs: "fsharp",
|
|
481
|
+
fsi: "fsharp",
|
|
482
|
+
fsx: "fsharp",
|
|
483
|
+
f03: "f03",
|
|
484
|
+
f08: "f08",
|
|
485
|
+
f18: "f18",
|
|
486
|
+
f77: "f77",
|
|
487
|
+
f90: "fortran-free-form",
|
|
488
|
+
f95: "fortran-free-form",
|
|
489
|
+
fnl: "fennel",
|
|
490
|
+
fish: "fish",
|
|
491
|
+
ftl: "ftl",
|
|
492
|
+
tres: "gdresource",
|
|
493
|
+
res: "gdresource",
|
|
494
|
+
gd: "gdscript",
|
|
495
|
+
gdshader: "gdshader",
|
|
496
|
+
gs: "genie",
|
|
497
|
+
feature: "gherkin",
|
|
498
|
+
COMMIT_EDITMSG: "git-commit",
|
|
499
|
+
"git-rebase-todo": "git-rebase",
|
|
500
|
+
gjs: "glimmer-js",
|
|
501
|
+
gleam: "gleam",
|
|
502
|
+
gts: "glimmer-ts",
|
|
503
|
+
glsl: "glsl",
|
|
504
|
+
vert: "glsl",
|
|
505
|
+
frag: "glsl",
|
|
506
|
+
shader: "shaderlab",
|
|
507
|
+
gp: "gnuplot",
|
|
508
|
+
plt: "gnuplot",
|
|
509
|
+
gnuplot: "gnuplot",
|
|
510
|
+
go: "go",
|
|
511
|
+
graphql: "graphql",
|
|
512
|
+
gql: "graphql",
|
|
513
|
+
groovy: "groovy",
|
|
514
|
+
gvy: "groovy",
|
|
515
|
+
hack: "hack",
|
|
516
|
+
haml: "haml",
|
|
517
|
+
hbs: "handlebars",
|
|
518
|
+
handlebars: "handlebars",
|
|
519
|
+
hs: "haskell",
|
|
520
|
+
lhs: "haskell",
|
|
521
|
+
hx: "haxe",
|
|
522
|
+
hcl: "hcl",
|
|
523
|
+
hjson: "hjson",
|
|
524
|
+
hlsl: "hlsl",
|
|
525
|
+
fx: "hlsl",
|
|
526
|
+
html: "html",
|
|
527
|
+
htm: "html",
|
|
528
|
+
http: "http",
|
|
529
|
+
rest: "http",
|
|
530
|
+
hxml: "hxml",
|
|
531
|
+
hy: "hy",
|
|
532
|
+
imba: "imba",
|
|
533
|
+
ini: "ini",
|
|
534
|
+
cfg: "ini",
|
|
535
|
+
jade: "pug",
|
|
536
|
+
pug: "pug",
|
|
537
|
+
java: "java",
|
|
538
|
+
js: "javascript",
|
|
539
|
+
mjs: "javascript",
|
|
540
|
+
cjs: "javascript",
|
|
541
|
+
jinja: "jinja",
|
|
542
|
+
jinja2: "jinja",
|
|
543
|
+
j2: "jinja",
|
|
544
|
+
jison: "jison",
|
|
545
|
+
jl: "julia",
|
|
546
|
+
json: "json",
|
|
547
|
+
json5: "json5",
|
|
548
|
+
jsonc: "jsonc",
|
|
549
|
+
jsonl: "jsonl",
|
|
550
|
+
jsonnet: "jsonnet",
|
|
551
|
+
libsonnet: "jsonnet",
|
|
552
|
+
jssm: "jssm",
|
|
553
|
+
jsx: "jsx",
|
|
554
|
+
kt: "kotlin",
|
|
555
|
+
kts: "kts",
|
|
556
|
+
kql: "kusto",
|
|
557
|
+
tex: "tex",
|
|
558
|
+
ltx: "tex",
|
|
559
|
+
lean: "lean4",
|
|
560
|
+
less: "less",
|
|
561
|
+
liquid: "liquid",
|
|
562
|
+
lit: "lit",
|
|
563
|
+
ll: "llvm",
|
|
564
|
+
logo: "logo",
|
|
565
|
+
lua: "lua",
|
|
566
|
+
luau: "luau",
|
|
567
|
+
Makefile: "makefile",
|
|
568
|
+
mk: "makefile",
|
|
569
|
+
makefile: "makefile",
|
|
570
|
+
md: "markdown",
|
|
571
|
+
markdown: "markdown",
|
|
572
|
+
marko: "marko",
|
|
573
|
+
m: "wolfram",
|
|
574
|
+
mat: "matlab",
|
|
575
|
+
mdc: "mdc",
|
|
576
|
+
mdx: "mdx",
|
|
577
|
+
wiki: "wikitext",
|
|
578
|
+
mediawiki: "wikitext",
|
|
579
|
+
mmd: "mermaid",
|
|
580
|
+
mermaid: "mermaid",
|
|
581
|
+
mips: "mipsasm",
|
|
582
|
+
mojo: "mojo",
|
|
583
|
+
"🔥": "mojo",
|
|
584
|
+
move: "move",
|
|
585
|
+
nar: "narrat",
|
|
586
|
+
nf: "nextflow",
|
|
587
|
+
nim: "nim",
|
|
588
|
+
nims: "nim",
|
|
589
|
+
nimble: "nim",
|
|
590
|
+
nix: "nix",
|
|
591
|
+
nu: "nushell",
|
|
592
|
+
mm: "objective-cpp",
|
|
593
|
+
ml: "ocaml",
|
|
594
|
+
mli: "ocaml",
|
|
595
|
+
mll: "ocaml",
|
|
596
|
+
mly: "ocaml",
|
|
597
|
+
odin: "odin",
|
|
598
|
+
pas: "pascal",
|
|
599
|
+
p: "pascal",
|
|
600
|
+
pl: "prolog",
|
|
601
|
+
pm: "perl",
|
|
602
|
+
t: "perl",
|
|
603
|
+
raku: "raku",
|
|
604
|
+
p6: "raku",
|
|
605
|
+
pl6: "raku",
|
|
606
|
+
php: "php",
|
|
607
|
+
phtml: "php",
|
|
608
|
+
pls: "plsql",
|
|
609
|
+
sql: "sql",
|
|
610
|
+
po: "po",
|
|
611
|
+
polar: "polar",
|
|
612
|
+
pcss: "postcss",
|
|
613
|
+
pot: "pot",
|
|
614
|
+
potx: "potx",
|
|
615
|
+
pq: "powerquery",
|
|
616
|
+
pqm: "powerquery",
|
|
617
|
+
ps1: "powershell",
|
|
618
|
+
psm1: "powershell",
|
|
619
|
+
psd1: "powershell",
|
|
620
|
+
prisma: "prisma",
|
|
621
|
+
pro: "prolog",
|
|
622
|
+
P: "prolog",
|
|
623
|
+
properties: "properties",
|
|
624
|
+
proto: "protobuf",
|
|
625
|
+
pp: "puppet",
|
|
626
|
+
purs: "purescript",
|
|
627
|
+
py: "python",
|
|
628
|
+
pyw: "python",
|
|
629
|
+
pyi: "python",
|
|
630
|
+
BUCK: "python",
|
|
631
|
+
BUILD: "python",
|
|
632
|
+
PACKAGE: "python",
|
|
633
|
+
WORKSPACE: "python",
|
|
634
|
+
Tiltfile: "python",
|
|
635
|
+
bazel: "python",
|
|
636
|
+
bxl: "python",
|
|
637
|
+
bzl: "python",
|
|
638
|
+
bzlmod: "python",
|
|
639
|
+
star: "python",
|
|
640
|
+
sky: "python",
|
|
641
|
+
qml: "qml",
|
|
642
|
+
qmldir: "qmldir",
|
|
643
|
+
qss: "qss",
|
|
644
|
+
r: "r",
|
|
645
|
+
R: "r",
|
|
646
|
+
rkt: "racket",
|
|
647
|
+
rktl: "racket",
|
|
648
|
+
razor: "razor",
|
|
649
|
+
cshtml: "razor",
|
|
650
|
+
rb: "ruby",
|
|
651
|
+
rbw: "ruby",
|
|
652
|
+
reg: "reg",
|
|
653
|
+
regex: "regexp",
|
|
654
|
+
rel: "rel",
|
|
655
|
+
rs: "rust",
|
|
656
|
+
rst: "rst",
|
|
657
|
+
rake: "ruby",
|
|
658
|
+
gemspec: "ruby",
|
|
659
|
+
jbuilder: "ruby",
|
|
660
|
+
builder: "ruby",
|
|
661
|
+
rabl: "ruby",
|
|
662
|
+
arb: "ruby",
|
|
663
|
+
ru: "ruby",
|
|
664
|
+
podspec: "ruby",
|
|
665
|
+
Gemfile: "ruby",
|
|
666
|
+
Rakefile: "ruby",
|
|
667
|
+
Guardfile: "ruby",
|
|
668
|
+
Capfile: "ruby",
|
|
669
|
+
Berksfile: "ruby",
|
|
670
|
+
Brewfile: "ruby",
|
|
671
|
+
Vagrantfile: "ruby",
|
|
672
|
+
Thorfile: "ruby",
|
|
673
|
+
Appraisals: "ruby",
|
|
674
|
+
Dangerfile: "ruby",
|
|
675
|
+
sas: "sas",
|
|
676
|
+
sass: "sass",
|
|
677
|
+
scala: "scala",
|
|
678
|
+
sc: "scala",
|
|
679
|
+
scm: "scheme",
|
|
680
|
+
ss: "scheme",
|
|
681
|
+
sld: "scheme",
|
|
682
|
+
scss: "scss",
|
|
683
|
+
sdbl: "sdbl",
|
|
684
|
+
shadergraph: "shader",
|
|
685
|
+
st: "smalltalk",
|
|
686
|
+
sol: "solidity",
|
|
687
|
+
sparql: "sparql",
|
|
688
|
+
rq: "sparql",
|
|
689
|
+
spl: "splunk",
|
|
690
|
+
config: "ssh-config",
|
|
691
|
+
do: "stata",
|
|
692
|
+
ado: "stata",
|
|
693
|
+
dta: "stata",
|
|
694
|
+
styl: "stylus",
|
|
695
|
+
stylus: "stylus",
|
|
696
|
+
svelte: "svelte",
|
|
697
|
+
swift: "swift",
|
|
698
|
+
sv: "system-verilog",
|
|
699
|
+
svh: "system-verilog",
|
|
700
|
+
service: "systemd",
|
|
701
|
+
socket: "systemd",
|
|
702
|
+
device: "systemd",
|
|
703
|
+
timer: "systemd",
|
|
704
|
+
talon: "talonscript",
|
|
705
|
+
tasl: "tasl",
|
|
706
|
+
tcl: "tcl",
|
|
707
|
+
templ: "templ",
|
|
708
|
+
tf: "tf",
|
|
709
|
+
tfvars: "tfvars",
|
|
710
|
+
toml: "toml",
|
|
711
|
+
ts: "typescript",
|
|
712
|
+
mts: "typescript",
|
|
713
|
+
cts: "typescript",
|
|
714
|
+
tsp: "typespec",
|
|
715
|
+
tsv: "tsv",
|
|
716
|
+
tsx: "tsx",
|
|
717
|
+
ttl: "turtle",
|
|
718
|
+
twig: "twig",
|
|
719
|
+
typ: "typst",
|
|
720
|
+
vv: "v",
|
|
721
|
+
vala: "vala",
|
|
722
|
+
vapi: "vala",
|
|
723
|
+
vb: "vb",
|
|
724
|
+
vbs: "vb",
|
|
725
|
+
bas: "vb",
|
|
726
|
+
vh: "verilog",
|
|
727
|
+
vhd: "vhdl",
|
|
728
|
+
vhdl: "vhdl",
|
|
729
|
+
vim: "vimscript",
|
|
730
|
+
vue: "vue",
|
|
731
|
+
"vine.ts": "vue-vine",
|
|
732
|
+
vy: "vyper",
|
|
733
|
+
wasm: "wasm",
|
|
734
|
+
wat: "wasm",
|
|
735
|
+
wy: "文言",
|
|
736
|
+
wgsl: "wgsl",
|
|
737
|
+
wit: "wit",
|
|
738
|
+
wl: "wolfram",
|
|
739
|
+
nb: "wolfram",
|
|
740
|
+
xml: "xml",
|
|
741
|
+
xsl: "xsl",
|
|
742
|
+
xslt: "xsl",
|
|
743
|
+
yaml: "yaml",
|
|
744
|
+
yml: "yml",
|
|
745
|
+
zs: "zenscript",
|
|
746
|
+
zig: "zig",
|
|
747
|
+
zsh: "zsh",
|
|
748
|
+
sty: "tex"
|
|
749
|
+
};
|
|
750
|
+
function getFiletypeFromFileName(fileName) {
|
|
751
|
+
const format = matchFiletypeFromName(fileName);
|
|
752
|
+
if (format != null) return format;
|
|
753
|
+
const baseName = fileName.split(/[/\\]/).pop() ?? fileName;
|
|
754
|
+
return baseName === fileName ? "text" : matchFiletypeFromName(baseName) ?? "text";
|
|
755
|
+
}
|
|
756
|
+
function matchFiletypeFromName(fileName) {
|
|
757
|
+
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(fileName)) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(fileName) ?? "text";
|
|
758
|
+
if (Object.hasOwn(EXTENSION_TO_FILE_FORMAT, fileName)) return EXTENSION_TO_FILE_FORMAT[fileName] ?? null;
|
|
759
|
+
const compoundMatch = fileName.match(/\.([^/\\]+\.[^/\\]+)$/);
|
|
760
|
+
if (compoundMatch != null) {
|
|
761
|
+
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(compoundMatch[1])) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(compoundMatch[1]) ?? "text";
|
|
762
|
+
if (Object.hasOwn(EXTENSION_TO_FILE_FORMAT, compoundMatch[1])) return EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] ?? "text";
|
|
763
|
+
}
|
|
764
|
+
const simpleMatch = fileName.match(/\.([^.]+)$/)?.[1] ?? "";
|
|
765
|
+
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(simpleMatch)) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(simpleMatch) ?? "text";
|
|
766
|
+
return Object.hasOwn(EXTENSION_TO_FILE_FORMAT, simpleMatch) ? EXTENSION_TO_FILE_FORMAT[simpleMatch] ?? "text" : null;
|
|
767
|
+
}
|
|
768
|
+
function replaceCustomExtensions(version, map) {
|
|
769
|
+
if (version <= customExtensionsVersion) return false;
|
|
770
|
+
CUSTOM_EXTENSION_TO_FILE_FORMAT.clear();
|
|
771
|
+
for (const key in map) {
|
|
772
|
+
const lang = map[key];
|
|
773
|
+
if (lang != null) CUSTOM_EXTENSION_TO_FILE_FORMAT.set(key, lang);
|
|
774
|
+
}
|
|
775
|
+
customExtensionsVersion = version;
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
function appendItems(target, items) {
|
|
779
|
+
for (const item of items) target.push(item);
|
|
780
|
+
}
|
|
781
|
+
function cleanLastNewline(contents) {
|
|
782
|
+
let end = contents.length;
|
|
783
|
+
if (contents.charCodeAt(end - 1) === 10) {
|
|
784
|
+
end--;
|
|
785
|
+
if (contents.charCodeAt(end - 1) === 13) end--;
|
|
786
|
+
}
|
|
787
|
+
return contents.slice(0, end);
|
|
788
|
+
}
|
|
789
|
+
function formatCSSVariablePrefix(type) {
|
|
790
|
+
return `--${type === "token" ? "diffs-token" : "diffs"}-`;
|
|
791
|
+
}
|
|
792
|
+
function getHighlighterThemeStyles({ theme = DEFAULT_THEMES, highlighter: highlighter2, prefix }) {
|
|
793
|
+
let styles = "";
|
|
794
|
+
if (typeof theme === "string") {
|
|
795
|
+
const themeData = highlighter2.getTheme(theme);
|
|
796
|
+
const normalized = getThemeColors(themeData, highlighter2);
|
|
797
|
+
styles += `color:${normalized.fg};`;
|
|
798
|
+
styles += `background-color:${normalized.bg};`;
|
|
799
|
+
styles += `${formatCSSVariablePrefix("global")}fg:${normalized.fg};`;
|
|
800
|
+
styles += `${formatCSSVariablePrefix("global")}bg:${normalized.bg};`;
|
|
801
|
+
styles += getGitVariables(themeData, prefix);
|
|
802
|
+
} else {
|
|
803
|
+
let themeData = highlighter2.getTheme(theme.dark);
|
|
804
|
+
let normalized = getThemeColors(themeData, highlighter2);
|
|
805
|
+
styles += `${formatCSSVariablePrefix("global")}dark:${normalized.fg};`;
|
|
806
|
+
styles += `${formatCSSVariablePrefix("global")}dark-bg:${normalized.bg};`;
|
|
807
|
+
styles += getGitVariables(themeData, "dark");
|
|
808
|
+
themeData = highlighter2.getTheme(theme.light);
|
|
809
|
+
normalized = getThemeColors(themeData, highlighter2);
|
|
810
|
+
styles += `${formatCSSVariablePrefix("global")}light:${normalized.fg};`;
|
|
811
|
+
styles += `${formatCSSVariablePrefix("global")}light-bg:${normalized.bg};`;
|
|
812
|
+
styles += getGitVariables(themeData, "light");
|
|
813
|
+
}
|
|
814
|
+
return styles;
|
|
815
|
+
}
|
|
816
|
+
function getThemeColors(theme, highlighter2) {
|
|
817
|
+
if (highlighter2.name === "highlights" && theme.zed?.cssVariables === true) {
|
|
818
|
+
const prefix = formatCSSVariablePrefix("token");
|
|
819
|
+
return {
|
|
820
|
+
fg: `var(${prefix}foreground)`,
|
|
821
|
+
bg: `var(${prefix}background)`
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
return normalizeThemeColors(theme);
|
|
825
|
+
}
|
|
826
|
+
function getGitVariables(themeData, modePrefix) {
|
|
827
|
+
modePrefix = modePrefix != null ? `${modePrefix}-` : "";
|
|
828
|
+
let styles = "";
|
|
829
|
+
const additionGreen = themeData.colors?.["gitDecoration.addedResourceForeground"] ?? themeData.colors?.["terminal.ansiGreen"];
|
|
830
|
+
if (additionGreen != null) styles += `${formatCSSVariablePrefix("global")}${modePrefix}addition-color:${additionGreen};`;
|
|
831
|
+
const deletionRed = themeData.colors?.["gitDecoration.deletedResourceForeground"] ?? themeData.colors?.["terminal.ansiRed"];
|
|
832
|
+
if (deletionRed != null) styles += `${formatCSSVariablePrefix("global")}${modePrefix}deletion-color:${deletionRed};`;
|
|
833
|
+
const modifiedBlue = themeData.colors?.["gitDecoration.modifiedResourceForeground"] ?? themeData.colors?.["terminal.ansiBlue"];
|
|
834
|
+
if (modifiedBlue != null) styles += `${formatCSSVariablePrefix("global")}${modePrefix}modified-color:${modifiedBlue};`;
|
|
835
|
+
return styles;
|
|
836
|
+
}
|
|
837
|
+
function getTokenOptions(lang, theme, tokenizeMaxLineLength) {
|
|
838
|
+
return {
|
|
839
|
+
lang,
|
|
840
|
+
...typeof theme === "string" ? { theme } : { themes: theme },
|
|
841
|
+
defaultColor: false,
|
|
842
|
+
cssVariablePrefix: formatCSSVariablePrefix("token"),
|
|
843
|
+
tokenizeMaxLineLength,
|
|
844
|
+
tokenizeTimeLimit: 0
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function getHunkSideStartBoundary(start, count) {
|
|
848
|
+
return start - (count === 0 ? 0 : 1);
|
|
849
|
+
}
|
|
850
|
+
function getHunkSideEndBoundary(start, count) {
|
|
851
|
+
return getHunkSideStartBoundary(start, count) + count;
|
|
852
|
+
}
|
|
853
|
+
function getExpandedRegion({ isPartial, rangeSize, expandedHunks, hunkIndex, collapsedContextThreshold }) {
|
|
854
|
+
const normalizedRangeSize = Math.max(rangeSize, 0);
|
|
855
|
+
if (normalizedRangeSize === 0 || isPartial) return {
|
|
856
|
+
fromStart: 0,
|
|
857
|
+
fromEnd: 0,
|
|
858
|
+
rangeSize: normalizedRangeSize,
|
|
859
|
+
collapsedLines: normalizedRangeSize,
|
|
860
|
+
renderAll: false
|
|
861
|
+
};
|
|
862
|
+
if (expandedHunks === true || normalizedRangeSize <= collapsedContextThreshold) return {
|
|
863
|
+
fromStart: normalizedRangeSize,
|
|
864
|
+
fromEnd: 0,
|
|
865
|
+
rangeSize: normalizedRangeSize,
|
|
866
|
+
collapsedLines: 0,
|
|
867
|
+
renderAll: true
|
|
868
|
+
};
|
|
869
|
+
const region = expandedHunks?.get(hunkIndex);
|
|
870
|
+
const fromStart = Math.min(Math.max(region?.fromStart ?? 0, 0), normalizedRangeSize);
|
|
871
|
+
const fromEnd = Math.min(Math.max(region?.fromEnd ?? 0, 0), normalizedRangeSize);
|
|
872
|
+
const expandedCount = fromStart + fromEnd;
|
|
873
|
+
const renderAll = expandedCount >= normalizedRangeSize;
|
|
874
|
+
return {
|
|
875
|
+
fromStart: renderAll ? normalizedRangeSize : fromStart,
|
|
876
|
+
fromEnd: renderAll ? 0 : fromEnd,
|
|
877
|
+
rangeSize: normalizedRangeSize,
|
|
878
|
+
collapsedLines: Math.max(normalizedRangeSize - expandedCount, 0),
|
|
879
|
+
renderAll
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
function getTrailingContextRangeSize({ fileDiff, errorPrefix }) {
|
|
883
|
+
const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
|
|
884
|
+
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
|
|
885
|
+
const additionRemaining = fileDiff.additionLines.length - getHunkSideEndBoundary(lastHunk.additionStart, lastHunk.additionCount);
|
|
886
|
+
const deletionRemaining = fileDiff.deletionLines.length - getHunkSideEndBoundary(lastHunk.deletionStart, lastHunk.deletionCount);
|
|
887
|
+
if (additionRemaining <= 0 && deletionRemaining <= 0) return 0;
|
|
888
|
+
if (additionRemaining !== deletionRemaining) throw new Error(`${errorPrefix}: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
|
|
889
|
+
return Math.min(additionRemaining, deletionRemaining);
|
|
890
|
+
}
|
|
891
|
+
function getTrailingExpandedRegion({ fileDiff, hunkIndex, expandedHunks, collapsedContextThreshold, errorPrefix }) {
|
|
892
|
+
if (hunkIndex !== fileDiff.hunks.length - 1) return;
|
|
893
|
+
const trailingRangeSize = getTrailingContextRangeSize({
|
|
894
|
+
fileDiff,
|
|
895
|
+
errorPrefix
|
|
896
|
+
});
|
|
897
|
+
if (trailingRangeSize <= 0) return;
|
|
898
|
+
if (expandedHunks === true || trailingRangeSize <= collapsedContextThreshold) return {
|
|
899
|
+
fromStart: trailingRangeSize,
|
|
900
|
+
fromEnd: 0,
|
|
901
|
+
rangeSize: trailingRangeSize,
|
|
902
|
+
collapsedLines: 0,
|
|
903
|
+
renderAll: true
|
|
904
|
+
};
|
|
905
|
+
const region = expandedHunks?.get(fileDiff.hunks.length);
|
|
906
|
+
const fromStart = Math.min(Math.max(region?.fromStart ?? 0, 0), trailingRangeSize);
|
|
907
|
+
return {
|
|
908
|
+
fromStart,
|
|
909
|
+
fromEnd: 0,
|
|
910
|
+
rangeSize: trailingRangeSize,
|
|
911
|
+
collapsedLines: trailingRangeSize - fromStart,
|
|
912
|
+
renderAll: fromStart >= trailingRangeSize
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infinity, expandedHunks, collapsedContextThreshold = 1, callback }) {
|
|
916
|
+
const iterationStart = getIterationStartState({
|
|
917
|
+
diff,
|
|
918
|
+
diffStyle,
|
|
919
|
+
startingLine,
|
|
920
|
+
expandedHunks,
|
|
921
|
+
collapsedContextThreshold
|
|
922
|
+
});
|
|
923
|
+
const state = {
|
|
924
|
+
viewportStart: startingLine,
|
|
925
|
+
viewportEnd: startingLine + totalLines,
|
|
926
|
+
isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
|
|
927
|
+
splitCount: iterationStart.splitCount,
|
|
928
|
+
unifiedCount: iterationStart.unifiedCount,
|
|
929
|
+
finalHunkIndex: diff.hunks.length - 1,
|
|
930
|
+
shouldBreak() {
|
|
931
|
+
if (!state.isWindowedHighlight) return false;
|
|
932
|
+
const breakUnified = state.unifiedCount >= startingLine + totalLines;
|
|
933
|
+
const breakSplit = state.splitCount >= startingLine + totalLines;
|
|
934
|
+
return breakUnified && breakSplit;
|
|
935
|
+
},
|
|
936
|
+
shouldSkip(unifiedCount, splitCount) {
|
|
937
|
+
if (!state.isWindowedHighlight) return false;
|
|
938
|
+
const skipUnified = unifiedCount > 0 && state.unifiedCount + unifiedCount <= startingLine;
|
|
939
|
+
const skipSplit = splitCount > 0 && state.splitCount + splitCount <= startingLine;
|
|
940
|
+
return skipUnified && skipSplit;
|
|
941
|
+
},
|
|
942
|
+
incrementCounts(unifiedValue, splitValue) {
|
|
943
|
+
state.unifiedCount += unifiedValue;
|
|
944
|
+
state.splitCount += splitValue;
|
|
945
|
+
},
|
|
946
|
+
isInWindow(unifiedHeight, splitHeight) {
|
|
947
|
+
if (!state.isWindowedHighlight) return true;
|
|
948
|
+
const unifiedInWindow = state.isInUnifiedWindow(unifiedHeight);
|
|
949
|
+
const splitInWindow = state.isInSplitWindow(splitHeight);
|
|
950
|
+
return unifiedInWindow || splitInWindow;
|
|
951
|
+
},
|
|
952
|
+
isInUnifiedWindow(unifiedHeight) {
|
|
953
|
+
return !state.isWindowedHighlight || state.unifiedCount >= startingLine - unifiedHeight && state.unifiedCount < startingLine + totalLines;
|
|
954
|
+
},
|
|
955
|
+
isInSplitWindow(splitHeight) {
|
|
956
|
+
return !state.isWindowedHighlight || state.splitCount >= startingLine - splitHeight && state.splitCount < startingLine + totalLines;
|
|
957
|
+
},
|
|
958
|
+
emit(props, silent = false) {
|
|
959
|
+
if (!silent) {
|
|
960
|
+
state.incrementCounts(1, 1);
|
|
961
|
+
}
|
|
962
|
+
return callback(props) ?? false;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
hunkIterator: for (let hunkIndex = iterationStart.hunkIndex; hunkIndex < diff.hunks.length; hunkIndex++) {
|
|
966
|
+
let getTrailingCollapsedAfter = function(unifiedLineIndex2, splitLineIndex2) {
|
|
967
|
+
if (trailingRegion == null || trailingRegion.collapsedLines <= 0 || trailingRegion.fromStart + trailingRegion.fromEnd > 0) return 0;
|
|
968
|
+
return splitLineIndex2 === hunk.splitLineStart + hunk.splitLineCount - 1 ? trailingRegion.collapsedLines : 0;
|
|
969
|
+
}, consumePendingCollapsed = function() {
|
|
970
|
+
if (consumedCollapsed) return 0;
|
|
971
|
+
consumedCollapsed = true;
|
|
972
|
+
return leadingRegion.collapsedLines;
|
|
973
|
+
};
|
|
974
|
+
const hunk = diff.hunks[hunkIndex];
|
|
975
|
+
if (hunk == null) throw new Error("iterateOverDiff: invalid hunk index");
|
|
976
|
+
if (state.shouldBreak()) break;
|
|
977
|
+
const deletionBoundary = getHunkSideStartBoundary(hunk.deletionStart, hunk.deletionCount);
|
|
978
|
+
const additionBoundary = getHunkSideStartBoundary(hunk.additionStart, hunk.additionCount);
|
|
979
|
+
const deletionStartIndex = !diff.isPartial && hunk.deletionCount === 0 ? deletionBoundary : hunk.deletionLineIndex;
|
|
980
|
+
const additionStartIndex = !diff.isPartial && hunk.additionCount === 0 ? additionBoundary : hunk.additionLineIndex;
|
|
981
|
+
const leadingRegion = getExpandedRegion({
|
|
982
|
+
isPartial: diff.isPartial,
|
|
983
|
+
rangeSize: hunk.collapsedBefore,
|
|
984
|
+
expandedHunks,
|
|
985
|
+
hunkIndex,
|
|
986
|
+
collapsedContextThreshold
|
|
987
|
+
});
|
|
988
|
+
const trailingRegion = hunkIndex === state.finalHunkIndex ? getTrailingExpandedRegion({
|
|
989
|
+
fileDiff: diff,
|
|
990
|
+
hunkIndex,
|
|
991
|
+
expandedHunks,
|
|
992
|
+
collapsedContextThreshold,
|
|
993
|
+
errorPrefix: "iterateOverDiff"
|
|
994
|
+
}) : void 0;
|
|
995
|
+
const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
996
|
+
let consumedCollapsed = leadingRegion.collapsedLines === 0;
|
|
997
|
+
if (!state.shouldSkip(expandedLineCount, expandedLineCount)) {
|
|
998
|
+
let unifiedLineIndex2 = hunk.unifiedLineStart - leadingRegion.rangeSize;
|
|
999
|
+
let splitLineIndex2 = hunk.splitLineStart - leadingRegion.rangeSize;
|
|
1000
|
+
let deletionLineIndex2 = deletionStartIndex - leadingRegion.rangeSize;
|
|
1001
|
+
let additionLineIndex2 = additionStartIndex - leadingRegion.rangeSize;
|
|
1002
|
+
let deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.rangeSize;
|
|
1003
|
+
let additionLineNumber2 = additionBoundary + 1 - leadingRegion.rangeSize;
|
|
1004
|
+
if (walkContextLines(state, leadingRegion.fromStart, diffStyle, (index) => {
|
|
1005
|
+
return state.emit({
|
|
1006
|
+
hunkIndex,
|
|
1007
|
+
hunk,
|
|
1008
|
+
collapsedBefore: 0,
|
|
1009
|
+
collapsedAfter: 0,
|
|
1010
|
+
type: "context-expanded",
|
|
1011
|
+
deletionLine: {
|
|
1012
|
+
lineNumber: deletionLineNumber2 + index,
|
|
1013
|
+
lineIndex: deletionLineIndex2 + index,
|
|
1014
|
+
noEOFCR: false,
|
|
1015
|
+
unifiedLineIndex: unifiedLineIndex2 + index,
|
|
1016
|
+
splitLineIndex: splitLineIndex2 + index
|
|
1017
|
+
},
|
|
1018
|
+
additionLine: {
|
|
1019
|
+
unifiedLineIndex: unifiedLineIndex2 + index,
|
|
1020
|
+
splitLineIndex: splitLineIndex2 + index,
|
|
1021
|
+
lineIndex: additionLineIndex2 + index,
|
|
1022
|
+
lineNumber: additionLineNumber2 + index,
|
|
1023
|
+
noEOFCR: false
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
})) break hunkIterator;
|
|
1027
|
+
unifiedLineIndex2 = hunk.unifiedLineStart - leadingRegion.fromEnd;
|
|
1028
|
+
splitLineIndex2 = hunk.splitLineStart - leadingRegion.fromEnd;
|
|
1029
|
+
deletionLineIndex2 = deletionStartIndex - leadingRegion.fromEnd;
|
|
1030
|
+
additionLineIndex2 = additionStartIndex - leadingRegion.fromEnd;
|
|
1031
|
+
deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.fromEnd;
|
|
1032
|
+
additionLineNumber2 = additionBoundary + 1 - leadingRegion.fromEnd;
|
|
1033
|
+
if (walkContextLines(state, leadingRegion.fromEnd, diffStyle, (index) => {
|
|
1034
|
+
return state.emit({
|
|
1035
|
+
hunkIndex,
|
|
1036
|
+
hunk,
|
|
1037
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
1038
|
+
collapsedAfter: 0,
|
|
1039
|
+
type: "context-expanded",
|
|
1040
|
+
deletionLine: {
|
|
1041
|
+
lineNumber: deletionLineNumber2 + index,
|
|
1042
|
+
lineIndex: deletionLineIndex2 + index,
|
|
1043
|
+
noEOFCR: false,
|
|
1044
|
+
unifiedLineIndex: unifiedLineIndex2 + index,
|
|
1045
|
+
splitLineIndex: splitLineIndex2 + index
|
|
1046
|
+
},
|
|
1047
|
+
additionLine: {
|
|
1048
|
+
unifiedLineIndex: unifiedLineIndex2 + index,
|
|
1049
|
+
splitLineIndex: splitLineIndex2 + index,
|
|
1050
|
+
lineIndex: additionLineIndex2 + index,
|
|
1051
|
+
lineNumber: additionLineNumber2 + index,
|
|
1052
|
+
noEOFCR: false
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
}, () => {
|
|
1056
|
+
consumePendingCollapsed();
|
|
1057
|
+
})) break hunkIterator;
|
|
1058
|
+
} else {
|
|
1059
|
+
state.incrementCounts(expandedLineCount, expandedLineCount);
|
|
1060
|
+
consumePendingCollapsed();
|
|
1061
|
+
}
|
|
1062
|
+
let unifiedLineIndex = hunk.unifiedLineStart;
|
|
1063
|
+
let splitLineIndex = hunk.splitLineStart;
|
|
1064
|
+
let deletionLineIndex = deletionStartIndex;
|
|
1065
|
+
let additionLineIndex = additionStartIndex;
|
|
1066
|
+
let deletionLineNumber = deletionBoundary + 1;
|
|
1067
|
+
let additionLineNumber = additionBoundary + 1;
|
|
1068
|
+
const lastContent = hunk.hunkContent.at(-1);
|
|
1069
|
+
for (const content of hunk.hunkContent) {
|
|
1070
|
+
if (state.shouldBreak()) break hunkIterator;
|
|
1071
|
+
const isLastContent = content === lastContent;
|
|
1072
|
+
if (content.type === "context") {
|
|
1073
|
+
if (!state.shouldSkip(content.lines, content.lines)) {
|
|
1074
|
+
if (walkContextLines(state, content.lines, diffStyle, (index) => {
|
|
1075
|
+
const isLastLine = isLastContent && index === content.lines - 1;
|
|
1076
|
+
const unifiedRowIndex = unifiedLineIndex + index;
|
|
1077
|
+
const splitRowIndex = splitLineIndex + index;
|
|
1078
|
+
return state.emit({
|
|
1079
|
+
hunkIndex,
|
|
1080
|
+
hunk,
|
|
1081
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
1082
|
+
collapsedAfter: getTrailingCollapsedAfter(unifiedRowIndex, splitRowIndex),
|
|
1083
|
+
type: "context",
|
|
1084
|
+
deletionLine: {
|
|
1085
|
+
lineNumber: deletionLineNumber + index,
|
|
1086
|
+
lineIndex: deletionLineIndex + index,
|
|
1087
|
+
noEOFCR: isLastLine && hunk.noEOFCRDeletions,
|
|
1088
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
1089
|
+
splitLineIndex: splitRowIndex
|
|
1090
|
+
},
|
|
1091
|
+
additionLine: {
|
|
1092
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
1093
|
+
splitLineIndex: splitRowIndex,
|
|
1094
|
+
lineIndex: additionLineIndex + index,
|
|
1095
|
+
lineNumber: additionLineNumber + index,
|
|
1096
|
+
noEOFCR: isLastLine && hunk.noEOFCRAdditions
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}, () => {
|
|
1100
|
+
consumePendingCollapsed();
|
|
1101
|
+
})) break hunkIterator;
|
|
1102
|
+
} else {
|
|
1103
|
+
state.incrementCounts(content.lines, content.lines);
|
|
1104
|
+
consumePendingCollapsed();
|
|
1105
|
+
}
|
|
1106
|
+
unifiedLineIndex += content.lines;
|
|
1107
|
+
splitLineIndex += content.lines;
|
|
1108
|
+
deletionLineIndex += content.lines;
|
|
1109
|
+
additionLineIndex += content.lines;
|
|
1110
|
+
deletionLineNumber += content.lines;
|
|
1111
|
+
additionLineNumber += content.lines;
|
|
1112
|
+
} else {
|
|
1113
|
+
const splitCount = Math.max(content.deletions, content.additions);
|
|
1114
|
+
const unifiedCount = content.deletions + content.additions;
|
|
1115
|
+
if (!state.shouldSkip(unifiedCount, splitCount)) {
|
|
1116
|
+
const iterationRanges = getChangeIterationRanges(state, content);
|
|
1117
|
+
if ((iterationRanges[0]?.[0] ?? 0) > 0) consumePendingCollapsed();
|
|
1118
|
+
for (const [rangeStart, rangeEnd] of iterationRanges) for (let index = rangeStart; index < rangeEnd; index++) {
|
|
1119
|
+
const collapsedAfter = getTrailingCollapsedAfter(unifiedLineIndex + index, splitLineIndex + index);
|
|
1120
|
+
if (state.emit(getChangeLineData({
|
|
1121
|
+
hunkIndex,
|
|
1122
|
+
hunk,
|
|
1123
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
1124
|
+
collapsedAfter,
|
|
1125
|
+
diffStyle,
|
|
1126
|
+
index,
|
|
1127
|
+
unifiedLineIndex,
|
|
1128
|
+
splitLineIndex,
|
|
1129
|
+
additionLineIndex,
|
|
1130
|
+
deletionLineIndex,
|
|
1131
|
+
additionLineNumber,
|
|
1132
|
+
deletionLineNumber,
|
|
1133
|
+
content,
|
|
1134
|
+
isLastContent,
|
|
1135
|
+
unifiedCount,
|
|
1136
|
+
splitCount
|
|
1137
|
+
}), true)) break hunkIterator;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
consumePendingCollapsed();
|
|
1141
|
+
state.incrementCounts(unifiedCount, splitCount);
|
|
1142
|
+
unifiedLineIndex += unifiedCount;
|
|
1143
|
+
splitLineIndex += splitCount;
|
|
1144
|
+
deletionLineIndex += content.deletions;
|
|
1145
|
+
additionLineIndex += content.additions;
|
|
1146
|
+
deletionLineNumber += content.deletions;
|
|
1147
|
+
additionLineNumber += content.additions;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (trailingRegion != null) {
|
|
1151
|
+
const { collapsedLines, fromStart, fromEnd } = trailingRegion;
|
|
1152
|
+
const len = fromStart + fromEnd;
|
|
1153
|
+
if (walkContextLines(state, len, diffStyle, (index) => {
|
|
1154
|
+
const isLastLine = index === len - 1;
|
|
1155
|
+
return state.emit({
|
|
1156
|
+
hunkIndex: diff.hunks.length,
|
|
1157
|
+
hunk: void 0,
|
|
1158
|
+
collapsedBefore: 0,
|
|
1159
|
+
collapsedAfter: isLastLine ? collapsedLines : 0,
|
|
1160
|
+
type: "context-expanded",
|
|
1161
|
+
deletionLine: {
|
|
1162
|
+
lineNumber: deletionLineNumber + index,
|
|
1163
|
+
lineIndex: deletionLineIndex + index,
|
|
1164
|
+
noEOFCR: false,
|
|
1165
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
1166
|
+
splitLineIndex: splitLineIndex + index
|
|
1167
|
+
},
|
|
1168
|
+
additionLine: {
|
|
1169
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
1170
|
+
splitLineIndex: splitLineIndex + index,
|
|
1171
|
+
lineIndex: additionLineIndex + index,
|
|
1172
|
+
lineNumber: additionLineNumber + index,
|
|
1173
|
+
noEOFCR: false
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}, void 0, () => state.shouldBreak())) break hunkIterator;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function getIterationStartState({ diff, diffStyle, startingLine, expandedHunks, collapsedContextThreshold }) {
|
|
1181
|
+
return {
|
|
1182
|
+
hunkIndex: 0,
|
|
1183
|
+
splitCount: 0,
|
|
1184
|
+
unifiedCount: 0
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
function getContextLineIterationBounds(state, count, diffStyle) {
|
|
1188
|
+
if (!state.isWindowedHighlight || count <= 0) return [0, count];
|
|
1189
|
+
const ranges = [];
|
|
1190
|
+
function pushRange(currentCount) {
|
|
1191
|
+
const start2 = Math.max(0, state.viewportStart - currentCount);
|
|
1192
|
+
const end2 = Math.min(count, state.viewportEnd - currentCount);
|
|
1193
|
+
if (end2 > start2) ranges.push([start2, end2]);
|
|
1194
|
+
}
|
|
1195
|
+
pushRange(state.unifiedCount);
|
|
1196
|
+
pushRange(state.splitCount);
|
|
1197
|
+
if (ranges.length === 0) return [0, 0];
|
|
1198
|
+
let start = ranges[0][0];
|
|
1199
|
+
let end = ranges[0][1];
|
|
1200
|
+
for (let index = 1; index < ranges.length; index++) {
|
|
1201
|
+
const range = ranges[index];
|
|
1202
|
+
start = Math.min(start, range[0]);
|
|
1203
|
+
end = Math.max(end, range[1]);
|
|
1204
|
+
}
|
|
1205
|
+
return [start, end];
|
|
1206
|
+
}
|
|
1207
|
+
function walkContextLines(state, count, diffStyle, callback, onSkippedStart, shouldBreak) {
|
|
1208
|
+
const [startIndex, endIndex] = getContextLineIterationBounds(state, count);
|
|
1209
|
+
if (startIndex > 0) {
|
|
1210
|
+
state.incrementCounts(startIndex, startIndex);
|
|
1211
|
+
onSkippedStart?.();
|
|
1212
|
+
}
|
|
1213
|
+
let index = startIndex;
|
|
1214
|
+
while (index < count) {
|
|
1215
|
+
if (shouldBreak?.() === true) return true;
|
|
1216
|
+
if (index >= endIndex) {
|
|
1217
|
+
state.incrementCounts(count - index, count - index);
|
|
1218
|
+
break;
|
|
1219
|
+
}
|
|
1220
|
+
if (state.isInWindow(0, 0)) {
|
|
1221
|
+
if (callback(index) === true) return true;
|
|
1222
|
+
} else state.incrementCounts(1, 1);
|
|
1223
|
+
index++;
|
|
1224
|
+
}
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
function getChangeIterationRanges(state, content, diffStyle) {
|
|
1228
|
+
if (!state.isWindowedHighlight) return [[0, Math.max(content.deletions, content.additions)]];
|
|
1229
|
+
const iterationRanges = [];
|
|
1230
|
+
function getVisibleRange(start, count) {
|
|
1231
|
+
if (start + count <= state.viewportStart || start >= state.viewportEnd) return;
|
|
1232
|
+
const visibleStart = Math.max(0, state.viewportStart - start);
|
|
1233
|
+
const visibleEnd = Math.min(count, state.viewportEnd - start);
|
|
1234
|
+
return visibleEnd > visibleStart ? [visibleStart, visibleEnd] : void 0;
|
|
1235
|
+
}
|
|
1236
|
+
function mapRangeToIteration(range, kind) {
|
|
1237
|
+
return range;
|
|
1238
|
+
}
|
|
1239
|
+
function pushRange(range, kind) {
|
|
1240
|
+
if (range == null) return;
|
|
1241
|
+
const [start, end] = mapRangeToIteration(range);
|
|
1242
|
+
if (end > start) iterationRanges.push([start, end]);
|
|
1243
|
+
}
|
|
1244
|
+
{
|
|
1245
|
+
pushRange(getVisibleRange(state.unifiedCount, content.deletions));
|
|
1246
|
+
pushRange(getVisibleRange(state.unifiedCount + content.deletions, content.additions));
|
|
1247
|
+
}
|
|
1248
|
+
{
|
|
1249
|
+
pushRange(getVisibleRange(state.splitCount, content.deletions));
|
|
1250
|
+
pushRange(getVisibleRange(state.splitCount, content.additions));
|
|
1251
|
+
}
|
|
1252
|
+
if (iterationRanges.length === 0) return iterationRanges;
|
|
1253
|
+
iterationRanges.sort((a, b) => a[0] - b[0]);
|
|
1254
|
+
const merged = [iterationRanges[0]];
|
|
1255
|
+
for (const [start, end] of iterationRanges.slice(1)) {
|
|
1256
|
+
const last = merged[merged.length - 1];
|
|
1257
|
+
if (start <= last[1]) last[1] = Math.max(last[1], end);
|
|
1258
|
+
else merged.push([start, end]);
|
|
1259
|
+
}
|
|
1260
|
+
return merged;
|
|
1261
|
+
}
|
|
1262
|
+
function getChangeLineData({ hunkIndex, hunk, collapsedAfter, collapsedBefore, diffStyle, index, unifiedLineIndex, splitLineIndex, additionLineIndex, deletionLineIndex, additionLineNumber, deletionLineNumber, content, isLastContent, unifiedCount, splitCount }) {
|
|
1263
|
+
const unifiedDeletionLineIndex = index < content.deletions ? unifiedLineIndex + index : void 0;
|
|
1264
|
+
const unifiedAdditionLineIndex = diffStyle === "unified" ? index >= content.deletions ? unifiedLineIndex + index : void 0 : index < content.additions ? unifiedLineIndex + content.deletions + index : void 0;
|
|
1265
|
+
const resolvedSplitLineIndex = diffStyle === "unified" ? splitLineIndex + (index < content.deletions ? index : index - content.deletions) : splitLineIndex + index;
|
|
1266
|
+
const deletionLineIndexValue = index < content.deletions ? deletionLineIndex + index : void 0;
|
|
1267
|
+
const deletionLineNumberValue = index < content.deletions ? deletionLineNumber + index : void 0;
|
|
1268
|
+
const additionLineIndexValue = diffStyle === "unified" ? index >= content.deletions ? additionLineIndex + (index - content.deletions) : void 0 : index < content.additions ? additionLineIndex + index : void 0;
|
|
1269
|
+
const additionLineNumberValue = diffStyle === "unified" ? index >= content.deletions ? additionLineNumber + (index - content.deletions) : void 0 : index < content.additions ? additionLineNumber + index : void 0;
|
|
1270
|
+
const noEOFCRDeletion = diffStyle === "unified" ? isLastContent && index === content.deletions - 1 && hunk.noEOFCRDeletions : isLastContent && index === splitCount - 1 && hunk.noEOFCRDeletions;
|
|
1271
|
+
const noEOFCRAddition = diffStyle === "unified" ? isLastContent && index === unifiedCount - 1 && hunk.noEOFCRAdditions : isLastContent && index === splitCount - 1 && hunk.noEOFCRAdditions;
|
|
1272
|
+
const deletionLine = deletionLineIndexValue != null && deletionLineNumberValue != null && unifiedDeletionLineIndex != null ? {
|
|
1273
|
+
lineNumber: deletionLineNumberValue,
|
|
1274
|
+
lineIndex: deletionLineIndexValue,
|
|
1275
|
+
noEOFCR: noEOFCRDeletion,
|
|
1276
|
+
unifiedLineIndex: unifiedDeletionLineIndex,
|
|
1277
|
+
splitLineIndex: resolvedSplitLineIndex
|
|
1278
|
+
} : void 0;
|
|
1279
|
+
const additionLine = additionLineIndexValue != null && additionLineNumberValue != null && unifiedAdditionLineIndex != null ? {
|
|
1280
|
+
unifiedLineIndex: unifiedAdditionLineIndex,
|
|
1281
|
+
splitLineIndex: resolvedSplitLineIndex,
|
|
1282
|
+
lineIndex: additionLineIndexValue,
|
|
1283
|
+
lineNumber: additionLineNumberValue,
|
|
1284
|
+
noEOFCR: noEOFCRAddition
|
|
1285
|
+
} : void 0;
|
|
1286
|
+
if (deletionLine == null && additionLine != null) return {
|
|
1287
|
+
type: "change",
|
|
1288
|
+
hunkIndex,
|
|
1289
|
+
hunk,
|
|
1290
|
+
collapsedAfter,
|
|
1291
|
+
collapsedBefore,
|
|
1292
|
+
deletionLine: void 0,
|
|
1293
|
+
additionLine
|
|
1294
|
+
};
|
|
1295
|
+
else if (deletionLine != null && additionLine == null) return {
|
|
1296
|
+
type: "change",
|
|
1297
|
+
hunkIndex,
|
|
1298
|
+
hunk,
|
|
1299
|
+
collapsedAfter,
|
|
1300
|
+
collapsedBefore,
|
|
1301
|
+
deletionLine,
|
|
1302
|
+
additionLine: void 0
|
|
1303
|
+
};
|
|
1304
|
+
if (deletionLine == null || additionLine == null) throw new Error("iterateOverDiff: missing change line data");
|
|
1305
|
+
return {
|
|
1306
|
+
type: "change",
|
|
1307
|
+
hunkIndex,
|
|
1308
|
+
hunk,
|
|
1309
|
+
collapsedAfter,
|
|
1310
|
+
collapsedBefore,
|
|
1311
|
+
deletionLine,
|
|
1312
|
+
additionLine
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
function createDiffSpanDecoration({ line, spanStart, spanLength }) {
|
|
1316
|
+
return {
|
|
1317
|
+
start: {
|
|
1318
|
+
line,
|
|
1319
|
+
character: spanStart
|
|
1320
|
+
},
|
|
1321
|
+
end: {
|
|
1322
|
+
line,
|
|
1323
|
+
character: spanStart + spanLength
|
|
1324
|
+
},
|
|
1325
|
+
properties: { "data-diff-span": "" },
|
|
1326
|
+
alwaysWrap: true
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
function pushOrJoinSpan({ item, arr, enableJoin, isNeutral = false, isLastItem = false }) {
|
|
1330
|
+
const lastItem = arr[arr.length - 1];
|
|
1331
|
+
if (lastItem == null || isLastItem || !enableJoin) {
|
|
1332
|
+
arr.push([isNeutral ? 0 : 1, item.value]);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
const isLastItemNeutral = lastItem[0] === 0;
|
|
1336
|
+
if (isNeutral === isLastItemNeutral || isNeutral && item.value.length === 1 && !isLastItemNeutral) {
|
|
1337
|
+
lastItem[1] += item.value;
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
arr.push([isNeutral ? 0 : 1, item.value]);
|
|
1341
|
+
}
|
|
1342
|
+
function createTextNodeElement(value) {
|
|
1343
|
+
return {
|
|
1344
|
+
type: "text",
|
|
1345
|
+
value
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function createHastElement({ tagName, children = [], properties = {} }) {
|
|
1349
|
+
return {
|
|
1350
|
+
type: "element",
|
|
1351
|
+
tagName,
|
|
1352
|
+
properties,
|
|
1353
|
+
children
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
function processLine(node, line, state) {
|
|
1357
|
+
const lineInfo = typeof state.lineInfo === "function" ? state.lineInfo(line) : state.lineInfo[line - 1];
|
|
1358
|
+
if (lineInfo == null) {
|
|
1359
|
+
const errorMessage = `processLine: line ${line}, contains no state.lineInfo`;
|
|
1360
|
+
console.error(errorMessage, {
|
|
1361
|
+
node,
|
|
1362
|
+
line,
|
|
1363
|
+
state
|
|
1364
|
+
});
|
|
1365
|
+
throw new Error(errorMessage);
|
|
1366
|
+
}
|
|
1367
|
+
node.tagName = "div";
|
|
1368
|
+
node.properties["data-line"] = lineInfo.lineNumber;
|
|
1369
|
+
node.properties["data-alt-line"] = lineInfo.altLineNumber;
|
|
1370
|
+
node.properties["data-line-type"] = lineInfo.type;
|
|
1371
|
+
node.properties["data-line-index"] = lineInfo.lineIndex;
|
|
1372
|
+
if (node.children.length === 0) node.children.push(createTextNodeElement("\n"));
|
|
1373
|
+
return node;
|
|
1374
|
+
}
|
|
1375
|
+
function setDeferredArrayItem(array, index, create, { retain = true } = {}) {
|
|
1376
|
+
let initialized = false;
|
|
1377
|
+
let cached;
|
|
1378
|
+
Object.defineProperty(array, index, {
|
|
1379
|
+
configurable: true,
|
|
1380
|
+
enumerable: true,
|
|
1381
|
+
get() {
|
|
1382
|
+
if (initialized) return cached;
|
|
1383
|
+
const value = create();
|
|
1384
|
+
if (!retain) return value;
|
|
1385
|
+
cached = value;
|
|
1386
|
+
initialized = true;
|
|
1387
|
+
if (Object.getOwnPropertyDescriptor(array, index)?.configurable === true) Object.defineProperty(array, index, {
|
|
1388
|
+
configurable: true,
|
|
1389
|
+
enumerable: true,
|
|
1390
|
+
writable: true,
|
|
1391
|
+
value: cached
|
|
1392
|
+
});
|
|
1393
|
+
return cached;
|
|
1394
|
+
},
|
|
1395
|
+
set(value) {
|
|
1396
|
+
if (Object.getOwnPropertyDescriptor(array, index)?.configurable === true) Object.defineProperty(array, index, {
|
|
1397
|
+
configurable: true,
|
|
1398
|
+
enumerable: true,
|
|
1399
|
+
writable: true,
|
|
1400
|
+
value
|
|
1401
|
+
});
|
|
1402
|
+
else if (Object.isFrozen(array)) throw new TypeError(`Cannot assign to read only array index '${index}'`);
|
|
1403
|
+
else {
|
|
1404
|
+
cached = value;
|
|
1405
|
+
initialized = true;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
const htmlStyleCache = /* @__PURE__ */ new WeakMap();
|
|
1411
|
+
function tokenStyle(token, cacheHtmlStyle = false) {
|
|
1412
|
+
const { htmlStyle } = token;
|
|
1413
|
+
if (htmlStyle != null) {
|
|
1414
|
+
let style2 = cacheHtmlStyle ? htmlStyleCache.get(htmlStyle) : void 0;
|
|
1415
|
+
if (style2 == null) {
|
|
1416
|
+
style2 = "";
|
|
1417
|
+
for (const name in htmlStyle) style2 += `${style2 === "" ? "" : ";"}${name}:${htmlStyle[name]}`;
|
|
1418
|
+
if (cacheHtmlStyle) htmlStyleCache.set(htmlStyle, style2);
|
|
1419
|
+
}
|
|
1420
|
+
return style2;
|
|
1421
|
+
}
|
|
1422
|
+
let style = token.color != null ? `color:${token.color}` : "";
|
|
1423
|
+
if (token.bgColor != null) style += `;background-color:${token.bgColor}`;
|
|
1424
|
+
if (token.fontStyle != null) {
|
|
1425
|
+
if ((token.fontStyle & 1) !== 0) style += ";font-style:italic";
|
|
1426
|
+
if ((token.fontStyle & 2) !== 0) style += ";font-weight:bold";
|
|
1427
|
+
const underline = (token.fontStyle & 4) !== 0;
|
|
1428
|
+
const strikethrough = (token.fontStyle & 8) !== 0;
|
|
1429
|
+
if (underline || strikethrough) style += `;text-decoration:${underline ? "underline" : ""}${underline && strikethrough ? " " : ""}${strikethrough ? "line-through" : ""}`;
|
|
1430
|
+
}
|
|
1431
|
+
return style.replace(/^;/, "");
|
|
1432
|
+
}
|
|
1433
|
+
const NO_TOKEN = /* @__PURE__ */ Symbol("no-token");
|
|
1434
|
+
const MULTIPLE_TOKENS = /* @__PURE__ */ Symbol("multiple-tokens");
|
|
1435
|
+
function wrapTokenFragments(container) {
|
|
1436
|
+
const ownTokenChar = getTokenChar(container);
|
|
1437
|
+
if (ownTokenChar != null) return ownTokenChar;
|
|
1438
|
+
let containerTokenState = NO_TOKEN;
|
|
1439
|
+
const wrappedChildren = [];
|
|
1440
|
+
let currentTokenChildren = [];
|
|
1441
|
+
let currentTokenChar;
|
|
1442
|
+
const flushTokenChildren = () => {
|
|
1443
|
+
if (currentTokenChildren.length === 0 || currentTokenChar == null) {
|
|
1444
|
+
currentTokenChildren = [];
|
|
1445
|
+
currentTokenChar = void 0;
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
if (currentTokenChildren.length === 1) {
|
|
1449
|
+
const child = currentTokenChildren[0];
|
|
1450
|
+
if (child?.type === "element") {
|
|
1451
|
+
setTokenChar(child, currentTokenChar);
|
|
1452
|
+
for (const grandChild of child.children) stripTokenChar(grandChild);
|
|
1453
|
+
} else stripTokenChar(child);
|
|
1454
|
+
wrappedChildren.push(child);
|
|
1455
|
+
currentTokenChildren = [];
|
|
1456
|
+
currentTokenChar = void 0;
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
for (const child of currentTokenChildren) stripTokenChar(child);
|
|
1460
|
+
wrappedChildren.push(createHastElement({
|
|
1461
|
+
tagName: "span",
|
|
1462
|
+
properties: { "data-char": currentTokenChar },
|
|
1463
|
+
children: currentTokenChildren
|
|
1464
|
+
}));
|
|
1465
|
+
currentTokenChildren = [];
|
|
1466
|
+
currentTokenChar = void 0;
|
|
1467
|
+
};
|
|
1468
|
+
const mergeContainerTokenState = (childTokenState) => {
|
|
1469
|
+
if (childTokenState === NO_TOKEN) return;
|
|
1470
|
+
if (childTokenState === MULTIPLE_TOKENS) {
|
|
1471
|
+
containerTokenState = MULTIPLE_TOKENS;
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
if (containerTokenState === NO_TOKEN) {
|
|
1475
|
+
containerTokenState = childTokenState;
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
if (containerTokenState !== childTokenState) containerTokenState = MULTIPLE_TOKENS;
|
|
1479
|
+
};
|
|
1480
|
+
for (const child of container.children) {
|
|
1481
|
+
const childTokenState = child.type === "element" ? wrapTokenFragments(child) : NO_TOKEN;
|
|
1482
|
+
mergeContainerTokenState(childTokenState);
|
|
1483
|
+
if (typeof childTokenState !== "number") {
|
|
1484
|
+
flushTokenChildren();
|
|
1485
|
+
wrappedChildren.push(child);
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
if (currentTokenChar != null && currentTokenChar !== childTokenState) flushTokenChildren();
|
|
1489
|
+
currentTokenChar ??= childTokenState;
|
|
1490
|
+
currentTokenChildren.push(child);
|
|
1491
|
+
}
|
|
1492
|
+
flushTokenChildren();
|
|
1493
|
+
container.children = wrappedChildren;
|
|
1494
|
+
return containerTokenState;
|
|
1495
|
+
}
|
|
1496
|
+
function getTokenChar(node) {
|
|
1497
|
+
const value = node.properties["data-char"];
|
|
1498
|
+
if (typeof value === "number") return value;
|
|
1499
|
+
}
|
|
1500
|
+
function stripTokenChar(node) {
|
|
1501
|
+
if (node.type !== "element") return;
|
|
1502
|
+
node.properties["data-char"] = void 0;
|
|
1503
|
+
for (const child of node.children) stripTokenChar(child);
|
|
1504
|
+
}
|
|
1505
|
+
function setTokenChar(node, char) {
|
|
1506
|
+
node.properties["data-char"] = char;
|
|
1507
|
+
}
|
|
1508
|
+
function renderTokenLines(lines, { state, lazyLineAST = false, cacheHtmlStyles = false, useTokenTransformer = false, mergeWhitespaces = "always", decorations = [], lineOffsets = [] }) {
|
|
1509
|
+
let decorationsByLine;
|
|
1510
|
+
for (const decoration of decorations) {
|
|
1511
|
+
const byLine = decorationsByLine ??= /* @__PURE__ */ new Map();
|
|
1512
|
+
const normalized = {
|
|
1513
|
+
...decoration,
|
|
1514
|
+
start: getDecorationPosition(decoration.start, lineOffsets),
|
|
1515
|
+
end: getDecorationPosition(decoration.end, lineOffsets)
|
|
1516
|
+
};
|
|
1517
|
+
const lastLine = Math.min(normalized.end.line, lines.length - 1);
|
|
1518
|
+
for (let line = normalized.start.line; line <= lastLine; line++) {
|
|
1519
|
+
let spans = byLine.get(line);
|
|
1520
|
+
if (spans == null) byLine.set(line, spans = []);
|
|
1521
|
+
spans.push(normalized);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
const renderLine = (tokens, lineIndex) => {
|
|
1525
|
+
let normalized;
|
|
1526
|
+
if (useTokenTransformer || mergeWhitespaces !== "never") {
|
|
1527
|
+
let pendingWhitespace = "";
|
|
1528
|
+
let whitespaceOffset = 0;
|
|
1529
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1530
|
+
let token = tokens[i];
|
|
1531
|
+
if (useTokenTransformer) {
|
|
1532
|
+
const content = token.content.trim();
|
|
1533
|
+
if (content !== "" && content !== token.content) {
|
|
1534
|
+
normalized ??= tokens.slice(0, i);
|
|
1535
|
+
const start = token.content.indexOf(content);
|
|
1536
|
+
if (start > 0) normalized.push({
|
|
1537
|
+
content: token.content.slice(0, start),
|
|
1538
|
+
offset: token.offset
|
|
1539
|
+
});
|
|
1540
|
+
normalized.push({
|
|
1541
|
+
...token,
|
|
1542
|
+
content,
|
|
1543
|
+
offset: token.offset + start
|
|
1544
|
+
});
|
|
1545
|
+
const end = start + content.length;
|
|
1546
|
+
if (end < token.content.length) normalized.push({
|
|
1547
|
+
content: token.content.slice(end),
|
|
1548
|
+
offset: token.offset + end
|
|
1549
|
+
});
|
|
1550
|
+
continue;
|
|
1551
|
+
}
|
|
1552
|
+
} else {
|
|
1553
|
+
const decoratedWhitespace = ((token.fontStyle ?? 0) & 12) !== 0;
|
|
1554
|
+
if (!decoratedWhitespace && /^\s+$/.test(token.content) && i < tokens.length - 1) {
|
|
1555
|
+
normalized ??= tokens.slice(0, i);
|
|
1556
|
+
if (pendingWhitespace === "") whitespaceOffset = token.offset;
|
|
1557
|
+
pendingWhitespace += token.content;
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
if (pendingWhitespace !== "" && normalized != null) {
|
|
1561
|
+
if (decoratedWhitespace) normalized.push({
|
|
1562
|
+
content: pendingWhitespace,
|
|
1563
|
+
offset: whitespaceOffset
|
|
1564
|
+
});
|
|
1565
|
+
else token = {
|
|
1566
|
+
...token,
|
|
1567
|
+
content: pendingWhitespace + token.content,
|
|
1568
|
+
offset: whitespaceOffset
|
|
1569
|
+
};
|
|
1570
|
+
pendingWhitespace = "";
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
normalized?.push(token);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
normalized ??= tokens;
|
|
1577
|
+
const line = {
|
|
1578
|
+
type: "element",
|
|
1579
|
+
tagName: state == null ? "span" : "div",
|
|
1580
|
+
properties: state == null ? { class: "line" } : {},
|
|
1581
|
+
children: []
|
|
1582
|
+
};
|
|
1583
|
+
const spans = decorationsByLine?.get(lineIndex);
|
|
1584
|
+
const column = spans == null ? appendTokens(line, normalized, useTokenTransformer, cacheHtmlStyles) : appendDecoratedTokens(line, normalized, spans, lineIndex, useTokenTransformer, cacheHtmlStyles);
|
|
1585
|
+
if (useTokenTransformer && column === 0) line.children.push({
|
|
1586
|
+
type: "element",
|
|
1587
|
+
tagName: "br",
|
|
1588
|
+
properties: {},
|
|
1589
|
+
children: []
|
|
1590
|
+
});
|
|
1591
|
+
if (useTokenTransformer && spans != null) wrapTokenFragments(line);
|
|
1592
|
+
return state == null ? line : processLine(line, lineIndex + 1, state);
|
|
1593
|
+
};
|
|
1594
|
+
if (!lazyLineAST) return lines.map(renderLine);
|
|
1595
|
+
const rows = new Array(lines.length);
|
|
1596
|
+
for (let index = 0; index < lines.length; index++) {
|
|
1597
|
+
const tokens = lines[index];
|
|
1598
|
+
setDeferredArrayItem(rows, index, () => renderLine(tokens, index));
|
|
1599
|
+
}
|
|
1600
|
+
return rows;
|
|
1601
|
+
}
|
|
1602
|
+
function appendTokens(line, tokens, useTokenTransformer, cacheHtmlStyles) {
|
|
1603
|
+
let column = 0;
|
|
1604
|
+
for (const token of tokens) {
|
|
1605
|
+
if (token.content === "") continue;
|
|
1606
|
+
line.children.push(createTokenSpan(token, tokenStyle(token, cacheHtmlStyles), token.content, column, useTokenTransformer));
|
|
1607
|
+
column += token.content.length;
|
|
1608
|
+
}
|
|
1609
|
+
return column;
|
|
1610
|
+
}
|
|
1611
|
+
function appendDecoratedTokens(line, tokens, spans, lineIndex, useTokenTransformer, cacheHtmlStyles) {
|
|
1612
|
+
if (spans.length > 1) spans.sort((a, b) => {
|
|
1613
|
+
if (a.start.line !== b.start.line) return a.start.line - b.start.line;
|
|
1614
|
+
if (a.start.character !== b.start.character) return a.start.character - b.start.character;
|
|
1615
|
+
if (a.end.line !== b.end.line) return b.end.line - a.end.line;
|
|
1616
|
+
return b.end.character - a.end.character;
|
|
1617
|
+
});
|
|
1618
|
+
const lineLength = tokens.reduce((length, token) => length + token.content.length, 0);
|
|
1619
|
+
const boundaries = [];
|
|
1620
|
+
for (let order = 0; order < spans.length; order++) {
|
|
1621
|
+
const decoration = spans[order];
|
|
1622
|
+
const range = {
|
|
1623
|
+
decoration,
|
|
1624
|
+
order,
|
|
1625
|
+
from: decoration.start.line === lineIndex ? decoration.start.character : 0,
|
|
1626
|
+
to: decoration.end.line === lineIndex ? decoration.end.character : lineLength
|
|
1627
|
+
};
|
|
1628
|
+
boundaries.push({
|
|
1629
|
+
position: Math.max(0, Math.min(range.from, lineLength)),
|
|
1630
|
+
range,
|
|
1631
|
+
start: true
|
|
1632
|
+
}, {
|
|
1633
|
+
position: Math.max(0, Math.min(range.to, lineLength)),
|
|
1634
|
+
range,
|
|
1635
|
+
start: false
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
boundaries.sort((a, b) => a.position - b.position);
|
|
1639
|
+
const active = [];
|
|
1640
|
+
const decorationStack = [];
|
|
1641
|
+
let boundaryIndex = 0;
|
|
1642
|
+
const updateActive = (range, add) => {
|
|
1643
|
+
let low = 0;
|
|
1644
|
+
let high = active.length;
|
|
1645
|
+
while (low < high) {
|
|
1646
|
+
const middle = low + high >>> 1;
|
|
1647
|
+
if (active[middle].order < range.order) low = middle + 1;
|
|
1648
|
+
else high = middle;
|
|
1649
|
+
}
|
|
1650
|
+
if (add) active.splice(low, 0, range);
|
|
1651
|
+
else if (active[low] === range) active.splice(low, 1);
|
|
1652
|
+
};
|
|
1653
|
+
const getParent = () => {
|
|
1654
|
+
let parent2 = line;
|
|
1655
|
+
let depth = 0;
|
|
1656
|
+
for (const range of active) {
|
|
1657
|
+
if (decorationStack[depth]?.range !== range) {
|
|
1658
|
+
decorationStack.length = depth;
|
|
1659
|
+
const wrapper = {
|
|
1660
|
+
type: "element",
|
|
1661
|
+
tagName: "span",
|
|
1662
|
+
properties: { ...range.decoration.properties },
|
|
1663
|
+
children: []
|
|
1664
|
+
};
|
|
1665
|
+
parent2.children.push(wrapper);
|
|
1666
|
+
decorationStack.push({
|
|
1667
|
+
range,
|
|
1668
|
+
node: wrapper
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
parent2 = decorationStack[depth++].node;
|
|
1672
|
+
}
|
|
1673
|
+
decorationStack.length = depth;
|
|
1674
|
+
return parent2;
|
|
1675
|
+
};
|
|
1676
|
+
let parent = line;
|
|
1677
|
+
const advanceBoundary = (position) => {
|
|
1678
|
+
const first = boundaryIndex;
|
|
1679
|
+
while (boundaries[boundaryIndex]?.position === position) boundaryIndex++;
|
|
1680
|
+
let hasMarker = false;
|
|
1681
|
+
for (let i = first; i < boundaryIndex; i++) {
|
|
1682
|
+
const { range, start } = boundaries[i];
|
|
1683
|
+
if (!start && range.from !== range.to && position < lineLength) updateActive(range, false);
|
|
1684
|
+
}
|
|
1685
|
+
for (let i = first; i < boundaryIndex; i++) {
|
|
1686
|
+
const { range, start } = boundaries[i];
|
|
1687
|
+
if (start && range.from <= position && range.to >= position && (range.to > position || range.from === position || position === lineLength)) {
|
|
1688
|
+
updateActive(range, true);
|
|
1689
|
+
if (range.from === range.to) hasMarker = true;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
if (hasMarker) {
|
|
1693
|
+
getParent();
|
|
1694
|
+
for (let i = first; i < boundaryIndex; i++) {
|
|
1695
|
+
const { range, start } = boundaries[i];
|
|
1696
|
+
if (start && range.from === range.to) updateActive(range, false);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
if (position < lineLength) parent = getParent();
|
|
1700
|
+
};
|
|
1701
|
+
let column = 0;
|
|
1702
|
+
for (const token of tokens) {
|
|
1703
|
+
if (token.content === "") continue;
|
|
1704
|
+
const start = column;
|
|
1705
|
+
const end = start + token.content.length;
|
|
1706
|
+
const style = tokenStyle(token, cacheHtmlStyles);
|
|
1707
|
+
while (column < end) {
|
|
1708
|
+
if (boundaries[boundaryIndex]?.position === column) advanceBoundary(column);
|
|
1709
|
+
const to = Math.min(end, boundaries[boundaryIndex]?.position ?? end);
|
|
1710
|
+
parent.children.push(createTokenSpan(token, style, column === start && to === end ? token.content : token.content.slice(column - start, to - start), start, useTokenTransformer));
|
|
1711
|
+
column = to;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
if (boundaries[boundaryIndex]?.position === column) advanceBoundary(column);
|
|
1715
|
+
return column;
|
|
1716
|
+
}
|
|
1717
|
+
function createTokenSpan(token, style, text, start, useTokenTransformer) {
|
|
1718
|
+
const properties = token.htmlAttrs != null ? { ...token.htmlAttrs } : {};
|
|
1719
|
+
if (style !== "") properties.style = style;
|
|
1720
|
+
if (useTokenTransformer) properties["data-char"] = start;
|
|
1721
|
+
return {
|
|
1722
|
+
type: "element",
|
|
1723
|
+
tagName: "span",
|
|
1724
|
+
properties,
|
|
1725
|
+
children: [{
|
|
1726
|
+
type: "text",
|
|
1727
|
+
value: text
|
|
1728
|
+
}]
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
function getDecorationPosition(position, lineOffsets) {
|
|
1732
|
+
if (typeof position !== "number") return position;
|
|
1733
|
+
let low = 0;
|
|
1734
|
+
let high = lineOffsets.length;
|
|
1735
|
+
while (low + 1 < high) {
|
|
1736
|
+
const middle = low + high >>> 1;
|
|
1737
|
+
if (lineOffsets[middle] <= position) low = middle;
|
|
1738
|
+
else high = middle;
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
line: low,
|
|
1742
|
+
character: position - (lineOffsets[low] ?? 0)
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
const DEFAULT_PLAIN_TEXT_OPTIONS$1 = { forcePlainText: false };
|
|
1746
|
+
function renderDiffWithHighlighter(diff, highlighter2, options, { forcePlainText, lazyLineAST = false, startingLine, totalLines, expandedHunks, collapsedContextThreshold = 1 } = DEFAULT_PLAIN_TEXT_OPTIONS$1) {
|
|
1747
|
+
if (forcePlainText) {
|
|
1748
|
+
startingLine ??= 0;
|
|
1749
|
+
totalLines ??= Infinity;
|
|
1750
|
+
} else {
|
|
1751
|
+
startingLine = 0;
|
|
1752
|
+
totalLines = Infinity;
|
|
1753
|
+
}
|
|
1754
|
+
const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;
|
|
1755
|
+
lazyLineAST &&= !forcePlainText && !options.useTokenTransformer;
|
|
1756
|
+
const baseThemeType = typeof options.theme === "string" ? highlighter2.getTheme(options.theme).type : void 0;
|
|
1757
|
+
const themeStyles = getHighlighterThemeStyles({
|
|
1758
|
+
theme: options.theme,
|
|
1759
|
+
highlighter: highlighter2
|
|
1760
|
+
});
|
|
1761
|
+
const lineDiffType = forcePlainText && !isWindowedHighlight && (diff.unifiedLineCount > 1e3 || diff.splitLineCount > 1e3) ? "none" : options.lineDiffType;
|
|
1762
|
+
const code = {
|
|
1763
|
+
deletionLines: [],
|
|
1764
|
+
additionLines: []
|
|
1765
|
+
};
|
|
1766
|
+
const { maxLineDiffLength } = options;
|
|
1767
|
+
const shouldGroupAll = !forcePlainText && !diff.isPartial;
|
|
1768
|
+
const expandedHunksForIteration = forcePlainText ? expandedHunks : void 0;
|
|
1769
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
1770
|
+
function getBucketForHunk(hunkIndex) {
|
|
1771
|
+
const index = shouldGroupAll ? 0 : hunkIndex;
|
|
1772
|
+
const bucket = buckets.get(index) ?? createBucket();
|
|
1773
|
+
buckets.set(index, bucket);
|
|
1774
|
+
return bucket;
|
|
1775
|
+
}
|
|
1776
|
+
function appendContent(lineContent, lineIndex, segments, contentWrapper) {
|
|
1777
|
+
if (isWindowedHighlight) {
|
|
1778
|
+
let segment = segments.at(-1);
|
|
1779
|
+
if (segment == null || segment.targetIndex + segment.count !== lineIndex) {
|
|
1780
|
+
segment = {
|
|
1781
|
+
targetIndex: lineIndex,
|
|
1782
|
+
originalOffset: contentWrapper.length,
|
|
1783
|
+
count: 0
|
|
1784
|
+
};
|
|
1785
|
+
segments.push(segment);
|
|
1786
|
+
}
|
|
1787
|
+
segment.count++;
|
|
1788
|
+
}
|
|
1789
|
+
contentWrapper.push(lineContent);
|
|
1790
|
+
}
|
|
1791
|
+
iterateOverDiff({
|
|
1792
|
+
diff,
|
|
1793
|
+
diffStyle: "both",
|
|
1794
|
+
startingLine,
|
|
1795
|
+
totalLines,
|
|
1796
|
+
expandedHunks: isWindowedHighlight ? expandedHunksForIteration : true,
|
|
1797
|
+
collapsedContextThreshold,
|
|
1798
|
+
callback: ({ hunkIndex, additionLine, deletionLine, type }) => {
|
|
1799
|
+
const bucket = getBucketForHunk(hunkIndex);
|
|
1800
|
+
const splitLineIndex = additionLine != null ? additionLine.splitLineIndex : deletionLine.splitLineIndex;
|
|
1801
|
+
if (type === "change" && additionLine != null && deletionLine != null) computeLineDiffDecorations({
|
|
1802
|
+
additionLine: diff.additionLines[additionLine.lineIndex],
|
|
1803
|
+
deletionLine: diff.deletionLines[deletionLine.lineIndex],
|
|
1804
|
+
deletionLineIndex: bucket.deletionContent.length,
|
|
1805
|
+
additionLineIndex: bucket.additionContent.length,
|
|
1806
|
+
deletionDecorations: bucket.deletionDecorations,
|
|
1807
|
+
additionDecorations: bucket.additionDecorations,
|
|
1808
|
+
lineDiffType,
|
|
1809
|
+
maxLineDiffLength
|
|
1810
|
+
});
|
|
1811
|
+
if (deletionLine != null) {
|
|
1812
|
+
appendContent(diff.deletionLines[deletionLine.lineIndex], deletionLine.lineIndex, bucket.deletionSegments, bucket.deletionContent);
|
|
1813
|
+
bucket.deletionInfo.push({
|
|
1814
|
+
type: type === "change" ? "change-deletion" : type,
|
|
1815
|
+
lineNumber: deletionLine.lineNumber,
|
|
1816
|
+
altLineNumber: type === "change" ? void 0 : additionLine.lineNumber ?? void 0,
|
|
1817
|
+
lineIndex: `${deletionLine.unifiedLineIndex},${splitLineIndex}`
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
if (additionLine != null) {
|
|
1821
|
+
appendContent(diff.additionLines[additionLine.lineIndex], additionLine.lineIndex, bucket.additionSegments, bucket.additionContent);
|
|
1822
|
+
bucket.additionInfo.push({
|
|
1823
|
+
type: type === "change" ? "change-addition" : type,
|
|
1824
|
+
lineNumber: additionLine.lineNumber,
|
|
1825
|
+
altLineNumber: type === "change" ? void 0 : deletionLine.lineNumber ?? void 0,
|
|
1826
|
+
lineIndex: `${additionLine.unifiedLineIndex},${splitLineIndex}`
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
for (const bucket of buckets.values()) {
|
|
1832
|
+
if (bucket.deletionContent.length === 0 && bucket.additionContent.length === 0) continue;
|
|
1833
|
+
const deletionFile = {
|
|
1834
|
+
name: diff.prevName ?? diff.name,
|
|
1835
|
+
contents: bucket.deletionContent.value
|
|
1836
|
+
};
|
|
1837
|
+
const additionFile = {
|
|
1838
|
+
name: diff.name,
|
|
1839
|
+
contents: bucket.additionContent.value
|
|
1840
|
+
};
|
|
1841
|
+
const { deletionLines, additionLines } = renderTwoFiles({
|
|
1842
|
+
deletionFile,
|
|
1843
|
+
deletionInfo: bucket.deletionInfo,
|
|
1844
|
+
deletionDecorations: bucket.deletionDecorations,
|
|
1845
|
+
additionFile,
|
|
1846
|
+
additionInfo: bucket.additionInfo,
|
|
1847
|
+
additionDecorations: bucket.additionDecorations,
|
|
1848
|
+
highlighter: highlighter2,
|
|
1849
|
+
options,
|
|
1850
|
+
languageOverride: forcePlainText ? "text" : diff.lang,
|
|
1851
|
+
lazyLineAST
|
|
1852
|
+
});
|
|
1853
|
+
if (shouldGroupAll) {
|
|
1854
|
+
code.deletionLines = deletionLines;
|
|
1855
|
+
code.additionLines = additionLines;
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
for (const [target, lines, segments] of [[
|
|
1859
|
+
code.deletionLines,
|
|
1860
|
+
deletionLines,
|
|
1861
|
+
bucket.deletionSegments
|
|
1862
|
+
], [
|
|
1863
|
+
code.additionLines,
|
|
1864
|
+
additionLines,
|
|
1865
|
+
bucket.additionSegments
|
|
1866
|
+
]]) if (segments.length > 0) for (const segment of segments) for (let index = 0; index < segment.count; index++) target[segment.targetIndex + index] = lines[segment.originalOffset + index];
|
|
1867
|
+
else if (lazyLineAST) {
|
|
1868
|
+
const offset = target.length;
|
|
1869
|
+
for (let index = 0; index < lines.length; index++) setDeferredArrayItem(target, offset + index, () => lines[index]);
|
|
1870
|
+
} else appendItems(target, lines);
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
code,
|
|
1874
|
+
themeStyles,
|
|
1875
|
+
baseThemeType
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
function pushWordLineDecorations(lineDiff, { deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations }) {
|
|
1879
|
+
let deletionOffset = 0;
|
|
1880
|
+
let additionOffset = 0;
|
|
1881
|
+
let deletionStart = -1;
|
|
1882
|
+
let deletionEnd = 0;
|
|
1883
|
+
let additionStart = -1;
|
|
1884
|
+
let additionEnd = 0;
|
|
1885
|
+
for (const { value, added, removed } of lineDiff) if (removed) {
|
|
1886
|
+
if (deletionStart === -1) deletionStart = deletionOffset;
|
|
1887
|
+
deletionOffset += value.length;
|
|
1888
|
+
deletionEnd = deletionOffset;
|
|
1889
|
+
} else if (added) {
|
|
1890
|
+
if (additionStart === -1) additionStart = additionOffset;
|
|
1891
|
+
additionOffset += value.length;
|
|
1892
|
+
additionEnd = additionOffset;
|
|
1893
|
+
} else {
|
|
1894
|
+
deletionOffset += value.length;
|
|
1895
|
+
additionOffset += value.length;
|
|
1896
|
+
}
|
|
1897
|
+
if (deletionStart !== -1) deletionDecorations.push(createDiffSpanDecoration({
|
|
1898
|
+
line: deletionLineIndex,
|
|
1899
|
+
spanStart: deletionStart,
|
|
1900
|
+
spanLength: deletionEnd - deletionStart
|
|
1901
|
+
}));
|
|
1902
|
+
if (additionStart !== -1) additionDecorations.push(createDiffSpanDecoration({
|
|
1903
|
+
line: additionLineIndex,
|
|
1904
|
+
spanStart: additionStart,
|
|
1905
|
+
spanLength: additionEnd - additionStart
|
|
1906
|
+
}));
|
|
1907
|
+
}
|
|
1908
|
+
function computeLineDiffDecorations({ deletionLine, additionLine, deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations, lineDiffType, maxLineDiffLength }) {
|
|
1909
|
+
if (deletionLine == null || additionLine == null || lineDiffType === "none") return;
|
|
1910
|
+
deletionLine = cleanLastNewline(deletionLine);
|
|
1911
|
+
additionLine = cleanLastNewline(additionLine);
|
|
1912
|
+
if (deletionLine.length > maxLineDiffLength || additionLine.length > maxLineDiffLength) return;
|
|
1913
|
+
const lineDiff = lineDiffType === "char" ? diffChars(deletionLine, additionLine) : diffWordsWithSpace(deletionLine, additionLine);
|
|
1914
|
+
if (lineDiffType === "word-line") {
|
|
1915
|
+
pushWordLineDecorations(lineDiff, {
|
|
1916
|
+
deletionLineIndex,
|
|
1917
|
+
additionLineIndex,
|
|
1918
|
+
deletionDecorations,
|
|
1919
|
+
additionDecorations
|
|
1920
|
+
});
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
const deletionSpans = [];
|
|
1924
|
+
const additionSpans = [];
|
|
1925
|
+
const enableJoin = lineDiffType === "word-alt";
|
|
1926
|
+
const lastItem = lineDiff.at(-1);
|
|
1927
|
+
for (const item of lineDiff) {
|
|
1928
|
+
const isLastItem = item === lastItem;
|
|
1929
|
+
if (!item.added && !item.removed) {
|
|
1930
|
+
pushOrJoinSpan({
|
|
1931
|
+
item,
|
|
1932
|
+
arr: deletionSpans,
|
|
1933
|
+
enableJoin,
|
|
1934
|
+
isNeutral: true,
|
|
1935
|
+
isLastItem
|
|
1936
|
+
});
|
|
1937
|
+
pushOrJoinSpan({
|
|
1938
|
+
item,
|
|
1939
|
+
arr: additionSpans,
|
|
1940
|
+
enableJoin,
|
|
1941
|
+
isNeutral: true,
|
|
1942
|
+
isLastItem
|
|
1943
|
+
});
|
|
1944
|
+
} else if (item.removed) pushOrJoinSpan({
|
|
1945
|
+
item,
|
|
1946
|
+
arr: deletionSpans,
|
|
1947
|
+
enableJoin,
|
|
1948
|
+
isLastItem
|
|
1949
|
+
});
|
|
1950
|
+
else pushOrJoinSpan({
|
|
1951
|
+
item,
|
|
1952
|
+
arr: additionSpans,
|
|
1953
|
+
enableJoin,
|
|
1954
|
+
isLastItem
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
let spanIndex = 0;
|
|
1958
|
+
for (const span of deletionSpans) {
|
|
1959
|
+
if (span[0] === 1) deletionDecorations.push(createDiffSpanDecoration({
|
|
1960
|
+
line: deletionLineIndex,
|
|
1961
|
+
spanStart: spanIndex,
|
|
1962
|
+
spanLength: span[1].length
|
|
1963
|
+
}));
|
|
1964
|
+
spanIndex += span[1].length;
|
|
1965
|
+
}
|
|
1966
|
+
spanIndex = 0;
|
|
1967
|
+
for (const span of additionSpans) {
|
|
1968
|
+
if (span[0] === 1) additionDecorations.push(createDiffSpanDecoration({
|
|
1969
|
+
line: additionLineIndex,
|
|
1970
|
+
spanStart: spanIndex,
|
|
1971
|
+
spanLength: span[1].length
|
|
1972
|
+
}));
|
|
1973
|
+
spanIndex += span[1].length;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function createBucket() {
|
|
1977
|
+
return {
|
|
1978
|
+
deletionContent: {
|
|
1979
|
+
push(value) {
|
|
1980
|
+
this.value += value;
|
|
1981
|
+
this.length++;
|
|
1982
|
+
},
|
|
1983
|
+
value: "",
|
|
1984
|
+
length: 0
|
|
1985
|
+
},
|
|
1986
|
+
additionContent: {
|
|
1987
|
+
push(value) {
|
|
1988
|
+
this.value += value;
|
|
1989
|
+
this.length++;
|
|
1990
|
+
},
|
|
1991
|
+
value: "",
|
|
1992
|
+
length: 0
|
|
1993
|
+
},
|
|
1994
|
+
deletionInfo: [],
|
|
1995
|
+
additionInfo: [],
|
|
1996
|
+
deletionDecorations: [],
|
|
1997
|
+
additionDecorations: [],
|
|
1998
|
+
deletionSegments: [],
|
|
1999
|
+
additionSegments: []
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
function renderTwoFiles({ lazyLineAST, deletionFile, additionFile, deletionInfo, additionInfo, highlighter: highlighter2, deletionDecorations, additionDecorations, languageOverride, options: { theme, useTokenTransformer, tokenizeMaxLineLength } }) {
|
|
2003
|
+
const renderFile = (file, lineInfo, decorations) => {
|
|
2004
|
+
if (file.contents === "") return [];
|
|
2005
|
+
return renderTokenLines(highlighter2.codeToTokens(cleanLastNewline(file.contents), getTokenOptions(languageOverride ?? getFiletypeFromFileName(file.name), theme, tokenizeMaxLineLength)).tokens, {
|
|
2006
|
+
state: { lineInfo },
|
|
2007
|
+
useTokenTransformer,
|
|
2008
|
+
decorations,
|
|
2009
|
+
lazyLineAST,
|
|
2010
|
+
cacheHtmlStyles: highlighter2.name === "highlights"
|
|
2011
|
+
});
|
|
2012
|
+
};
|
|
2013
|
+
return {
|
|
2014
|
+
deletionLines: renderFile(deletionFile, deletionInfo, deletionDecorations),
|
|
2015
|
+
additionLines: renderFile(additionFile, additionInfo, additionDecorations)
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
const LINE_FEED = 10;
|
|
2019
|
+
const CARRIAGE_RETURN = 13;
|
|
2020
|
+
const DENSE_LINE_BREAK_BLOCK_SIZE = 4;
|
|
2021
|
+
const DENSE_LINE_BREAK_BLOCK_SPAN = 40;
|
|
2022
|
+
function computeLineOffsets(contents) {
|
|
2023
|
+
const offsets = [0];
|
|
2024
|
+
let carriageReturn = contents.indexOf("\r");
|
|
2025
|
+
let lineFeed = contents.indexOf("\n");
|
|
2026
|
+
let blockStart = 0;
|
|
2027
|
+
let blockBreaks = 0;
|
|
2028
|
+
while (carriageReturn !== -1 || lineFeed !== -1) {
|
|
2029
|
+
let nextOffset;
|
|
2030
|
+
if (carriageReturn !== -1 && (lineFeed === -1 || carriageReturn < lineFeed)) {
|
|
2031
|
+
if (lineFeed === carriageReturn + 1) {
|
|
2032
|
+
nextOffset = lineFeed + 1;
|
|
2033
|
+
carriageReturn = contents.indexOf("\r", nextOffset);
|
|
2034
|
+
lineFeed = contents.indexOf("\n", nextOffset);
|
|
2035
|
+
} else {
|
|
2036
|
+
nextOffset = carriageReturn + 1;
|
|
2037
|
+
carriageReturn = contents.indexOf("\r", nextOffset);
|
|
2038
|
+
}
|
|
2039
|
+
} else {
|
|
2040
|
+
nextOffset = lineFeed + 1;
|
|
2041
|
+
lineFeed = contents.indexOf("\n", nextOffset);
|
|
2042
|
+
}
|
|
2043
|
+
offsets.push(nextOffset);
|
|
2044
|
+
if (++blockBreaks === DENSE_LINE_BREAK_BLOCK_SIZE) {
|
|
2045
|
+
if (nextOffset - blockStart <= DENSE_LINE_BREAK_BLOCK_SPAN) {
|
|
2046
|
+
for (let i = nextOffset; i < contents.length; i++) {
|
|
2047
|
+
const char = contents.charCodeAt(i);
|
|
2048
|
+
if (char === LINE_FEED || char === CARRIAGE_RETURN) {
|
|
2049
|
+
if (char === CARRIAGE_RETURN && i + 1 < contents.length && contents.charCodeAt(i + 1) === LINE_FEED) i++;
|
|
2050
|
+
offsets.push(i + 1);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
return offsets;
|
|
2054
|
+
}
|
|
2055
|
+
blockStart = nextOffset;
|
|
2056
|
+
blockBreaks = 0;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
return offsets;
|
|
2060
|
+
}
|
|
2061
|
+
function linesFromFileContents(contents) {
|
|
2062
|
+
const offsets = computeLineOffsets(contents);
|
|
2063
|
+
return Array.from({ length: offsets.length }, (_, i) => {
|
|
2064
|
+
const start = offsets[i];
|
|
2065
|
+
const end = offsets[i + 1] ?? contents.length;
|
|
2066
|
+
return contents.slice(start, end);
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
const DEFAULT_PLAIN_TEXT_OPTIONS = { forcePlainText: false };
|
|
2070
|
+
function renderFileWithHighlighter(file, highlighter2, { theme, tokenizeMaxLineLength, useTokenTransformer }, { forcePlainText, lazyLineAST = false, startingLine, totalLines, lines } = DEFAULT_PLAIN_TEXT_OPTIONS) {
|
|
2071
|
+
if (forcePlainText) {
|
|
2072
|
+
startingLine ??= 0;
|
|
2073
|
+
totalLines ??= Infinity;
|
|
2074
|
+
} else {
|
|
2075
|
+
startingLine = 0;
|
|
2076
|
+
totalLines = Infinity;
|
|
2077
|
+
}
|
|
2078
|
+
const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;
|
|
2079
|
+
const state = { lineInfo: [] };
|
|
2080
|
+
const lang = forcePlainText ? "text" : file.lang ?? getFiletypeFromFileName(file.name);
|
|
2081
|
+
const baseThemeType = typeof theme === "string" ? highlighter2.getTheme(theme).type : void 0;
|
|
2082
|
+
const themeStyles = getHighlighterThemeStyles({
|
|
2083
|
+
theme,
|
|
2084
|
+
highlighter: highlighter2
|
|
2085
|
+
});
|
|
2086
|
+
state.lineInfo = (shikiLineNumber) => ({
|
|
2087
|
+
type: "context",
|
|
2088
|
+
lineIndex: shikiLineNumber - 1 + startingLine,
|
|
2089
|
+
lineNumber: shikiLineNumber + startingLine
|
|
2090
|
+
});
|
|
2091
|
+
const highlightedLines = renderTokenLines(highlighter2.codeToTokens(normalizeHighlightLineEndings(isWindowedHighlight ? extractWindowedFileContent(lines ?? linesFromFileContents(file.contents), startingLine, totalLines) : file.contents), getTokenOptions(lang, theme, tokenizeMaxLineLength)).tokens, {
|
|
2092
|
+
state,
|
|
2093
|
+
useTokenTransformer,
|
|
2094
|
+
lazyLineAST: lazyLineAST && !forcePlainText && !useTokenTransformer,
|
|
2095
|
+
cacheHtmlStyles: highlighter2.name === "highlights"
|
|
2096
|
+
});
|
|
2097
|
+
const code = isWindowedHighlight ? new Array(startingLine) : highlightedLines;
|
|
2098
|
+
if (isWindowedHighlight) appendItems(code, highlightedLines);
|
|
2099
|
+
return {
|
|
2100
|
+
code,
|
|
2101
|
+
themeStyles,
|
|
2102
|
+
baseThemeType
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
function normalizeHighlightLineEndings(contents) {
|
|
2106
|
+
return contents.replace(/\r(?!\n)/g, "\n");
|
|
2107
|
+
}
|
|
2108
|
+
function extractWindowedFileContent(lines, startingLine, totalLines) {
|
|
2109
|
+
if (lines.length === 0) return "";
|
|
2110
|
+
const endLine = Math.min(startingLine + totalLines, lines.length);
|
|
2111
|
+
return lines.slice(startingLine, endLine).join("");
|
|
2112
|
+
}
|
|
2113
|
+
const HOLE = 0;
|
|
2114
|
+
const TEXT = 1;
|
|
2115
|
+
const ELEMENT = 2;
|
|
2116
|
+
const OTHER = 3;
|
|
2117
|
+
const UNDEFINED = 0;
|
|
2118
|
+
const NULL = 1;
|
|
2119
|
+
const TRUE = 2;
|
|
2120
|
+
const FALSE = 3;
|
|
2121
|
+
const STRING = 4;
|
|
2122
|
+
const INTEGER = 5;
|
|
2123
|
+
const EXTRA = 6;
|
|
2124
|
+
function encodeHastLines(lines) {
|
|
2125
|
+
let ops = new Int32Array(Math.max(32, Math.min(65536, lines.length * 32)));
|
|
2126
|
+
let length = 0;
|
|
2127
|
+
const offsets = new Uint32Array(lines.length * 2);
|
|
2128
|
+
const strings = [];
|
|
2129
|
+
const stringIds = /* @__PURE__ */ new Map();
|
|
2130
|
+
const extras = [];
|
|
2131
|
+
let text = "";
|
|
2132
|
+
function push(value) {
|
|
2133
|
+
if (length === ops.length) {
|
|
2134
|
+
const next = new Int32Array(ops.length * 2);
|
|
2135
|
+
next.set(ops);
|
|
2136
|
+
ops = next;
|
|
2137
|
+
}
|
|
2138
|
+
ops[length++] = value;
|
|
2139
|
+
}
|
|
2140
|
+
function intern(value) {
|
|
2141
|
+
let id = stringIds.get(value);
|
|
2142
|
+
if (id == null) {
|
|
2143
|
+
id = strings.length;
|
|
2144
|
+
strings.push(value);
|
|
2145
|
+
stringIds.set(value, id);
|
|
2146
|
+
}
|
|
2147
|
+
return id;
|
|
2148
|
+
}
|
|
2149
|
+
function encodeNode(node) {
|
|
2150
|
+
let keys = 0;
|
|
2151
|
+
for (const _ in node) keys++;
|
|
2152
|
+
if (node?.type === "text" && keys === 2) {
|
|
2153
|
+
push(TEXT);
|
|
2154
|
+
push(node.value.length);
|
|
2155
|
+
text += node.value;
|
|
2156
|
+
} else if (node?.type === "element" && keys === 4 && node.properties != null && Object.getPrototypeOf(node.properties) === Object.prototype) {
|
|
2157
|
+
push(ELEMENT);
|
|
2158
|
+
push(intern(node.tagName));
|
|
2159
|
+
let count = 0;
|
|
2160
|
+
for (const _ in node.properties) count++;
|
|
2161
|
+
push(count);
|
|
2162
|
+
for (const key in node.properties) {
|
|
2163
|
+
const value = node.properties[key];
|
|
2164
|
+
push(intern(key));
|
|
2165
|
+
if (value === void 0) push(UNDEFINED);
|
|
2166
|
+
else if (value === null) push(NULL);
|
|
2167
|
+
else if (value === true) push(TRUE);
|
|
2168
|
+
else if (value === false) push(FALSE);
|
|
2169
|
+
else if (typeof value === "string") {
|
|
2170
|
+
push(STRING);
|
|
2171
|
+
push(intern(value));
|
|
2172
|
+
} else if (typeof value === "number" && (value | 0) === value && !Object.is(value, -0)) {
|
|
2173
|
+
push(INTEGER);
|
|
2174
|
+
push(value);
|
|
2175
|
+
} else {
|
|
2176
|
+
push(EXTRA);
|
|
2177
|
+
push(extras.length);
|
|
2178
|
+
extras.push(value);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
push(node.children.length);
|
|
2182
|
+
for (let index = 0; index < node.children.length; index++) if (index in node.children) encodeNode(node.children[index]);
|
|
2183
|
+
else push(HOLE);
|
|
2184
|
+
} else {
|
|
2185
|
+
push(OTHER);
|
|
2186
|
+
push(extras.length);
|
|
2187
|
+
extras.push(node);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
for (let index = 0; index < lines.length; index++) {
|
|
2191
|
+
offsets[index * 2] = length;
|
|
2192
|
+
offsets[index * 2 + 1] = text.length;
|
|
2193
|
+
if (index in lines) encodeNode(lines[index]);
|
|
2194
|
+
else push(HOLE);
|
|
2195
|
+
}
|
|
2196
|
+
return {
|
|
2197
|
+
ops: ops.subarray(0, length),
|
|
2198
|
+
offsets,
|
|
2199
|
+
strings,
|
|
2200
|
+
text,
|
|
2201
|
+
extras
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
let highlighter;
|
|
2205
|
+
let compactResults = false;
|
|
2206
|
+
let renderOptions = {
|
|
2207
|
+
theme: DEFAULT_THEMES,
|
|
2208
|
+
useTokenTransformer: false,
|
|
2209
|
+
tokenizeMaxLineLength: 1e3,
|
|
2210
|
+
lineDiffType: "word-alt",
|
|
2211
|
+
maxLineDiffLength: 1e3
|
|
2212
|
+
};
|
|
2213
|
+
self.addEventListener("error", (event) => {
|
|
2214
|
+
console.error("[Diffs Worker] Unhandled error:", event.error);
|
|
2215
|
+
});
|
|
2216
|
+
self.addEventListener("message", (event) => {
|
|
2217
|
+
handleMessage(event.data);
|
|
2218
|
+
});
|
|
2219
|
+
async function handleMessage(request) {
|
|
2220
|
+
try {
|
|
2221
|
+
switch (request.type) {
|
|
2222
|
+
case "initialize":
|
|
2223
|
+
await handleInitialize(request);
|
|
2224
|
+
break;
|
|
2225
|
+
case "set-render-options":
|
|
2226
|
+
await handleSetRenderOptions(request);
|
|
2227
|
+
break;
|
|
2228
|
+
case "file":
|
|
2229
|
+
await handleRenderFile(request);
|
|
2230
|
+
break;
|
|
2231
|
+
case "diff":
|
|
2232
|
+
await handleRenderDiff(request);
|
|
2233
|
+
break;
|
|
2234
|
+
default:
|
|
2235
|
+
throw new Error(`Unknown request type: ${request.type}`);
|
|
2236
|
+
}
|
|
2237
|
+
} catch (error) {
|
|
2238
|
+
console.error("Worker error:", error);
|
|
2239
|
+
sendError(request.id, error);
|
|
2240
|
+
} finally {
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
async function handleInitialize({ id, renderOptions: options, preferredHighlighter, resolvedThemes, resolvedLanguages, customExtensionsVersion: customExtensionsVersion2, customExtensionMap, resultFormat }) {
|
|
2244
|
+
let highlighter2 = getHighlighter(preferredHighlighter);
|
|
2245
|
+
if ("then" in highlighter2) highlighter2 = await highlighter2;
|
|
2246
|
+
syncCustomExtensionsFromRequest({
|
|
2247
|
+
customExtensionsVersion: customExtensionsVersion2,
|
|
2248
|
+
customExtensionMap
|
|
2249
|
+
});
|
|
2250
|
+
attachResolvedThemes(resolvedThemes, highlighter2);
|
|
2251
|
+
if (resolvedLanguages != null) attachResolvedLanguages(resolvedLanguages, highlighter2);
|
|
2252
|
+
renderOptions = options;
|
|
2253
|
+
compactResults = resultFormat === "hast-ops-v1";
|
|
2254
|
+
postMessage({
|
|
2255
|
+
type: "success",
|
|
2256
|
+
id,
|
|
2257
|
+
requestType: "initialize",
|
|
2258
|
+
sentAt: Date.now()
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
async function handleSetRenderOptions({ id, renderOptions: options, resolvedThemes }) {
|
|
2262
|
+
let highlighter2 = getHighlighter();
|
|
2263
|
+
if ("then" in highlighter2) highlighter2 = await highlighter2;
|
|
2264
|
+
attachResolvedThemes(resolvedThemes, highlighter2);
|
|
2265
|
+
renderOptions = options;
|
|
2266
|
+
postMessage({
|
|
2267
|
+
type: "success",
|
|
2268
|
+
id,
|
|
2269
|
+
requestType: "set-render-options",
|
|
2270
|
+
sentAt: Date.now()
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
async function handleRenderFile({ id, file, resolvedLanguages, customExtensionsVersion: customExtensionsVersion2, customExtensionMap }) {
|
|
2274
|
+
let highlighter2 = getHighlighter();
|
|
2275
|
+
if ("then" in highlighter2) highlighter2 = await highlighter2;
|
|
2276
|
+
syncCustomExtensionsFromRequest({
|
|
2277
|
+
customExtensionsVersion: customExtensionsVersion2,
|
|
2278
|
+
customExtensionMap
|
|
2279
|
+
});
|
|
2280
|
+
if (resolvedLanguages != null) attachResolvedLanguages(resolvedLanguages, highlighter2);
|
|
2281
|
+
const fileOptions = {
|
|
2282
|
+
theme: renderOptions.theme,
|
|
2283
|
+
useTokenTransformer: renderOptions.useTokenTransformer,
|
|
2284
|
+
tokenizeMaxLineLength: renderOptions.tokenizeMaxLineLength
|
|
2285
|
+
};
|
|
2286
|
+
const result = renderFileWithHighlighter(file, highlighter2, fileOptions);
|
|
2287
|
+
const code = compactResults ? encodeHastLines(result.code) : void 0;
|
|
2288
|
+
const response = {
|
|
2289
|
+
type: "success",
|
|
2290
|
+
requestType: "file",
|
|
2291
|
+
id,
|
|
2292
|
+
result,
|
|
2293
|
+
options: fileOptions,
|
|
2294
|
+
sentAt: Date.now()
|
|
2295
|
+
};
|
|
2296
|
+
postMessage(code == null ? response : {
|
|
2297
|
+
...response,
|
|
2298
|
+
result: {
|
|
2299
|
+
...result,
|
|
2300
|
+
code
|
|
2301
|
+
}
|
|
2302
|
+
}, code == null ? [] : [code.ops.buffer, code.offsets.buffer]);
|
|
2303
|
+
}
|
|
2304
|
+
async function handleRenderDiff({ id, diff, resolvedLanguages, customExtensionsVersion: customExtensionsVersion2, customExtensionMap }) {
|
|
2305
|
+
let highlighter2 = getHighlighter();
|
|
2306
|
+
if ("then" in highlighter2) highlighter2 = await highlighter2;
|
|
2307
|
+
syncCustomExtensionsFromRequest({
|
|
2308
|
+
customExtensionsVersion: customExtensionsVersion2,
|
|
2309
|
+
customExtensionMap
|
|
2310
|
+
});
|
|
2311
|
+
if (resolvedLanguages != null) attachResolvedLanguages(resolvedLanguages, highlighter2);
|
|
2312
|
+
const result = renderDiffWithHighlighter(diff, highlighter2, renderOptions);
|
|
2313
|
+
const code = compactResults ? {
|
|
2314
|
+
deletionLines: encodeHastLines(result.code.deletionLines),
|
|
2315
|
+
additionLines: encodeHastLines(result.code.additionLines)
|
|
2316
|
+
} : void 0;
|
|
2317
|
+
const response = {
|
|
2318
|
+
type: "success",
|
|
2319
|
+
requestType: "diff",
|
|
2320
|
+
id,
|
|
2321
|
+
result,
|
|
2322
|
+
options: renderOptions,
|
|
2323
|
+
sentAt: Date.now()
|
|
2324
|
+
};
|
|
2325
|
+
postMessage(code == null ? response : {
|
|
2326
|
+
...response,
|
|
2327
|
+
result: {
|
|
2328
|
+
...result,
|
|
2329
|
+
code
|
|
2330
|
+
}
|
|
2331
|
+
}, code == null ? [] : [
|
|
2332
|
+
code.deletionLines.ops.buffer,
|
|
2333
|
+
code.deletionLines.offsets.buffer,
|
|
2334
|
+
code.additionLines.ops.buffer,
|
|
2335
|
+
code.additionLines.offsets.buffer
|
|
2336
|
+
]);
|
|
2337
|
+
}
|
|
2338
|
+
function getHighlighter(preferredHighlighter) {
|
|
2339
|
+
highlighter ??= createHighlighter(preferredHighlighter);
|
|
2340
|
+
return highlighter;
|
|
2341
|
+
}
|
|
2342
|
+
function syncCustomExtensionsFromRequest({ customExtensionsVersion: customExtensionsVersion2, customExtensionMap }) {
|
|
2343
|
+
if (customExtensionsVersion2 == null && customExtensionMap == null) return;
|
|
2344
|
+
if (customExtensionsVersion2 == null || customExtensionMap == null) throw new Error("Worker request must include both customExtensionsVersion and customExtensionMap");
|
|
2345
|
+
replaceCustomExtensions(customExtensionsVersion2, customExtensionMap);
|
|
2346
|
+
}
|
|
2347
|
+
function sendError(id, error) {
|
|
2348
|
+
const response = {
|
|
2349
|
+
type: "error",
|
|
2350
|
+
id,
|
|
2351
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2352
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
2353
|
+
};
|
|
2354
|
+
postMessage(response);
|
|
2355
|
+
}
|
|
2356
|
+
export {
|
|
2357
|
+
HighlighterDisposedError as H,
|
|
2358
|
+
RegisteredCustomLanguages as R,
|
|
2359
|
+
attachResolvedLanguages as a,
|
|
2360
|
+
appendItems as b,
|
|
2361
|
+
ResolvedLanguages as c,
|
|
2362
|
+
ResolvingLanguages as d,
|
|
2363
|
+
acquireHighlighterType as e,
|
|
2364
|
+
formatCSSVariablePrefix as f,
|
|
2365
|
+
renderTokenLines as g,
|
|
2366
|
+
releaseHighlighterType as r
|
|
2367
|
+
};
|