@daniel156161/prism 0.2.98 → 0.2.101

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.
Files changed (1188) hide show
  1. package/README.md +2 -2
  2. package/dist/pi/pi-env.d.ts +1 -1
  3. package/dist/pi/pi-env.js +1 -1
  4. package/dist/pi/pi-native.js +2 -1
  5. package/dist/pi/pi-native.js.map +1 -1
  6. package/dist/pi/pi-package-command.d.ts +1 -0
  7. package/dist/pi/pi-package-command.js +6 -0
  8. package/dist/pi/pi-package-command.js.map +1 -0
  9. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +3 -2
  10. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -1
  11. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +13 -3
  12. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -1
  13. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts.map +1 -1
  14. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +14 -1
  15. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js.map +1 -1
  16. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  17. package/node_modules/@earendil-works/pi-ai/README.md +5 -3
  18. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  19. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +34 -19
  20. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  21. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +2 -0
  22. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  23. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +9 -2
  24. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  25. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  26. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +131 -7
  27. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  28. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts +2 -2
  29. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  30. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +17 -13
  31. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  32. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +5 -2
  33. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  34. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +16 -0
  35. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  36. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts +2 -2
  37. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  38. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +15 -11
  39. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  40. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  41. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +6 -1
  42. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  43. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  44. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -1
  45. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  46. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +3 -2
  47. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  48. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +128 -86
  49. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  50. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  51. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +6 -2
  52. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  53. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  54. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +1 -1
  55. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  56. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts +4 -0
  57. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  58. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +17 -10
  59. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  60. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.d.ts +1 -0
  61. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.d.ts.map +1 -1
  62. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js +1 -1
  63. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js.map +1 -1
  64. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  65. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js +98 -34
  66. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -1
  67. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
  68. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -14
  69. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js.map +1 -1
  70. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -1
  71. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  72. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  73. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  74. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  75. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  76. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  77. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  78. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  79. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  80. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  81. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  82. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  83. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  84. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  85. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  86. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  87. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  88. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  89. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
  90. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  91. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  92. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  93. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  94. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  95. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  96. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  97. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  98. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  99. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  100. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts +1 -1
  101. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts.map +1 -1
  102. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js +1 -5
  103. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js.map +1 -1
  104. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +29 -4
  105. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  106. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  107. package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.d.ts +2 -0
  108. package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.d.ts.map +1 -0
  109. package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.js +15 -0
  110. package/node_modules/@earendil-works/pi-ai/dist/utils/sleep.js.map +1 -0
  111. package/node_modules/@earendil-works/pi-ai/package.json +3 -4
  112. package/node_modules/@earendil-works/pi-client/CHANGELOG.md +4 -0
  113. package/node_modules/@earendil-works/pi-client/package.json +2 -2
  114. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +83 -0
  115. package/node_modules/@earendil-works/pi-coding-agent/README.md +8 -4
  116. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic-messages-JWX2WP65.js +45 -0
  117. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic.js +75 -0
  118. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/azure-openai-responses-5ENVCQ7U.js +2 -0
  119. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/bedrock-converse-stream.js +74 -0
  120. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  121. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  122. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
  123. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-AXIIZGTV.js +2 -0
  124. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  125. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-E5KXRMZK.js +1547 -0
  126. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
  127. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-GPPBJGBU.js +50 -0
  128. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
  129. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  130. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-MNAIPA3J.js +2 -0
  131. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-NBBFIJUL.js +11 -0
  132. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-NUHFSC37.js +25 -0
  133. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  134. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  135. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  136. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
  137. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-TRDNDS6A.js +4 -0
  138. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-UAQELI3K.js +2 -0
  139. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-XDUWOHPL.js +6 -0
  140. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
  141. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/dist-RDWOYWHR.js +13 -0
  142. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/github-copilot.js +2 -0
  143. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/google-generative-ai-XDKMGBCJ.js +2 -0
  144. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/google-vertex-D5FGEO3Y.js +2 -0
  145. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/image-resize-worker.js +2 -0
  146. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/kimi-coding.js +2 -0
  147. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/lib-HGQMNYVT.js +9 -0
  148. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/mistral-conversations-YK73UAOZ.js +5 -0
  149. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  150. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex-responses-GJVBJXLB.js +8 -0
  151. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex.js +75 -0
  152. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-completions-JD4WAC3R.js +7 -0
  153. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-responses-BSOJMSEV.js +2 -0
  154. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openrouter-images-N4XVVFSD.js +2 -0
  155. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openrouter.js +75 -0
  156. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/pi-messages-TPFH44NP.js +8 -0
  157. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/radius.js +75 -0
  158. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  159. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/xai.js +2 -0
  160. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js +3 -0
  161. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/client.js +2 -0
  162. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +2 -0
  163. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +3 -0
  164. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts +1 -0
  165. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
  166. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +29 -9
  167. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js.map +1 -1
  168. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -1
  169. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js +2 -1
  170. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js.map +1 -1
  171. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts +4 -3
  172. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
  173. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +22 -14
  174. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
  175. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +26 -7
  176. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  177. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +163 -95
  178. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  179. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  180. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +6 -7
  181. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  182. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  183. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js +3 -0
  184. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
  185. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +4 -3
  186. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  187. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +41 -32
  188. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  189. package/node_modules/@earendil-works/pi-coding-agent/dist/core/defaults.d.ts +1 -0
  190. package/node_modules/@earendil-works/pi-coding-agent/dist/core/defaults.d.ts.map +1 -1
  191. package/node_modules/@earendil-works/pi-coding-agent/dist/core/defaults.js +9 -0
  192. package/node_modules/@earendil-works/pi-coding-agent/dist/core/defaults.js.map +1 -1
  193. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
  194. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  195. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.js +1 -1
  196. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  197. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  198. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +115 -48
  199. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  200. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts +38 -9
  201. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  202. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js +3 -0
  203. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  204. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.d.ts +1 -1
  205. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -1
  206. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.js +1 -1
  207. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -1
  208. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts +20 -19
  209. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  210. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js +26 -5
  211. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  212. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts +5 -0
  213. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts.map +1 -1
  214. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js +3 -1
  215. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js.map +1 -1
  216. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.d.ts +1 -0
  217. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  218. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js +14 -8
  219. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  220. package/node_modules/@earendil-works/pi-coding-agent/dist/core/models-store.d.ts.map +1 -1
  221. package/node_modules/@earendil-works/pi-coding-agent/dist/core/models-store.js +2 -1
  222. package/node_modules/@earendil-works/pi-coding-agent/dist/core/models-store.js.map +1 -1
  223. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  224. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +22 -14
  225. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  226. package/node_modules/@earendil-works/pi-coding-agent/dist/core/pi-manifest.d.ts.map +1 -1
  227. package/node_modules/@earendil-works/pi-coding-agent/dist/core/pi-manifest.js +2 -1
  228. package/node_modules/@earendil-works/pi-coding-agent/dist/core/pi-manifest.js.map +1 -1
  229. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.d.ts.map +1 -1
  230. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js +2 -1
  231. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js.map +1 -1
  232. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  233. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +3 -2
  234. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  235. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts +2 -2
  236. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  237. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +10 -3
  238. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js.map +1 -1
  239. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-export.d.ts +4 -0
  240. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-export.d.ts.map +1 -0
  241. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-export.js +32 -0
  242. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-export.js.map +1 -0
  243. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  244. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +2 -1
  245. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  246. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-diagnostics.d.ts +9 -0
  247. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-diagnostics.d.ts.map +1 -0
  248. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-diagnostics.js +21 -0
  249. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-diagnostics.js.map +1 -0
  250. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts +9 -0
  251. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  252. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +52 -10
  253. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  254. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  255. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +51 -33
  256. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js.map +1 -1
  257. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
  258. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js +2 -1
  259. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
  260. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  261. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +11 -2
  262. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  263. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.d.ts +14 -1
  264. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
  265. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +36 -20
  266. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
  267. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.d.ts +0 -5
  268. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -1
  269. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js +2 -5
  270. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -1
  271. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
  272. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +20 -4
  273. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
  274. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.d.ts +4 -1
  275. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
  276. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.js +18 -1
  277. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.js.map +1 -1
  278. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/powershell.d.ts +16 -0
  279. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/powershell.d.ts.map +1 -0
  280. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/powershell.js +39 -0
  281. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/powershell.js.map +1 -0
  282. package/node_modules/@earendil-works/pi-coding-agent/dist/core/trust-manager.d.ts.map +1 -1
  283. package/node_modules/@earendil-works/pi-coding-agent/dist/core/trust-manager.js +2 -1
  284. package/node_modules/@earendil-works/pi-coding-agent/dist/core/trust-manager.js.map +1 -1
  285. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/index.d.ts.map +1 -1
  286. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/index.js +2 -0
  287. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/index.js.map +1 -1
  288. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.d.ts.map +1 -1
  289. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js +6 -2
  290. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js.map +1 -1
  291. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts +5 -5
  292. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts.map +1 -1
  293. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js +4 -4
  294. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js.map +1 -1
  295. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts +4 -0
  296. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
  297. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +18 -15
  298. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
  299. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.d.ts.map +1 -1
  300. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.js +4 -3
  301. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.js.map +1 -1
  302. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +9 -3
  303. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  304. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js +56 -12
  305. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
  306. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +7 -2
  307. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  308. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +118 -56
  309. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
  310. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
  311. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
  312. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-submenu.js +165 -0
  313. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-submenu.js.map +1 -0
  314. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
  315. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  316. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +74 -17
  317. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  318. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/external-editor.d.ts.map +1 -1
  319. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/external-editor.js +2 -1
  320. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/external-editor.js.map +1 -1
  321. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +11 -0
  322. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  323. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +182 -112
  324. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  325. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/session-share.d.ts +16 -0
  326. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/session-share.d.ts.map +1 -0
  327. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/session-share.js +188 -0
  328. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/session-share.js.map +1 -0
  329. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  330. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +4 -3
  331. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  332. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/json-event.d.ts +16 -13
  333. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/json-event.d.ts.map +1 -1
  334. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/json-event.js +20 -6
  335. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/json-event.js.map +1 -1
  336. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts +1 -0
  337. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
  338. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +186 -2
  339. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
  340. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/frontmatter.d.ts.map +1 -1
  341. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/frontmatter.js +2 -1
  342. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/frontmatter.js.map +1 -1
  343. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/management-http.d.ts +5 -3
  344. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/management-http.d.ts.map +1 -1
  345. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/management-http.js +14 -10
  346. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/management-http.js.map +1 -1
  347. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.d.ts +3 -0
  348. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.d.ts.map +1 -1
  349. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js +17 -5
  350. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js.map +1 -1
  351. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.d.ts +1 -0
  352. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.d.ts.map +1 -1
  353. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js +60 -1
  354. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js.map +1 -1
  355. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/text.d.ts +8 -0
  356. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/text.d.ts.map +1 -0
  357. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/text.js +9 -0
  358. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/text.js.map +1 -0
  359. package/node_modules/@earendil-works/pi-coding-agent/docs/compaction.md +15 -0
  360. package/node_modules/@earendil-works/pi-coding-agent/docs/custom-provider.md +5 -2
  361. package/node_modules/@earendil-works/pi-coding-agent/docs/environment-variables.md +8 -8
  362. package/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md +17 -7
  363. package/node_modules/@earendil-works/pi-coding-agent/docs/json.md +7 -2
  364. package/node_modules/@earendil-works/pi-coding-agent/docs/keybindings.md +8 -8
  365. package/node_modules/@earendil-works/pi-coding-agent/docs/llama-cpp.md +2 -0
  366. package/node_modules/@earendil-works/pi-coding-agent/docs/models.md +8 -2
  367. package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -2
  368. package/node_modules/@earendil-works/pi-coding-agent/docs/rpc.md +9 -3
  369. package/node_modules/@earendil-works/pi-coding-agent/docs/sdk.md +7 -2
  370. package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +11 -3
  371. package/node_modules/@earendil-works/pi-coding-agent/docs/skills.md +4 -3
  372. package/node_modules/@earendil-works/pi-coding-agent/docs/terminal-setup.md +11 -9
  373. package/node_modules/@earendil-works/pi-coding-agent/docs/usage.md +6 -2
  374. package/node_modules/@earendil-works/pi-coding-agent/docs/windows.md +24 -2
  375. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/border-status-editor.ts +1 -1
  376. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  377. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
  378. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  379. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/git-checkpoint.ts +2 -2
  380. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package-lock.json +2 -2
  381. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package.json +1 -1
  382. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/notify.ts +3 -1
  383. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +2 -2
  384. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
  385. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/README.md +1 -1
  386. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts +6 -1
  387. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/titlebar-spinner.ts +1 -1
  388. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +2 -2
  389. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
  390. package/node_modules/@earendil-works/pi-coding-agent/examples/rpc-extension-ui.ts +1 -1
  391. package/node_modules/@earendil-works/pi-coding-agent/examples/sdk/06-extensions.ts +1 -1
  392. package/node_modules/@earendil-works/pi-coding-agent/examples/sdk/README.md +1 -1
  393. package/node_modules/@earendil-works/pi-coding-agent/package.json +12 -14
  394. package/node_modules/@earendil-works/pi-protocol/package.json +1 -1
  395. package/node_modules/@earendil-works/pi-telemetry/package.json +2 -2
  396. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  397. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +9 -4
  398. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  399. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +8 -2
  400. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  401. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +24 -4
  402. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  403. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  404. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +5 -4
  405. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  406. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +2 -2
  407. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  408. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +2 -2
  409. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  410. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +1 -1
  411. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +2 -8
  412. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
  413. package/node_modules/@earendil-works/pi-tui/dist/native-module-path.d.ts +7 -0
  414. package/node_modules/@earendil-works/pi-tui/dist/native-module-path.d.ts.map +1 -0
  415. package/node_modules/@earendil-works/pi-tui/dist/native-module-path.js +19 -0
  416. package/node_modules/@earendil-works/pi-tui/dist/native-module-path.js.map +1 -0
  417. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  418. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +4 -10
  419. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  420. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  421. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +5 -1
  422. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  423. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  424. package/node_modules/@types/node/README.md +1 -1
  425. package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
  426. package/node_modules/@types/node/crypto.d.ts +2 -2
  427. package/node_modules/@types/node/http.d.ts +16 -0
  428. package/node_modules/@types/node/http2.d.ts +10 -2
  429. package/node_modules/@types/node/package.json +2 -2
  430. package/node_modules/@types/node/process.d.ts +52 -0
  431. package/node_modules/@types/node/quic.d.ts +210 -28
  432. package/node_modules/@types/node/sqlite.d.ts +6 -2
  433. package/node_modules/@types/node/test.d.ts +36 -0
  434. package/node_modules/brace-expansion/README.md +1 -2
  435. package/node_modules/brace-expansion/dist/commonjs/index.js +30 -4
  436. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
  437. package/node_modules/brace-expansion/dist/esm/index.js +30 -4
  438. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
  439. package/node_modules/brace-expansion/package.json +1 -1
  440. package/package.json +9 -9
  441. package/dist/prism-extensions/commands/voice-command.d.ts +0 -3
  442. package/dist/prism-extensions/commands/voice-command.js +0 -44
  443. package/dist/prism-extensions/commands/voice-command.js.map +0 -1
  444. package/dist/prism-extensions/core/voice-runtime.d.ts +0 -57
  445. package/dist/prism-extensions/core/voice-runtime.js +0 -313
  446. package/dist/prism-extensions/core/voice-runtime.js.map +0 -1
  447. package/dist/prism-extensions/core/voicebox-client.d.ts +0 -32
  448. package/dist/prism-extensions/core/voicebox-client.js +0 -194
  449. package/dist/prism-extensions/core/voicebox-client.js.map +0 -1
  450. package/dist/prism-extensions/core/voicebox-service.d.ts +0 -19
  451. package/dist/prism-extensions/core/voicebox-service.js +0 -122
  452. package/dist/prism-extensions/core/voicebox-service.js.map +0 -1
  453. package/dist/prism-extensions/integrations/honcho-memory.d.ts +0 -31
  454. package/dist/prism-extensions/integrations/honcho-memory.js +0 -281
  455. package/dist/prism-extensions/integrations/honcho-memory.js.map +0 -1
  456. package/node_modules/@opentelemetry/api/LICENSE +0 -201
  457. package/node_modules/@opentelemetry/api/README.md +0 -116
  458. package/node_modules/@opentelemetry/api/build/esm/api/context.d.ts +0 -41
  459. package/node_modules/@opentelemetry/api/build/esm/api/context.js +0 -110
  460. package/node_modules/@opentelemetry/api/build/esm/api/context.js.map +0 -1
  461. package/node_modules/@opentelemetry/api/build/esm/api/diag.d.ts +0 -30
  462. package/node_modules/@opentelemetry/api/build/esm/api/diag.js +0 -121
  463. package/node_modules/@opentelemetry/api/build/esm/api/diag.js.map +0 -1
  464. package/node_modules/@opentelemetry/api/build/esm/api/metrics.d.ts +0 -28
  465. package/node_modules/@opentelemetry/api/build/esm/api/metrics.js +0 -60
  466. package/node_modules/@opentelemetry/api/build/esm/api/metrics.js.map +0 -1
  467. package/node_modules/@opentelemetry/api/build/esm/api/propagation.d.ts +0 -49
  468. package/node_modules/@opentelemetry/api/build/esm/api/propagation.js +0 -89
  469. package/node_modules/@opentelemetry/api/build/esm/api/propagation.js.map +0 -1
  470. package/node_modules/@opentelemetry/api/build/esm/api/trace.d.ts +0 -40
  471. package/node_modules/@opentelemetry/api/build/esm/api/trace.js +0 -77
  472. package/node_modules/@opentelemetry/api/build/esm/api/trace.js.map +0 -1
  473. package/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.d.ts +0 -29
  474. package/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js +0 -56
  475. package/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js.map +0 -1
  476. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.d.ts +0 -12
  477. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js +0 -98
  478. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js.map +0 -1
  479. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/symbol.d.ts +0 -5
  480. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/symbol.js +0 -20
  481. package/node_modules/@opentelemetry/api/build/esm/baggage/internal/symbol.js.map +0 -1
  482. package/node_modules/@opentelemetry/api/build/esm/baggage/types.d.ts +0 -60
  483. package/node_modules/@opentelemetry/api/build/esm/baggage/types.js +0 -17
  484. package/node_modules/@opentelemetry/api/build/esm/baggage/types.js.map +0 -1
  485. package/node_modules/@opentelemetry/api/build/esm/baggage/utils.d.ts +0 -15
  486. package/node_modules/@opentelemetry/api/build/esm/baggage/utils.js +0 -47
  487. package/node_modules/@opentelemetry/api/build/esm/baggage/utils.js.map +0 -1
  488. package/node_modules/@opentelemetry/api/build/esm/common/Attributes.d.ts +0 -15
  489. package/node_modules/@opentelemetry/api/build/esm/common/Attributes.js +0 -17
  490. package/node_modules/@opentelemetry/api/build/esm/common/Attributes.js.map +0 -1
  491. package/node_modules/@opentelemetry/api/build/esm/common/Exception.d.ts +0 -26
  492. package/node_modules/@opentelemetry/api/build/esm/common/Exception.js +0 -17
  493. package/node_modules/@opentelemetry/api/build/esm/common/Exception.js.map +0 -1
  494. package/node_modules/@opentelemetry/api/build/esm/common/Time.d.ts +0 -20
  495. package/node_modules/@opentelemetry/api/build/esm/common/Time.js +0 -2
  496. package/node_modules/@opentelemetry/api/build/esm/common/Time.js.map +0 -1
  497. package/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.d.ts +0 -9
  498. package/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js +0 -67
  499. package/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js.map +0 -1
  500. package/node_modules/@opentelemetry/api/build/esm/context/context.d.ts +0 -6
  501. package/node_modules/@opentelemetry/api/build/esm/context/context.js +0 -52
  502. package/node_modules/@opentelemetry/api/build/esm/context/context.js.map +0 -1
  503. package/node_modules/@opentelemetry/api/build/esm/context/types.d.ts +0 -52
  504. package/node_modules/@opentelemetry/api/build/esm/context/types.js +0 -17
  505. package/node_modules/@opentelemetry/api/build/esm/context/types.js.map +0 -1
  506. package/node_modules/@opentelemetry/api/build/esm/context-api.d.ts +0 -4
  507. package/node_modules/@opentelemetry/api/build/esm/context-api.js +0 -21
  508. package/node_modules/@opentelemetry/api/build/esm/context-api.js.map +0 -1
  509. package/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.d.ts +0 -20
  510. package/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js +0 -102
  511. package/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js.map +0 -1
  512. package/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.d.ts +0 -38
  513. package/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js +0 -59
  514. package/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js.map +0 -1
  515. package/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.d.ts +0 -3
  516. package/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js +0 -41
  517. package/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js.map +0 -1
  518. package/node_modules/@opentelemetry/api/build/esm/diag/internal/noopLogger.d.ts +0 -8
  519. package/node_modules/@opentelemetry/api/build/esm/diag/internal/noopLogger.js +0 -31
  520. package/node_modules/@opentelemetry/api/build/esm/diag/internal/noopLogger.js.map +0 -1
  521. package/node_modules/@opentelemetry/api/build/esm/diag/types.d.ts +0 -100
  522. package/node_modules/@opentelemetry/api/build/esm/diag/types.js +0 -41
  523. package/node_modules/@opentelemetry/api/build/esm/diag/types.js.map +0 -1
  524. package/node_modules/@opentelemetry/api/build/esm/diag-api.d.ts +0 -9
  525. package/node_modules/@opentelemetry/api/build/esm/diag-api.js +0 -26
  526. package/node_modules/@opentelemetry/api/build/esm/diag-api.js.map +0 -1
  527. package/node_modules/@opentelemetry/api/build/esm/experimental/index.d.ts +0 -3
  528. package/node_modules/@opentelemetry/api/build/esm/experimental/index.js +0 -17
  529. package/node_modules/@opentelemetry/api/build/esm/experimental/index.js.map +0 -1
  530. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredOptions.d.ts +0 -13
  531. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredOptions.js +0 -17
  532. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredOptions.js.map +0 -1
  533. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.d.ts +0 -64
  534. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js +0 -92
  535. package/node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js.map +0 -1
  536. package/node_modules/@opentelemetry/api/build/esm/index.d.ts +0 -54
  537. package/node_modules/@opentelemetry/api/build/esm/index.js +0 -53
  538. package/node_modules/@opentelemetry/api/build/esm/index.js.map +0 -1
  539. package/node_modules/@opentelemetry/api/build/esm/internal/global-utils.d.ts +0 -18
  540. package/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js +0 -59
  541. package/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js.map +0 -1
  542. package/node_modules/@opentelemetry/api/build/esm/internal/semver.d.ts +0 -34
  543. package/node_modules/@opentelemetry/api/build/esm/internal/semver.js +0 -118
  544. package/node_modules/@opentelemetry/api/build/esm/internal/semver.js.map +0 -1
  545. package/node_modules/@opentelemetry/api/build/esm/metrics/Meter.d.ts +0 -110
  546. package/node_modules/@opentelemetry/api/build/esm/metrics/Meter.js +0 -17
  547. package/node_modules/@opentelemetry/api/build/esm/metrics/Meter.js.map +0 -1
  548. package/node_modules/@opentelemetry/api/build/esm/metrics/MeterProvider.d.ts +0 -17
  549. package/node_modules/@opentelemetry/api/build/esm/metrics/MeterProvider.js +0 -17
  550. package/node_modules/@opentelemetry/api/build/esm/metrics/MeterProvider.js.map +0 -1
  551. package/node_modules/@opentelemetry/api/build/esm/metrics/Metric.d.ts +0 -115
  552. package/node_modules/@opentelemetry/api/build/esm/metrics/Metric.js +0 -22
  553. package/node_modules/@opentelemetry/api/build/esm/metrics/Metric.js.map +0 -1
  554. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.d.ts +0 -82
  555. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js +0 -181
  556. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js.map +0 -1
  557. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.d.ts +0 -11
  558. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js +0 -31
  559. package/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js.map +0 -1
  560. package/node_modules/@opentelemetry/api/build/esm/metrics/ObservableResult.d.ts +0 -31
  561. package/node_modules/@opentelemetry/api/build/esm/metrics/ObservableResult.js +0 -17
  562. package/node_modules/@opentelemetry/api/build/esm/metrics/ObservableResult.js.map +0 -1
  563. package/node_modules/@opentelemetry/api/build/esm/metrics-api.d.ts +0 -4
  564. package/node_modules/@opentelemetry/api/build/esm/metrics-api.js +0 -21
  565. package/node_modules/@opentelemetry/api/build/esm/metrics-api.js.map +0 -1
  566. package/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.d.ts +0 -10
  567. package/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js +0 -35
  568. package/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js.map +0 -1
  569. package/node_modules/@opentelemetry/api/build/esm/platform/browser/index.d.ts +0 -2
  570. package/node_modules/@opentelemetry/api/build/esm/platform/browser/index.js +0 -17
  571. package/node_modules/@opentelemetry/api/build/esm/platform/browser/index.js.map +0 -1
  572. package/node_modules/@opentelemetry/api/build/esm/platform/index.d.ts +0 -2
  573. package/node_modules/@opentelemetry/api/build/esm/platform/index.js +0 -17
  574. package/node_modules/@opentelemetry/api/build/esm/platform/index.js.map +0 -1
  575. package/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.d.ts +0 -3
  576. package/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js +0 -19
  577. package/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js.map +0 -1
  578. package/node_modules/@opentelemetry/api/build/esm/platform/node/index.d.ts +0 -2
  579. package/node_modules/@opentelemetry/api/build/esm/platform/node/index.js +0 -17
  580. package/node_modules/@opentelemetry/api/build/esm/platform/node/index.js.map +0 -1
  581. package/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.d.ts +0 -13
  582. package/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js +0 -34
  583. package/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js.map +0 -1
  584. package/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.d.ts +0 -84
  585. package/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js +0 -38
  586. package/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js.map +0 -1
  587. package/node_modules/@opentelemetry/api/build/esm/propagation-api.d.ts +0 -4
  588. package/node_modules/@opentelemetry/api/build/esm/propagation-api.js +0 -21
  589. package/node_modules/@opentelemetry/api/build/esm/propagation-api.js.map +0 -1
  590. package/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.d.ts +0 -28
  591. package/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js +0 -68
  592. package/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js.map +0 -1
  593. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.d.ts +0 -14
  594. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js +0 -76
  595. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js.map +0 -1
  596. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.d.ts +0 -13
  597. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js +0 -32
  598. package/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js.map +0 -1
  599. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.d.ts +0 -27
  600. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js +0 -53
  601. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js.map +0 -1
  602. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.d.ts +0 -25
  603. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js +0 -54
  604. package/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js.map +0 -1
  605. package/node_modules/@opentelemetry/api/build/esm/trace/Sampler.d.ts +0 -31
  606. package/node_modules/@opentelemetry/api/build/esm/trace/Sampler.js +0 -17
  607. package/node_modules/@opentelemetry/api/build/esm/trace/Sampler.js.map +0 -1
  608. package/node_modules/@opentelemetry/api/build/esm/trace/SamplingResult.d.ts +0 -49
  609. package/node_modules/@opentelemetry/api/build/esm/trace/SamplingResult.js +0 -39
  610. package/node_modules/@opentelemetry/api/build/esm/trace/SamplingResult.js.map +0 -1
  611. package/node_modules/@opentelemetry/api/build/esm/trace/SpanOptions.d.ts +0 -23
  612. package/node_modules/@opentelemetry/api/build/esm/trace/SpanOptions.js +0 -17
  613. package/node_modules/@opentelemetry/api/build/esm/trace/SpanOptions.js.map +0 -1
  614. package/node_modules/@opentelemetry/api/build/esm/trace/attributes.d.ts +0 -10
  615. package/node_modules/@opentelemetry/api/build/esm/trace/attributes.js +0 -17
  616. package/node_modules/@opentelemetry/api/build/esm/trace/attributes.js.map +0 -1
  617. package/node_modules/@opentelemetry/api/build/esm/trace/context-utils.d.ts +0 -41
  618. package/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js +0 -73
  619. package/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js.map +0 -1
  620. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-impl.d.ts +0 -22
  621. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-impl.js +0 -102
  622. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-impl.js.map +0 -1
  623. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.d.ts +0 -15
  624. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.js +0 -41
  625. package/node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.js.map +0 -1
  626. package/node_modules/@opentelemetry/api/build/esm/trace/internal/utils.d.ts +0 -3
  627. package/node_modules/@opentelemetry/api/build/esm/trace/internal/utils.js +0 -20
  628. package/node_modules/@opentelemetry/api/build/esm/trace/internal/utils.js.map +0 -1
  629. package/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.d.ts +0 -5
  630. package/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js +0 -24
  631. package/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js.map +0 -1
  632. package/node_modules/@opentelemetry/api/build/esm/trace/link.d.ts +0 -26
  633. package/node_modules/@opentelemetry/api/build/esm/trace/link.js +0 -17
  634. package/node_modules/@opentelemetry/api/build/esm/trace/link.js.map +0 -1
  635. package/node_modules/@opentelemetry/api/build/esm/trace/span.d.ts +0 -120
  636. package/node_modules/@opentelemetry/api/build/esm/trace/span.js +0 -17
  637. package/node_modules/@opentelemetry/api/build/esm/trace/span.js.map +0 -1
  638. package/node_modules/@opentelemetry/api/build/esm/trace/span_context.d.ts +0 -53
  639. package/node_modules/@opentelemetry/api/build/esm/trace/span_context.js +0 -17
  640. package/node_modules/@opentelemetry/api/build/esm/trace/span_context.js.map +0 -1
  641. package/node_modules/@opentelemetry/api/build/esm/trace/span_kind.d.ts +0 -27
  642. package/node_modules/@opentelemetry/api/build/esm/trace/span_kind.js +0 -43
  643. package/node_modules/@opentelemetry/api/build/esm/trace/span_kind.js.map +0 -1
  644. package/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.d.ts +0 -17
  645. package/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js +0 -42
  646. package/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js.map +0 -1
  647. package/node_modules/@opentelemetry/api/build/esm/trace/status.d.ts +0 -25
  648. package/node_modules/@opentelemetry/api/build/esm/trace/status.js +0 -20
  649. package/node_modules/@opentelemetry/api/build/esm/trace/status.js.map +0 -1
  650. package/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.d.ts +0 -7
  651. package/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js +0 -23
  652. package/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js.map +0 -1
  653. package/node_modules/@opentelemetry/api/build/esm/trace/trace_state.d.ts +0 -38
  654. package/node_modules/@opentelemetry/api/build/esm/trace/trace_state.js +0 -17
  655. package/node_modules/@opentelemetry/api/build/esm/trace/trace_state.js.map +0 -1
  656. package/node_modules/@opentelemetry/api/build/esm/trace/tracer.d.ts +0 -71
  657. package/node_modules/@opentelemetry/api/build/esm/trace/tracer.js +0 -17
  658. package/node_modules/@opentelemetry/api/build/esm/trace/tracer.js.map +0 -1
  659. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_options.d.ts +0 -10
  660. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_options.js +0 -17
  661. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_options.js.map +0 -1
  662. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_provider.d.ts +0 -21
  663. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_provider.js +0 -17
  664. package/node_modules/@opentelemetry/api/build/esm/trace/tracer_provider.js.map +0 -1
  665. package/node_modules/@opentelemetry/api/build/esm/trace-api.d.ts +0 -4
  666. package/node_modules/@opentelemetry/api/build/esm/trace-api.js +0 -21
  667. package/node_modules/@opentelemetry/api/build/esm/trace-api.js.map +0 -1
  668. package/node_modules/@opentelemetry/api/build/esm/version.d.ts +0 -2
  669. package/node_modules/@opentelemetry/api/build/esm/version.js +0 -18
  670. package/node_modules/@opentelemetry/api/build/esm/version.js.map +0 -1
  671. package/node_modules/@opentelemetry/api/build/esnext/api/context.d.ts +0 -41
  672. package/node_modules/@opentelemetry/api/build/esnext/api/context.js +0 -77
  673. package/node_modules/@opentelemetry/api/build/esnext/api/context.js.map +0 -1
  674. package/node_modules/@opentelemetry/api/build/esnext/api/diag.d.ts +0 -30
  675. package/node_modules/@opentelemetry/api/build/esnext/api/diag.js +0 -89
  676. package/node_modules/@opentelemetry/api/build/esnext/api/diag.js.map +0 -1
  677. package/node_modules/@opentelemetry/api/build/esnext/api/metrics.d.ts +0 -28
  678. package/node_modules/@opentelemetry/api/build/esnext/api/metrics.js +0 -57
  679. package/node_modules/@opentelemetry/api/build/esnext/api/metrics.js.map +0 -1
  680. package/node_modules/@opentelemetry/api/build/esnext/api/propagation.d.ts +0 -49
  681. package/node_modules/@opentelemetry/api/build/esnext/api/propagation.js +0 -85
  682. package/node_modules/@opentelemetry/api/build/esnext/api/propagation.js.map +0 -1
  683. package/node_modules/@opentelemetry/api/build/esnext/api/trace.d.ts +0 -40
  684. package/node_modules/@opentelemetry/api/build/esnext/api/trace.js +0 -75
  685. package/node_modules/@opentelemetry/api/build/esnext/api/trace.js.map +0 -1
  686. package/node_modules/@opentelemetry/api/build/esnext/baggage/context-helpers.d.ts +0 -29
  687. package/node_modules/@opentelemetry/api/build/esnext/baggage/context-helpers.js +0 -56
  688. package/node_modules/@opentelemetry/api/build/esnext/baggage/context-helpers.js.map +0 -1
  689. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/baggage-impl.d.ts +0 -12
  690. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/baggage-impl.js +0 -51
  691. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/baggage-impl.js.map +0 -1
  692. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/symbol.d.ts +0 -5
  693. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/symbol.js +0 -20
  694. package/node_modules/@opentelemetry/api/build/esnext/baggage/internal/symbol.js.map +0 -1
  695. package/node_modules/@opentelemetry/api/build/esnext/baggage/types.d.ts +0 -60
  696. package/node_modules/@opentelemetry/api/build/esnext/baggage/types.js +0 -17
  697. package/node_modules/@opentelemetry/api/build/esnext/baggage/types.js.map +0 -1
  698. package/node_modules/@opentelemetry/api/build/esnext/baggage/utils.d.ts +0 -15
  699. package/node_modules/@opentelemetry/api/build/esnext/baggage/utils.js +0 -46
  700. package/node_modules/@opentelemetry/api/build/esnext/baggage/utils.js.map +0 -1
  701. package/node_modules/@opentelemetry/api/build/esnext/common/Attributes.d.ts +0 -15
  702. package/node_modules/@opentelemetry/api/build/esnext/common/Attributes.js +0 -17
  703. package/node_modules/@opentelemetry/api/build/esnext/common/Attributes.js.map +0 -1
  704. package/node_modules/@opentelemetry/api/build/esnext/common/Exception.d.ts +0 -26
  705. package/node_modules/@opentelemetry/api/build/esnext/common/Exception.js +0 -17
  706. package/node_modules/@opentelemetry/api/build/esnext/common/Exception.js.map +0 -1
  707. package/node_modules/@opentelemetry/api/build/esnext/common/Time.d.ts +0 -20
  708. package/node_modules/@opentelemetry/api/build/esnext/common/Time.js +0 -2
  709. package/node_modules/@opentelemetry/api/build/esnext/common/Time.js.map +0 -1
  710. package/node_modules/@opentelemetry/api/build/esnext/context/NoopContextManager.d.ts +0 -9
  711. package/node_modules/@opentelemetry/api/build/esnext/context/NoopContextManager.js +0 -34
  712. package/node_modules/@opentelemetry/api/build/esnext/context/NoopContextManager.js.map +0 -1
  713. package/node_modules/@opentelemetry/api/build/esnext/context/context.d.ts +0 -6
  714. package/node_modules/@opentelemetry/api/build/esnext/context/context.js +0 -51
  715. package/node_modules/@opentelemetry/api/build/esnext/context/context.js.map +0 -1
  716. package/node_modules/@opentelemetry/api/build/esnext/context/types.d.ts +0 -52
  717. package/node_modules/@opentelemetry/api/build/esnext/context/types.js +0 -17
  718. package/node_modules/@opentelemetry/api/build/esnext/context/types.js.map +0 -1
  719. package/node_modules/@opentelemetry/api/build/esnext/context-api.d.ts +0 -4
  720. package/node_modules/@opentelemetry/api/build/esnext/context-api.js +0 -21
  721. package/node_modules/@opentelemetry/api/build/esnext/context-api.js.map +0 -1
  722. package/node_modules/@opentelemetry/api/build/esnext/diag/ComponentLogger.d.ts +0 -20
  723. package/node_modules/@opentelemetry/api/build/esnext/diag/ComponentLogger.js +0 -55
  724. package/node_modules/@opentelemetry/api/build/esnext/diag/ComponentLogger.js.map +0 -1
  725. package/node_modules/@opentelemetry/api/build/esnext/diag/consoleLogger.d.ts +0 -38
  726. package/node_modules/@opentelemetry/api/build/esnext/diag/consoleLogger.js +0 -53
  727. package/node_modules/@opentelemetry/api/build/esnext/diag/consoleLogger.js.map +0 -1
  728. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/logLevelLogger.d.ts +0 -3
  729. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/logLevelLogger.js +0 -41
  730. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/logLevelLogger.js.map +0 -1
  731. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/noopLogger.d.ts +0 -8
  732. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/noopLogger.js +0 -31
  733. package/node_modules/@opentelemetry/api/build/esnext/diag/internal/noopLogger.js.map +0 -1
  734. package/node_modules/@opentelemetry/api/build/esnext/diag/types.d.ts +0 -100
  735. package/node_modules/@opentelemetry/api/build/esnext/diag/types.js +0 -41
  736. package/node_modules/@opentelemetry/api/build/esnext/diag/types.js.map +0 -1
  737. package/node_modules/@opentelemetry/api/build/esnext/diag-api.d.ts +0 -9
  738. package/node_modules/@opentelemetry/api/build/esnext/diag-api.js +0 -26
  739. package/node_modules/@opentelemetry/api/build/esnext/diag-api.js.map +0 -1
  740. package/node_modules/@opentelemetry/api/build/esnext/experimental/index.d.ts +0 -3
  741. package/node_modules/@opentelemetry/api/build/esnext/experimental/index.js +0 -17
  742. package/node_modules/@opentelemetry/api/build/esnext/experimental/index.js.map +0 -1
  743. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredOptions.d.ts +0 -13
  744. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredOptions.js +0 -17
  745. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredOptions.js.map +0 -1
  746. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredTracer.d.ts +0 -64
  747. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredTracer.js +0 -88
  748. package/node_modules/@opentelemetry/api/build/esnext/experimental/trace/SugaredTracer.js.map +0 -1
  749. package/node_modules/@opentelemetry/api/build/esnext/index.d.ts +0 -54
  750. package/node_modules/@opentelemetry/api/build/esnext/index.js +0 -53
  751. package/node_modules/@opentelemetry/api/build/esnext/index.js.map +0 -1
  752. package/node_modules/@opentelemetry/api/build/esnext/internal/global-utils.d.ts +0 -18
  753. package/node_modules/@opentelemetry/api/build/esnext/internal/global-utils.js +0 -58
  754. package/node_modules/@opentelemetry/api/build/esnext/internal/global-utils.js.map +0 -1
  755. package/node_modules/@opentelemetry/api/build/esnext/internal/semver.d.ts +0 -34
  756. package/node_modules/@opentelemetry/api/build/esnext/internal/semver.js +0 -118
  757. package/node_modules/@opentelemetry/api/build/esnext/internal/semver.js.map +0 -1
  758. package/node_modules/@opentelemetry/api/build/esnext/metrics/Meter.d.ts +0 -110
  759. package/node_modules/@opentelemetry/api/build/esnext/metrics/Meter.js +0 -17
  760. package/node_modules/@opentelemetry/api/build/esnext/metrics/Meter.js.map +0 -1
  761. package/node_modules/@opentelemetry/api/build/esnext/metrics/MeterProvider.d.ts +0 -17
  762. package/node_modules/@opentelemetry/api/build/esnext/metrics/MeterProvider.js +0 -17
  763. package/node_modules/@opentelemetry/api/build/esnext/metrics/MeterProvider.js.map +0 -1
  764. package/node_modules/@opentelemetry/api/build/esnext/metrics/Metric.d.ts +0 -115
  765. package/node_modules/@opentelemetry/api/build/esnext/metrics/Metric.js +0 -22
  766. package/node_modules/@opentelemetry/api/build/esnext/metrics/Metric.js.map +0 -1
  767. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeter.d.ts +0 -82
  768. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeter.js +0 -113
  769. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeter.js.map +0 -1
  770. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeterProvider.d.ts +0 -11
  771. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeterProvider.js +0 -27
  772. package/node_modules/@opentelemetry/api/build/esnext/metrics/NoopMeterProvider.js.map +0 -1
  773. package/node_modules/@opentelemetry/api/build/esnext/metrics/ObservableResult.d.ts +0 -31
  774. package/node_modules/@opentelemetry/api/build/esnext/metrics/ObservableResult.js +0 -17
  775. package/node_modules/@opentelemetry/api/build/esnext/metrics/ObservableResult.js.map +0 -1
  776. package/node_modules/@opentelemetry/api/build/esnext/metrics-api.d.ts +0 -4
  777. package/node_modules/@opentelemetry/api/build/esnext/metrics-api.js +0 -21
  778. package/node_modules/@opentelemetry/api/build/esnext/metrics-api.js.map +0 -1
  779. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/globalThis.d.ts +0 -10
  780. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/globalThis.js +0 -35
  781. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/globalThis.js.map +0 -1
  782. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/index.d.ts +0 -2
  783. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/index.js +0 -17
  784. package/node_modules/@opentelemetry/api/build/esnext/platform/browser/index.js.map +0 -1
  785. package/node_modules/@opentelemetry/api/build/esnext/platform/index.d.ts +0 -2
  786. package/node_modules/@opentelemetry/api/build/esnext/platform/index.js +0 -17
  787. package/node_modules/@opentelemetry/api/build/esnext/platform/index.js.map +0 -1
  788. package/node_modules/@opentelemetry/api/build/esnext/platform/node/globalThis.d.ts +0 -3
  789. package/node_modules/@opentelemetry/api/build/esnext/platform/node/globalThis.js +0 -19
  790. package/node_modules/@opentelemetry/api/build/esnext/platform/node/globalThis.js.map +0 -1
  791. package/node_modules/@opentelemetry/api/build/esnext/platform/node/index.d.ts +0 -2
  792. package/node_modules/@opentelemetry/api/build/esnext/platform/node/index.js +0 -17
  793. package/node_modules/@opentelemetry/api/build/esnext/platform/node/index.js.map +0 -1
  794. package/node_modules/@opentelemetry/api/build/esnext/propagation/NoopTextMapPropagator.d.ts +0 -13
  795. package/node_modules/@opentelemetry/api/build/esnext/propagation/NoopTextMapPropagator.js +0 -30
  796. package/node_modules/@opentelemetry/api/build/esnext/propagation/NoopTextMapPropagator.js.map +0 -1
  797. package/node_modules/@opentelemetry/api/build/esnext/propagation/TextMapPropagator.d.ts +0 -84
  798. package/node_modules/@opentelemetry/api/build/esnext/propagation/TextMapPropagator.js +0 -38
  799. package/node_modules/@opentelemetry/api/build/esnext/propagation/TextMapPropagator.js.map +0 -1
  800. package/node_modules/@opentelemetry/api/build/esnext/propagation-api.d.ts +0 -4
  801. package/node_modules/@opentelemetry/api/build/esnext/propagation-api.js +0 -21
  802. package/node_modules/@opentelemetry/api/build/esnext/propagation-api.js.map +0 -1
  803. package/node_modules/@opentelemetry/api/build/esnext/trace/NonRecordingSpan.d.ts +0 -28
  804. package/node_modules/@opentelemetry/api/build/esnext/trace/NonRecordingSpan.js +0 -65
  805. package/node_modules/@opentelemetry/api/build/esnext/trace/NonRecordingSpan.js.map +0 -1
  806. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracer.d.ts +0 -14
  807. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracer.js +0 -71
  808. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracer.js.map +0 -1
  809. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracerProvider.d.ts +0 -13
  810. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracerProvider.js +0 -28
  811. package/node_modules/@opentelemetry/api/build/esnext/trace/NoopTracerProvider.js.map +0 -1
  812. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracer.d.ts +0 -27
  813. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracer.js +0 -51
  814. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracer.js.map +0 -1
  815. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracerProvider.d.ts +0 -25
  816. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracerProvider.js +0 -50
  817. package/node_modules/@opentelemetry/api/build/esnext/trace/ProxyTracerProvider.js.map +0 -1
  818. package/node_modules/@opentelemetry/api/build/esnext/trace/Sampler.d.ts +0 -31
  819. package/node_modules/@opentelemetry/api/build/esnext/trace/Sampler.js +0 -17
  820. package/node_modules/@opentelemetry/api/build/esnext/trace/Sampler.js.map +0 -1
  821. package/node_modules/@opentelemetry/api/build/esnext/trace/SamplingResult.d.ts +0 -49
  822. package/node_modules/@opentelemetry/api/build/esnext/trace/SamplingResult.js +0 -39
  823. package/node_modules/@opentelemetry/api/build/esnext/trace/SamplingResult.js.map +0 -1
  824. package/node_modules/@opentelemetry/api/build/esnext/trace/SpanOptions.d.ts +0 -23
  825. package/node_modules/@opentelemetry/api/build/esnext/trace/SpanOptions.js +0 -17
  826. package/node_modules/@opentelemetry/api/build/esnext/trace/SpanOptions.js.map +0 -1
  827. package/node_modules/@opentelemetry/api/build/esnext/trace/attributes.d.ts +0 -10
  828. package/node_modules/@opentelemetry/api/build/esnext/trace/attributes.js +0 -17
  829. package/node_modules/@opentelemetry/api/build/esnext/trace/attributes.js.map +0 -1
  830. package/node_modules/@opentelemetry/api/build/esnext/trace/context-utils.d.ts +0 -41
  831. package/node_modules/@opentelemetry/api/build/esnext/trace/context-utils.js +0 -73
  832. package/node_modules/@opentelemetry/api/build/esnext/trace/context-utils.js.map +0 -1
  833. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-impl.d.ts +0 -22
  834. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-impl.js +0 -99
  835. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-impl.js.map +0 -1
  836. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-validators.d.ts +0 -15
  837. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-validators.js +0 -41
  838. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/tracestate-validators.js.map +0 -1
  839. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/utils.d.ts +0 -3
  840. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/utils.js +0 -20
  841. package/node_modules/@opentelemetry/api/build/esnext/trace/internal/utils.js.map +0 -1
  842. package/node_modules/@opentelemetry/api/build/esnext/trace/invalid-span-constants.d.ts +0 -5
  843. package/node_modules/@opentelemetry/api/build/esnext/trace/invalid-span-constants.js +0 -24
  844. package/node_modules/@opentelemetry/api/build/esnext/trace/invalid-span-constants.js.map +0 -1
  845. package/node_modules/@opentelemetry/api/build/esnext/trace/link.d.ts +0 -26
  846. package/node_modules/@opentelemetry/api/build/esnext/trace/link.js +0 -17
  847. package/node_modules/@opentelemetry/api/build/esnext/trace/link.js.map +0 -1
  848. package/node_modules/@opentelemetry/api/build/esnext/trace/span.d.ts +0 -120
  849. package/node_modules/@opentelemetry/api/build/esnext/trace/span.js +0 -17
  850. package/node_modules/@opentelemetry/api/build/esnext/trace/span.js.map +0 -1
  851. package/node_modules/@opentelemetry/api/build/esnext/trace/span_context.d.ts +0 -53
  852. package/node_modules/@opentelemetry/api/build/esnext/trace/span_context.js +0 -17
  853. package/node_modules/@opentelemetry/api/build/esnext/trace/span_context.js.map +0 -1
  854. package/node_modules/@opentelemetry/api/build/esnext/trace/span_kind.d.ts +0 -27
  855. package/node_modules/@opentelemetry/api/build/esnext/trace/span_kind.js +0 -43
  856. package/node_modules/@opentelemetry/api/build/esnext/trace/span_kind.js.map +0 -1
  857. package/node_modules/@opentelemetry/api/build/esnext/trace/spancontext-utils.d.ts +0 -17
  858. package/node_modules/@opentelemetry/api/build/esnext/trace/spancontext-utils.js +0 -42
  859. package/node_modules/@opentelemetry/api/build/esnext/trace/spancontext-utils.js.map +0 -1
  860. package/node_modules/@opentelemetry/api/build/esnext/trace/status.d.ts +0 -25
  861. package/node_modules/@opentelemetry/api/build/esnext/trace/status.js +0 -20
  862. package/node_modules/@opentelemetry/api/build/esnext/trace/status.js.map +0 -1
  863. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_flags.d.ts +0 -7
  864. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_flags.js +0 -23
  865. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_flags.js.map +0 -1
  866. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_state.d.ts +0 -38
  867. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_state.js +0 -17
  868. package/node_modules/@opentelemetry/api/build/esnext/trace/trace_state.js.map +0 -1
  869. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer.d.ts +0 -71
  870. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer.js +0 -17
  871. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer.js.map +0 -1
  872. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_options.d.ts +0 -10
  873. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_options.js +0 -17
  874. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_options.js.map +0 -1
  875. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_provider.d.ts +0 -21
  876. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_provider.js +0 -17
  877. package/node_modules/@opentelemetry/api/build/esnext/trace/tracer_provider.js.map +0 -1
  878. package/node_modules/@opentelemetry/api/build/esnext/trace-api.d.ts +0 -4
  879. package/node_modules/@opentelemetry/api/build/esnext/trace-api.js +0 -21
  880. package/node_modules/@opentelemetry/api/build/esnext/trace-api.js.map +0 -1
  881. package/node_modules/@opentelemetry/api/build/esnext/version.d.ts +0 -2
  882. package/node_modules/@opentelemetry/api/build/esnext/version.js +0 -18
  883. package/node_modules/@opentelemetry/api/build/esnext/version.js.map +0 -1
  884. package/node_modules/@opentelemetry/api/build/src/api/context.d.ts +0 -41
  885. package/node_modules/@opentelemetry/api/build/src/api/context.js +0 -81
  886. package/node_modules/@opentelemetry/api/build/src/api/context.js.map +0 -1
  887. package/node_modules/@opentelemetry/api/build/src/api/diag.d.ts +0 -30
  888. package/node_modules/@opentelemetry/api/build/src/api/diag.js +0 -93
  889. package/node_modules/@opentelemetry/api/build/src/api/diag.js.map +0 -1
  890. package/node_modules/@opentelemetry/api/build/src/api/metrics.d.ts +0 -28
  891. package/node_modules/@opentelemetry/api/build/src/api/metrics.js +0 -61
  892. package/node_modules/@opentelemetry/api/build/src/api/metrics.js.map +0 -1
  893. package/node_modules/@opentelemetry/api/build/src/api/propagation.d.ts +0 -49
  894. package/node_modules/@opentelemetry/api/build/src/api/propagation.js +0 -89
  895. package/node_modules/@opentelemetry/api/build/src/api/propagation.js.map +0 -1
  896. package/node_modules/@opentelemetry/api/build/src/api/trace.d.ts +0 -40
  897. package/node_modules/@opentelemetry/api/build/src/api/trace.js +0 -79
  898. package/node_modules/@opentelemetry/api/build/src/api/trace.js.map +0 -1
  899. package/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.d.ts +0 -29
  900. package/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js +0 -63
  901. package/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js.map +0 -1
  902. package/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.d.ts +0 -12
  903. package/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js +0 -55
  904. package/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js.map +0 -1
  905. package/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.d.ts +0 -5
  906. package/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js +0 -23
  907. package/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js.map +0 -1
  908. package/node_modules/@opentelemetry/api/build/src/baggage/types.d.ts +0 -60
  909. package/node_modules/@opentelemetry/api/build/src/baggage/types.js +0 -18
  910. package/node_modules/@opentelemetry/api/build/src/baggage/types.js.map +0 -1
  911. package/node_modules/@opentelemetry/api/build/src/baggage/utils.d.ts +0 -15
  912. package/node_modules/@opentelemetry/api/build/src/baggage/utils.js +0 -51
  913. package/node_modules/@opentelemetry/api/build/src/baggage/utils.js.map +0 -1
  914. package/node_modules/@opentelemetry/api/build/src/common/Attributes.d.ts +0 -15
  915. package/node_modules/@opentelemetry/api/build/src/common/Attributes.js +0 -18
  916. package/node_modules/@opentelemetry/api/build/src/common/Attributes.js.map +0 -1
  917. package/node_modules/@opentelemetry/api/build/src/common/Exception.d.ts +0 -26
  918. package/node_modules/@opentelemetry/api/build/src/common/Exception.js +0 -18
  919. package/node_modules/@opentelemetry/api/build/src/common/Exception.js.map +0 -1
  920. package/node_modules/@opentelemetry/api/build/src/common/Time.d.ts +0 -20
  921. package/node_modules/@opentelemetry/api/build/src/common/Time.js +0 -3
  922. package/node_modules/@opentelemetry/api/build/src/common/Time.js.map +0 -1
  923. package/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.d.ts +0 -9
  924. package/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js +0 -38
  925. package/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js.map +0 -1
  926. package/node_modules/@opentelemetry/api/build/src/context/context.d.ts +0 -6
  927. package/node_modules/@opentelemetry/api/build/src/context/context.js +0 -55
  928. package/node_modules/@opentelemetry/api/build/src/context/context.js.map +0 -1
  929. package/node_modules/@opentelemetry/api/build/src/context/types.d.ts +0 -52
  930. package/node_modules/@opentelemetry/api/build/src/context/types.js +0 -18
  931. package/node_modules/@opentelemetry/api/build/src/context/types.js.map +0 -1
  932. package/node_modules/@opentelemetry/api/build/src/context-api.d.ts +0 -4
  933. package/node_modules/@opentelemetry/api/build/src/context-api.js +0 -24
  934. package/node_modules/@opentelemetry/api/build/src/context-api.js.map +0 -1
  935. package/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.d.ts +0 -20
  936. package/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js +0 -59
  937. package/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js.map +0 -1
  938. package/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.d.ts +0 -38
  939. package/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js +0 -57
  940. package/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js.map +0 -1
  941. package/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.d.ts +0 -3
  942. package/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js +0 -45
  943. package/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js.map +0 -1
  944. package/node_modules/@opentelemetry/api/build/src/diag/internal/noopLogger.d.ts +0 -8
  945. package/node_modules/@opentelemetry/api/build/src/diag/internal/noopLogger.js +0 -35
  946. package/node_modules/@opentelemetry/api/build/src/diag/internal/noopLogger.js.map +0 -1
  947. package/node_modules/@opentelemetry/api/build/src/diag/types.d.ts +0 -100
  948. package/node_modules/@opentelemetry/api/build/src/diag/types.js +0 -44
  949. package/node_modules/@opentelemetry/api/build/src/diag/types.js.map +0 -1
  950. package/node_modules/@opentelemetry/api/build/src/diag-api.d.ts +0 -9
  951. package/node_modules/@opentelemetry/api/build/src/diag-api.js +0 -29
  952. package/node_modules/@opentelemetry/api/build/src/diag-api.js.map +0 -1
  953. package/node_modules/@opentelemetry/api/build/src/experimental/index.d.ts +0 -3
  954. package/node_modules/@opentelemetry/api/build/src/experimental/index.js +0 -22
  955. package/node_modules/@opentelemetry/api/build/src/experimental/index.js.map +0 -1
  956. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredOptions.d.ts +0 -13
  957. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredOptions.js +0 -18
  958. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredOptions.js.map +0 -1
  959. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredTracer.d.ts +0 -64
  960. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredTracer.js +0 -93
  961. package/node_modules/@opentelemetry/api/build/src/experimental/trace/SugaredTracer.js.map +0 -1
  962. package/node_modules/@opentelemetry/api/build/src/index.d.ts +0 -54
  963. package/node_modules/@opentelemetry/api/build/src/index.js +0 -81
  964. package/node_modules/@opentelemetry/api/build/src/index.js.map +0 -1
  965. package/node_modules/@opentelemetry/api/build/src/internal/global-utils.d.ts +0 -18
  966. package/node_modules/@opentelemetry/api/build/src/internal/global-utils.js +0 -64
  967. package/node_modules/@opentelemetry/api/build/src/internal/global-utils.js.map +0 -1
  968. package/node_modules/@opentelemetry/api/build/src/internal/semver.d.ts +0 -34
  969. package/node_modules/@opentelemetry/api/build/src/internal/semver.js +0 -122
  970. package/node_modules/@opentelemetry/api/build/src/internal/semver.js.map +0 -1
  971. package/node_modules/@opentelemetry/api/build/src/metrics/Meter.d.ts +0 -110
  972. package/node_modules/@opentelemetry/api/build/src/metrics/Meter.js +0 -18
  973. package/node_modules/@opentelemetry/api/build/src/metrics/Meter.js.map +0 -1
  974. package/node_modules/@opentelemetry/api/build/src/metrics/MeterProvider.d.ts +0 -17
  975. package/node_modules/@opentelemetry/api/build/src/metrics/MeterProvider.js +0 -18
  976. package/node_modules/@opentelemetry/api/build/src/metrics/MeterProvider.js.map +0 -1
  977. package/node_modules/@opentelemetry/api/build/src/metrics/Metric.d.ts +0 -115
  978. package/node_modules/@opentelemetry/api/build/src/metrics/Metric.js +0 -25
  979. package/node_modules/@opentelemetry/api/build/src/metrics/Metric.js.map +0 -1
  980. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.d.ts +0 -82
  981. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js +0 -127
  982. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js.map +0 -1
  983. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.d.ts +0 -11
  984. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js +0 -31
  985. package/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js.map +0 -1
  986. package/node_modules/@opentelemetry/api/build/src/metrics/ObservableResult.d.ts +0 -31
  987. package/node_modules/@opentelemetry/api/build/src/metrics/ObservableResult.js +0 -18
  988. package/node_modules/@opentelemetry/api/build/src/metrics/ObservableResult.js.map +0 -1
  989. package/node_modules/@opentelemetry/api/build/src/metrics-api.d.ts +0 -4
  990. package/node_modules/@opentelemetry/api/build/src/metrics-api.js +0 -24
  991. package/node_modules/@opentelemetry/api/build/src/metrics-api.js.map +0 -1
  992. package/node_modules/@opentelemetry/api/build/src/platform/browser/globalThis.d.ts +0 -10
  993. package/node_modules/@opentelemetry/api/build/src/platform/browser/globalThis.js +0 -38
  994. package/node_modules/@opentelemetry/api/build/src/platform/browser/globalThis.js.map +0 -1
  995. package/node_modules/@opentelemetry/api/build/src/platform/browser/index.d.ts +0 -2
  996. package/node_modules/@opentelemetry/api/build/src/platform/browser/index.js +0 -29
  997. package/node_modules/@opentelemetry/api/build/src/platform/browser/index.js.map +0 -1
  998. package/node_modules/@opentelemetry/api/build/src/platform/index.d.ts +0 -2
  999. package/node_modules/@opentelemetry/api/build/src/platform/index.js +0 -29
  1000. package/node_modules/@opentelemetry/api/build/src/platform/index.js.map +0 -1
  1001. package/node_modules/@opentelemetry/api/build/src/platform/node/globalThis.d.ts +0 -3
  1002. package/node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js +0 -22
  1003. package/node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js.map +0 -1
  1004. package/node_modules/@opentelemetry/api/build/src/platform/node/index.d.ts +0 -2
  1005. package/node_modules/@opentelemetry/api/build/src/platform/node/index.js +0 -29
  1006. package/node_modules/@opentelemetry/api/build/src/platform/node/index.js.map +0 -1
  1007. package/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.d.ts +0 -13
  1008. package/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js +0 -34
  1009. package/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js.map +0 -1
  1010. package/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.d.ts +0 -84
  1011. package/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js +0 -41
  1012. package/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js.map +0 -1
  1013. package/node_modules/@opentelemetry/api/build/src/propagation-api.d.ts +0 -4
  1014. package/node_modules/@opentelemetry/api/build/src/propagation-api.js +0 -24
  1015. package/node_modules/@opentelemetry/api/build/src/propagation-api.js.map +0 -1
  1016. package/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.d.ts +0 -28
  1017. package/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js +0 -69
  1018. package/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js.map +0 -1
  1019. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.d.ts +0 -14
  1020. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js +0 -75
  1021. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js.map +0 -1
  1022. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.d.ts +0 -13
  1023. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js +0 -32
  1024. package/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js.map +0 -1
  1025. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.d.ts +0 -27
  1026. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js +0 -55
  1027. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js.map +0 -1
  1028. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.d.ts +0 -25
  1029. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js +0 -54
  1030. package/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js.map +0 -1
  1031. package/node_modules/@opentelemetry/api/build/src/trace/Sampler.d.ts +0 -31
  1032. package/node_modules/@opentelemetry/api/build/src/trace/Sampler.js +0 -18
  1033. package/node_modules/@opentelemetry/api/build/src/trace/Sampler.js.map +0 -1
  1034. package/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.d.ts +0 -49
  1035. package/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js +0 -42
  1036. package/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js.map +0 -1
  1037. package/node_modules/@opentelemetry/api/build/src/trace/SpanOptions.d.ts +0 -23
  1038. package/node_modules/@opentelemetry/api/build/src/trace/SpanOptions.js +0 -18
  1039. package/node_modules/@opentelemetry/api/build/src/trace/SpanOptions.js.map +0 -1
  1040. package/node_modules/@opentelemetry/api/build/src/trace/attributes.d.ts +0 -10
  1041. package/node_modules/@opentelemetry/api/build/src/trace/attributes.js +0 -18
  1042. package/node_modules/@opentelemetry/api/build/src/trace/attributes.js.map +0 -1
  1043. package/node_modules/@opentelemetry/api/build/src/trace/context-utils.d.ts +0 -41
  1044. package/node_modules/@opentelemetry/api/build/src/trace/context-utils.js +0 -82
  1045. package/node_modules/@opentelemetry/api/build/src/trace/context-utils.js.map +0 -1
  1046. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.d.ts +0 -22
  1047. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js +0 -103
  1048. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js.map +0 -1
  1049. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.d.ts +0 -15
  1050. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js +0 -46
  1051. package/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js.map +0 -1
  1052. package/node_modules/@opentelemetry/api/build/src/trace/internal/utils.d.ts +0 -3
  1053. package/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js +0 -24
  1054. package/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js.map +0 -1
  1055. package/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.d.ts +0 -5
  1056. package/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js +0 -27
  1057. package/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js.map +0 -1
  1058. package/node_modules/@opentelemetry/api/build/src/trace/link.d.ts +0 -26
  1059. package/node_modules/@opentelemetry/api/build/src/trace/link.js +0 -18
  1060. package/node_modules/@opentelemetry/api/build/src/trace/link.js.map +0 -1
  1061. package/node_modules/@opentelemetry/api/build/src/trace/span.d.ts +0 -120
  1062. package/node_modules/@opentelemetry/api/build/src/trace/span.js +0 -18
  1063. package/node_modules/@opentelemetry/api/build/src/trace/span.js.map +0 -1
  1064. package/node_modules/@opentelemetry/api/build/src/trace/span_context.d.ts +0 -53
  1065. package/node_modules/@opentelemetry/api/build/src/trace/span_context.js +0 -18
  1066. package/node_modules/@opentelemetry/api/build/src/trace/span_context.js.map +0 -1
  1067. package/node_modules/@opentelemetry/api/build/src/trace/span_kind.d.ts +0 -27
  1068. package/node_modules/@opentelemetry/api/build/src/trace/span_kind.js +0 -46
  1069. package/node_modules/@opentelemetry/api/build/src/trace/span_kind.js.map +0 -1
  1070. package/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.d.ts +0 -17
  1071. package/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js +0 -49
  1072. package/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js.map +0 -1
  1073. package/node_modules/@opentelemetry/api/build/src/trace/status.d.ts +0 -25
  1074. package/node_modules/@opentelemetry/api/build/src/trace/status.js +0 -23
  1075. package/node_modules/@opentelemetry/api/build/src/trace/status.js.map +0 -1
  1076. package/node_modules/@opentelemetry/api/build/src/trace/trace_flags.d.ts +0 -7
  1077. package/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js +0 -26
  1078. package/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js.map +0 -1
  1079. package/node_modules/@opentelemetry/api/build/src/trace/trace_state.d.ts +0 -38
  1080. package/node_modules/@opentelemetry/api/build/src/trace/trace_state.js +0 -18
  1081. package/node_modules/@opentelemetry/api/build/src/trace/trace_state.js.map +0 -1
  1082. package/node_modules/@opentelemetry/api/build/src/trace/tracer.d.ts +0 -71
  1083. package/node_modules/@opentelemetry/api/build/src/trace/tracer.js +0 -18
  1084. package/node_modules/@opentelemetry/api/build/src/trace/tracer.js.map +0 -1
  1085. package/node_modules/@opentelemetry/api/build/src/trace/tracer_options.d.ts +0 -10
  1086. package/node_modules/@opentelemetry/api/build/src/trace/tracer_options.js +0 -18
  1087. package/node_modules/@opentelemetry/api/build/src/trace/tracer_options.js.map +0 -1
  1088. package/node_modules/@opentelemetry/api/build/src/trace/tracer_provider.d.ts +0 -21
  1089. package/node_modules/@opentelemetry/api/build/src/trace/tracer_provider.js +0 -18
  1090. package/node_modules/@opentelemetry/api/build/src/trace/tracer_provider.js.map +0 -1
  1091. package/node_modules/@opentelemetry/api/build/src/trace-api.d.ts +0 -4
  1092. package/node_modules/@opentelemetry/api/build/src/trace-api.js +0 -24
  1093. package/node_modules/@opentelemetry/api/build/src/trace-api.js.map +0 -1
  1094. package/node_modules/@opentelemetry/api/build/src/version.d.ts +0 -2
  1095. package/node_modules/@opentelemetry/api/build/src/version.js +0 -21
  1096. package/node_modules/@opentelemetry/api/build/src/version.js.map +0 -1
  1097. package/node_modules/@opentelemetry/api/package.json +0 -113
  1098. package/node_modules/glob/LICENSE.md +0 -63
  1099. package/node_modules/glob/README.md +0 -1203
  1100. package/node_modules/glob/dist/commonjs/glob.d.ts +0 -396
  1101. package/node_modules/glob/dist/commonjs/glob.d.ts.map +0 -1
  1102. package/node_modules/glob/dist/commonjs/glob.js +0 -248
  1103. package/node_modules/glob/dist/commonjs/glob.js.map +0 -1
  1104. package/node_modules/glob/dist/commonjs/has-magic.d.ts +0 -14
  1105. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +0 -1
  1106. package/node_modules/glob/dist/commonjs/has-magic.js +0 -27
  1107. package/node_modules/glob/dist/commonjs/has-magic.js.map +0 -1
  1108. package/node_modules/glob/dist/commonjs/ignore.d.ts +0 -24
  1109. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +0 -1
  1110. package/node_modules/glob/dist/commonjs/ignore.js +0 -119
  1111. package/node_modules/glob/dist/commonjs/ignore.js.map +0 -1
  1112. package/node_modules/glob/dist/commonjs/index.d.ts +0 -97
  1113. package/node_modules/glob/dist/commonjs/index.d.ts.map +0 -1
  1114. package/node_modules/glob/dist/commonjs/index.js +0 -68
  1115. package/node_modules/glob/dist/commonjs/index.js.map +0 -1
  1116. package/node_modules/glob/dist/commonjs/index.min.js +0 -4
  1117. package/node_modules/glob/dist/commonjs/index.min.js.map +0 -7
  1118. package/node_modules/glob/dist/commonjs/package.json +0 -3
  1119. package/node_modules/glob/dist/commonjs/pattern.d.ts +0 -79
  1120. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +0 -1
  1121. package/node_modules/glob/dist/commonjs/pattern.js +0 -223
  1122. package/node_modules/glob/dist/commonjs/pattern.js.map +0 -1
  1123. package/node_modules/glob/dist/commonjs/processor.d.ts +0 -59
  1124. package/node_modules/glob/dist/commonjs/processor.d.ts.map +0 -1
  1125. package/node_modules/glob/dist/commonjs/processor.js +0 -301
  1126. package/node_modules/glob/dist/commonjs/processor.js.map +0 -1
  1127. package/node_modules/glob/dist/commonjs/walker.d.ts +0 -97
  1128. package/node_modules/glob/dist/commonjs/walker.d.ts.map +0 -1
  1129. package/node_modules/glob/dist/commonjs/walker.js +0 -387
  1130. package/node_modules/glob/dist/commonjs/walker.js.map +0 -1
  1131. package/node_modules/glob/dist/esm/glob.d.ts +0 -396
  1132. package/node_modules/glob/dist/esm/glob.d.ts.map +0 -1
  1133. package/node_modules/glob/dist/esm/glob.js +0 -244
  1134. package/node_modules/glob/dist/esm/glob.js.map +0 -1
  1135. package/node_modules/glob/dist/esm/has-magic.d.ts +0 -14
  1136. package/node_modules/glob/dist/esm/has-magic.d.ts.map +0 -1
  1137. package/node_modules/glob/dist/esm/has-magic.js +0 -23
  1138. package/node_modules/glob/dist/esm/has-magic.js.map +0 -1
  1139. package/node_modules/glob/dist/esm/ignore.d.ts +0 -24
  1140. package/node_modules/glob/dist/esm/ignore.d.ts.map +0 -1
  1141. package/node_modules/glob/dist/esm/ignore.js +0 -115
  1142. package/node_modules/glob/dist/esm/ignore.js.map +0 -1
  1143. package/node_modules/glob/dist/esm/index.d.ts +0 -97
  1144. package/node_modules/glob/dist/esm/index.d.ts.map +0 -1
  1145. package/node_modules/glob/dist/esm/index.js +0 -55
  1146. package/node_modules/glob/dist/esm/index.js.map +0 -1
  1147. package/node_modules/glob/dist/esm/index.min.js +0 -4
  1148. package/node_modules/glob/dist/esm/index.min.js.map +0 -7
  1149. package/node_modules/glob/dist/esm/package.json +0 -3
  1150. package/node_modules/glob/dist/esm/pattern.d.ts +0 -79
  1151. package/node_modules/glob/dist/esm/pattern.d.ts.map +0 -1
  1152. package/node_modules/glob/dist/esm/pattern.js +0 -219
  1153. package/node_modules/glob/dist/esm/pattern.js.map +0 -1
  1154. package/node_modules/glob/dist/esm/processor.d.ts +0 -59
  1155. package/node_modules/glob/dist/esm/processor.d.ts.map +0 -1
  1156. package/node_modules/glob/dist/esm/processor.js +0 -294
  1157. package/node_modules/glob/dist/esm/processor.js.map +0 -1
  1158. package/node_modules/glob/dist/esm/walker.d.ts +0 -97
  1159. package/node_modules/glob/dist/esm/walker.d.ts.map +0 -1
  1160. package/node_modules/glob/dist/esm/walker.js +0 -381
  1161. package/node_modules/glob/dist/esm/walker.js.map +0 -1
  1162. package/node_modules/glob/package.json +0 -98
  1163. package/node_modules/minipass/LICENSE.md +0 -55
  1164. package/node_modules/minipass/README.md +0 -825
  1165. package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
  1166. package/node_modules/minipass/dist/commonjs/index.d.ts.map +0 -1
  1167. package/node_modules/minipass/dist/commonjs/index.js +0 -1038
  1168. package/node_modules/minipass/dist/commonjs/index.js.map +0 -1
  1169. package/node_modules/minipass/dist/commonjs/package.json +0 -3
  1170. package/node_modules/minipass/dist/esm/index.d.ts +0 -545
  1171. package/node_modules/minipass/dist/esm/index.d.ts.map +0 -1
  1172. package/node_modules/minipass/dist/esm/index.js +0 -1020
  1173. package/node_modules/minipass/dist/esm/index.js.map +0 -1
  1174. package/node_modules/minipass/dist/esm/package.json +0 -3
  1175. package/node_modules/minipass/package.json +0 -77
  1176. package/node_modules/path-scurry/LICENSE.md +0 -55
  1177. package/node_modules/path-scurry/README.md +0 -636
  1178. package/node_modules/path-scurry/dist/commonjs/index.d.ts +0 -1115
  1179. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +0 -1
  1180. package/node_modules/path-scurry/dist/commonjs/index.js +0 -2018
  1181. package/node_modules/path-scurry/dist/commonjs/index.js.map +0 -1
  1182. package/node_modules/path-scurry/dist/commonjs/package.json +0 -3
  1183. package/node_modules/path-scurry/dist/esm/index.d.ts +0 -1115
  1184. package/node_modules/path-scurry/dist/esm/index.d.ts.map +0 -1
  1185. package/node_modules/path-scurry/dist/esm/index.js +0 -1983
  1186. package/node_modules/path-scurry/dist/esm/index.js.map +0 -1
  1187. package/node_modules/path-scurry/dist/esm/package.json +0 -3
  1188. package/node_modules/path-scurry/package.json +0 -72
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-module-path.js","sourceRoot":"","sources":["../src/native-module-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAQlD,MAAM,UAAU,yBAAyB,CAAC,UAAkB,EAAE,OAAO,GAAiC,EAAE,EAAY;IACnH,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,IAAI,CAAC;QACJ,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC;QACzF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACR,4DAA4D;IAC7D,CAAC;IAED,UAAU,CAAC,IAAI,CACd,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,EACjC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAC/D,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAAA,CACvC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst moduleRequire = createRequire(import.meta.url);\nconst TUI_PACKAGE_NAME = \"@earendil-works/pi-tui\";\n\nexport interface NativeModuleCandidateOptions {\n\tmoduleUrl?: string;\n\texecPath?: string;\n\tresolvePackage?: (specifier: string) => string;\n}\n\nexport function getNativeModuleCandidates(nativePath: string, options: NativeModuleCandidateOptions = {}): string[] {\n\tconst moduleDir = dirname(fileURLToPath(options.moduleUrl ?? import.meta.url));\n\tconst candidates: string[] = [];\n\n\ttry {\n\t\tconst packageEntry = (options.resolvePackage ?? moduleRequire.resolve)(TUI_PACKAGE_NAME);\n\t\tcandidates.push(join(dirname(packageEntry), \"..\", nativePath));\n\t} catch {\n\t\t// Standalone binaries do not have an installed TUI package.\n\t}\n\n\tcandidates.push(\n\t\tjoin(moduleDir, \"..\", nativePath),\n\t\tjoin(moduleDir, nativePath),\n\t\tjoin(dirname(options.execPath ?? process.execPath), nativePath),\n\t);\n\treturn Array.from(new Set(candidates));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,mCAAmC,GAC5C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEjC,wBAAgB,wCAAwC,CACvD,QAAQ,EAAE,MAAM,GACd,mCAAmC,GAAG,SAAS,CASjD;AAMD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,MAAM,EACZ,4BAA4B,EAAE,OAAO,EACrC,cAAc,EAAE,OAAO,GACrB,MAAM,CAGR;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAEnH;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IAExB,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAGnE,IAAI,IAAI,IAAI,CAAC;IAEb;;;;;OAKG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG3D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,IAAI,OAAO,IAAI,MAAM,CAAC;IACtB,IAAI,IAAI,IAAI,MAAM,CAAC;IAGnB,IAAI,mBAAmB,IAAI,OAAO,CAAC;IAGnC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,UA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,OAAO,CAAC,6CAA6C;IAOrD,OAAO,CAAC,8CAA8C;IAQtD,OAAO,CAAC,gDAAgD;IAMxD,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,sBAAsB;IAM9B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA8BtB,UAAU,CAAC,KAAK,SAAO,EAAE,MAAM,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCzD;IAED,IAAI,IAAI,IAAI,CA8CX;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CASxB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAS1B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,SAAS,IAAI,IAAI,CAEhB;IAED,eAAe,IAAI,IAAI,CAEtB;IAED,WAAW,IAAI,IAAI,CAElB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAG5B;IAED,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAcjC;IAED,OAAO,CAAC,qBAAqB;CAM7B","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.setEncoding(\"utf8\");\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tprocess.stdout.write(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tprocess.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. In the npm package native/ is next to dist/; in compiled\n\t\t\t// binary archives native/ is copied next to the executable.\n\t\t\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tconst candidates = [\n\t\t\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\t\t\tpath.join(moduleDir, nativePath),\n\t\t\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t\t\t];\n\t\t\tfor (const modulePath of candidates) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tprocess.stdout.write(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t}\n\t}\n\n\twrite(data: string): void {\n\t\tprocess.stdout.write(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tprocess.stdout.write(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tprocess.stdout.write(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tprocess.stdout.write(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tprocess.stdout.write(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title\n\t\tprocess.stdout.write(`\\x1b]0;${title}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,mCAAmC,GAC5C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEjC,wBAAgB,wCAAwC,CACvD,QAAQ,EAAE,MAAM,GACd,mCAAmC,GAAG,SAAS,CASjD;AAMD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,MAAM,EACZ,4BAA4B,EAAE,OAAO,EACrC,cAAc,EAAE,OAAO,GACrB,MAAM,CAGR;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAEnH;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IAExB,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAGnE,IAAI,IAAI,IAAI,CAAC;IAEb;;;;;OAKG;IACH,UAAU,CAAC,KAAK,CA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OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAiCjE;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IA8BxB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,yCAAyC;IAwBjD,OAAO,CAAC,uCAAuC;IA0B/C,OAAO,CAAC,oCAAoC;IAK5C,OAAO,CAAC,sCAAsC;IAK9C,OAAO,CAAC,6CAA6C;IAOrD,OAAO,CAAC,8CAA8C;IAQtD,OAAO,CAAC,gDAAgD;IAMxD,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,sBAAsB;IAM9B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAwBtB,UAAU,CAAC,KAAK,SAAO,EAAE,MAAM,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCzD;IAED,IAAI,IAAI,IAAI,CA8CX;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CASxB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAS1B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,SAAS,IAAI,IAAI,CAEhB;IAED,eAAe,IAAI,IAAI,CAEtB;IAED,WAAW,IAAI,IAAI,CAElB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAG5B;IAED,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAcjC;IAED,OAAO,CAAC,qBAAqB;CAM7B","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { getNativeModuleCandidates } from \"./native-module-path.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.setEncoding(\"utf8\");\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tprocess.stdout.write(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tprocess.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. Installed packages resolve it from pi-tui; standalone\n\t\t\t// binaries resolve the copy next to the executable.\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tfor (const modulePath of getNativeModuleCandidates(nativePath)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tprocess.stdout.write(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t}\n\t}\n\n\twrite(data: string): void {\n\t\tprocess.stdout.write(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tprocess.stdout.write(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tprocess.stdout.write(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tprocess.stdout.write(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tprocess.stdout.write(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title\n\t\tprocess.stdout.write(`\\x1b]0;${title}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import * as fs from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import * as path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
4
  import { setKittyProtocolActive } from "./keys.js";
6
5
  import { isNativeModifierPressed } from "./native-modifiers.js";
6
+ import { getNativeModuleCandidates } from "./native-module-path.js";
7
7
  import { StdinBuffer } from "./stdin-buffer.js";
8
8
  const cjsRequire = createRequire(import.meta.url);
9
9
  const TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;
@@ -279,16 +279,10 @@ export class ProcessTerminal {
279
279
  if (arch !== "x64" && arch !== "arm64")
280
280
  return;
281
281
  // Dynamic require so non-Windows and bundled/browser paths never load the
282
- // native helper. In the npm package native/ is next to dist/; in compiled
283
- // binary archives native/ is copied next to the executable.
284
- const moduleDir = path.dirname(fileURLToPath(import.meta.url));
282
+ // native helper. Installed packages resolve it from pi-tui; standalone
283
+ // binaries resolve the copy next to the executable.
285
284
  const nativePath = path.join("native", "win32", "prebuilds", `win32-${arch}`, "win32-console-mode.node");
286
- const candidates = [
287
- path.join(moduleDir, "..", nativePath),
288
- path.join(moduleDir, nativePath),
289
- path.join(path.dirname(process.execPath), nativePath),
290
- ];
291
- for (const modulePath of candidates) {
285
+ for (const modulePath of getNativeModuleCandidates(nativePath)) {
292
286
  try {
293
287
  const helper = cjsRequire(modulePath);
294
288
  helper.enableVirtualTerminalInput?.();
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAElD,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAC5C,MAAM,iCAAiC,GAAG,gBAAgB,CAAC;AAC3D,MAAM,gCAAgC,GAAG,gBAAgB,CAAC;AAC1D,MAAM,2BAA2B,GAAG,YAAY,CAAC;AACjD,MAAM,qCAAqC,GAAG,CAAC,CAAC;AAChD,MAAM,8CAA8C,GAAG,GAAG,CAAC;AAC3D,MAAM,6BAA6B,GAAG,SAAS,qCAAqC,gBAAgB,CAAC;AAMrG,MAAM,UAAU,wCAAwC,CACvD,QAAgB,EACkC;IAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtD,IAAI,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM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,CACZ;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.setEncoding(\"utf8\");\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tprocess.stdout.write(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tprocess.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. In the npm package native/ is next to dist/; in compiled\n\t\t\t// binary archives native/ is copied next to the executable.\n\t\t\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tconst candidates = [\n\t\t\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\t\t\tpath.join(moduleDir, nativePath),\n\t\t\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t\t\t];\n\t\t\tfor (const modulePath of candidates) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tprocess.stdout.write(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t}\n\t}\n\n\twrite(data: string): void {\n\t\tprocess.stdout.write(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tprocess.stdout.write(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tprocess.stdout.write(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tprocess.stdout.write(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tprocess.stdout.write(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title\n\t\tprocess.stdout.write(`\\x1b]0;${title}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBA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;YAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACxD,CAAC;IAAA,CACD;IAEO,qBAAqB,GAAY;QACxC,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,OAAO,KAAK,CAAC;QACzC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { getNativeModuleCandidates } from \"./native-module-path.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.setEncoding(\"utf8\");\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tprocess.stdout.write(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tprocess.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tprocess.stdout.write(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. Installed packages resolve it from pi-tui; standalone\n\t\t\t// binaries resolve the copy next to the executable.\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tfor (const modulePath of getNativeModuleCandidates(nativePath)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tprocess.stdout.write(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tprocess.stdout.write(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t}\n\t}\n\n\twrite(data: string): void {\n\t\tprocess.stdout.write(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tprocess.stdout.write(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tprocess.stdout.write(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tprocess.stdout.write(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tprocess.stdout.write(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tprocess.stdout.write(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title\n\t\tprocess.stdout.write(`\\x1b]0;${title}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tprocess.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tui-alt-screen.d.ts","sourceRoot":"","sources":["../src/tui-alt-screen.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAY9C,OAAO,EACN,KAAK,SAAS,EAId,OAAO,EACP,KAAK,c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mB;IAkB3B,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,yBAAyB;IAoEjC,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,mBAAmB;YAqBb,wBAAwB;IAmCtC,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,qBAAqB;IAkD7B,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,cAAc;IAiDtB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;IAcxB,UAAmB,QAAQ,IAAI,IAAI,CAmElC;CACD","sourcesContent":["import {\n\tAltScreenSearchComponent,\n\ttype AltScreenSearchMatch,\n\tfindAltScreenSearchMatches,\n\tgetAltScreenSearchMatchKey,\n} from \"./alt-screen-search.ts\";\nimport { AltScreenFlashContainer } from \"./components/alt-screen-flash.ts\";\nimport { ScrollView } from \"./components/scroll-view.ts\";\nimport { getKeybindings } from \"./keybindings.ts\";\nimport { isKeyRelease } from \"./keys.ts\";\nimport {\n\tgetScrollbarGeometry,\n\tgetScrollViewBox,\n\tgetScrollViewsAt,\n\ttype LayoutFrame,\n\trenderLayoutFrame,\n\ttype ScrollbarGeometry,\n} from \"./layout.ts\";\nimport type { Terminal } from \"./terminal.ts\";\nimport {\n\tdeleteAllKittyImages,\n\tdeleteAllKittyPlacements,\n\tdeleteKittyImage,\n\tgetCapabilities,\n\tgetKittyImagePlacement,\n\ttype ImageProtocol,\n\tisImageLine,\n\tsetCapabilities,\n\ttype TerminalCapabilities,\n} from \"./terminal-image.ts\";\nimport {\n\ttype Component,\n\tCURSOR_MARKER,\n\tcompositeTuiLine,\n\ttype OverlayHandle,\n\tTuiBase,\n\ttype TuiStopOptions,\n\tVIEWPORT_TUI,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nimport {\n\textractAnsiCode,\n\tgetGraphemeCellRange,\n\tgetOsc8LinkAtColumn,\n\tgetWordSegmenter,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\tvisibleWidth,\n} from \"./utils.ts\";\n\nconst ENTER_ALT_SCREEN = \"\\x1b[?1049h\";\nconst EXIT_ALT_SCREEN = \"\\x1b[?1049l\";\nconst DISABLE_AUTOWRAP = \"\\x1b[?7l\";\nconst ENABLE_AUTOWRAP = \"\\x1b[?7h\";\nconst ENABLE_BUTTON_MOTION_MOUSE = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1004h\\x1b[?1006h\";\nconst ENABLE_ALL_MOTION_MOUSE = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1003h\\x1b[?1004h\\x1b[?1006h\";\nconst DISABLE_MOUSE = \"\\x1b[?1006l\\x1b[?1004l\\x1b[?1003l\\x1b[?1002l\\x1b[?1000l\";\nconst FOCUS_IN = \"\\x1b[I\";\nconst FOCUS_OUT = \"\\x1b[O\";\nconst BEGIN_SYNCHRONIZED_OUTPUT = \"\\x1b[?2026h\";\nconst END_SYNCHRONIZED_OUTPUT = \"\\x1b[?2026l\";\nconst OSC133_ZONE_PREFIX = /^(?:\\x1b\\]133;[ABC](?:\\x07|\\x1b\\\\))+/;\nconst OSC133_PROMPT_START = /^\\x1b\\]133;A(?:\\x07|\\x1b\\\\)/;\nconst PAGE_SCROLL_OVERLAP = 4;\nconst MAX_CACHED_OFFSCREEN_KITTY_IMAGES = 16;\nconst MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES = 32 * 1024 * 1024;\nconst MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES = 64 * 1024 * 1024;\nconst DOUBLE_CLICK_INTERVAL_MS = 500;\nconst wordSegmenter = getWordSegmenter();\n\ninterface CachedKittyImage {\n\ttransmissionGeneration: number;\n\ttransmissionBytes: number;\n\testimatedDecodedBytes: number;\n}\n\ninterface SelectionPoint {\n\trow: number;\n\tcol: number;\n\tscrollView?: ScrollView;\n\t/** Whether this point lies between terminal cells rather than on a cell. */\n\tboundary?: boolean;\n}\n\ninterface SelectionRange {\n\tstart: SelectionPoint;\n\tend: SelectionPoint;\n}\n\ntype SelectionGranularity = \"character\" | \"word\" | \"line\";\n\ninterface ClickTarget {\n\ttimestamp: number;\n\tcount: number;\n\trow: number;\n\tscrollView?: ScrollView;\n\twordStart: number;\n\twordEnd: number;\n}\n\ninterface SgrMouseEvent {\n\tbutton: number;\n\tx: number;\n\ty: number;\n\trelease: boolean;\n}\n\ninterface WheelEvent {\n\tdirection: -1 | 1;\n\tx: number;\n\ty: number;\n}\n\ninterface ScrollbarDrag {\n\tscrollView: ScrollView;\n\tgrabOffset: number;\n}\n\ninterface ScrollbarTarget {\n\tscrollView: ScrollView;\n\tgeometry: ScrollbarGeometry;\n}\n\ntype SearchSelectionMode = \"query\" | \"retain\" | \"next\" | \"previous\";\n\ninterface ActiveSearch {\n\tcomponent: AltScreenSearchComponent;\n\toverlay?: OverlayHandle;\n\tquery: string;\n\tmatches: AltScreenSearchMatch[];\n\tselectedIndex: number;\n\tselectedKey?: string;\n\tanchorRow: number;\n\tselectionMode: SearchSelectionMode;\n}\n\ninterface SearchHighlightRange {\n\tstartCol: number;\n\tendCol: number;\n\tcurrent: boolean;\n}\n\nexport interface TuiAltScreenOptions {\n\t/** Number of logical lines moved for each mouse-wheel event. */\n\twheelScrollLines?: number;\n\t/** Capture mouse events for viewport scrolling and application-owned text selection. */\n\tmouse?: boolean;\n\t/** Style a non-current transcript search match. */\n\tsearchMatchStyle?: (text: string) => string;\n\t/** Style the current transcript search match. */\n\tsearchCurrentMatchStyle?: (text: string) => string;\n\t/** Open an OSC 8 hyperlink activated with a primary-button click. */\n\topenUrl?: (url: string) => void;\n\t/** Handle an unmodified secondary-button press for clipboard paste. Currently enabled on Windows only. */\n\tonRightClickPaste?: () => void;\n\t/**\n\t * Copy selected text to the system clipboard. Return `true` on success; the caller flashes\n\t * an error otherwise. When omitted, the selection is copied via an OSC 52 write.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean>;\n}\n\n/** Alternate-screen TUI with a scrollable, application-owned viewport. */\nexport class TuiAltScreen extends TuiBase implements ViewportTUI {\n\treadonly mode = \"fullscreen\" as const;\n\treadonly [VIEWPORT_TUI] = true as const;\n\tprivate previousScreen: string[] = [];\n\tprivate lastDocument: string[] = [];\n\tprivate previousScreenWidth = 0;\n\tprivate previousScreenHeight = 0;\n\tprivate layoutRoot: Component | undefined;\n\tprivate currentLayout: LayoutFrame | undefined;\n\tprivate readonly implicitDocument: Component;\n\tprivate readonly implicitScrollView: ScrollView;\n\tprivate readonly flashes: AltScreenFlashContainer;\n\tprivate altScreenActive = false;\n\tprivate imageProtocol: ImageProtocol = null;\n\tprivate savedCapabilities?: TerminalCapabilities;\n\tprivate readonly uploadedKittyImages = new Map<number, CachedKittyImage>();\n\tprivate selectionAnchor?: SelectionPoint;\n\tprivate selectionFocus?: SelectionPoint;\n\tprivate selectionGranularity: SelectionGranularity = \"character\";\n\tprivate selectionInitialRange?: SelectionRange;\n\tprivate lastClick?: ClickTarget;\n\tprivate selectionDragPointer?: { x: number; y: number };\n\tprivate selectionAutoScrollDirection: -1 | 0 | 1 = 0;\n\tprivate selectionAutoScrollTimer?: NodeJS.Timeout;\n\tprivate selectionPressActive = false;\n\tprivate scrollbarDrag?: ScrollbarDrag;\n\tprivate scrollbarHover?: ScrollView;\n\tprivate activeSearch?: ActiveSearch;\n\tprivate pressedUrl?: string;\n\tprivate selectionDragged = false;\n\tprivate readonly wheelScrollLines: number;\n\tprivate readonly mouseEnabled: boolean;\n\tprivate readonly searchMatchStyle: (text: string) => string;\n\tprivate readonly searchCurrentMatchStyle: (text: string) => string;\n\tprivate readonly openUrl?: (url: string) => void;\n\tprivate readonly onRightClickPaste?: () => void;\n\tprivate readonly copySelection?: (text: string) => Promise<boolean>;\n\n\tconstructor(\n\t\tterminal: Terminal,\n\t\tshowHardwareCursor?: boolean,\n\t\tlogDirectory?: string,\n\t\toptions: TuiAltScreenOptions = {},\n\t) {\n\t\tsuper(terminal, showHardwareCursor, logDirectory);\n\t\tthis.implicitDocument = {\n\t\t\trender: (width) => super.render(width),\n\t\t\tinvalidate: () => {\n\t\t\t\tfor (const child of this.children) child.invalidate();\n\t\t\t},\n\t\t};\n\t\tthis.implicitScrollView = new ScrollView(this.implicitDocument, { follow: \"end\", primary: true });\n\t\tthis.flashes = new AltScreenFlashContainer(() => this.requestRender());\n\t\tthis.wheelScrollLines = Math.max(1, Math.floor(options.wheelScrollLines ?? 1));\n\t\tthis.mouseEnabled = options.mouse ?? true;\n\t\tthis.searchMatchStyle = options.searchMatchStyle ?? ((text) => `\\x1b[4m${text}\\x1b[24m`);\n\t\tthis.searchCurrentMatchStyle = options.searchCurrentMatchStyle ?? ((text) => `\\x1b[1;7m${text}\\x1b[22;27m`);\n\t\tthis.openUrl = options.openUrl;\n\t\tthis.onRightClickPaste = options.onRightClickPaste;\n\t\tthis.copySelection = options.copySelection;\n\t\tthis.addInputListener((data) => this.handleViewportInput(data));\n\t}\n\n\tget viewportTop(): number {\n\t\treturn this.getPrimaryScrollView().scrollTop;\n\t}\n\n\tget isFollowingOutput(): boolean {\n\t\treturn this.getPrimaryScrollView().isFollowingEnd;\n\t}\n\n\tsetLayoutRoot(component: Component | undefined): void {\n\t\tif (this.layoutRoot === component) return;\n\t\tthis.layoutRoot = component;\n\t\tthis.currentLayout = undefined;\n\t\tthis.requestRender();\n\t}\n\n\toverride render(width: number): string[] {\n\t\treturn this.layoutRoot?.render(width) ?? super.render(width);\n\t}\n\n\tprotected override getMountedRoots(): readonly Component[] {\n\t\treturn this.layoutRoot ? [this.layoutRoot] : this.children;\n\t}\n\n\tprivate getPrimaryScrollView(): ScrollView {\n\t\treturn this.currentLayout?.primaryScrollView ?? this.implicitScrollView;\n\t}\n\n\tprotected override beforeTerminalStart(): void {\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.stopScrollbarHover();\n\t\tthis.stopScrollbarDrag();\n\t\tthis.flashes.dispose();\n\t\tthis.altScreenActive = true;\n\t\tconst capabilities = getCapabilities();\n\t\tthis.imageProtocol = capabilities.images;\n\t\tthis.uploadedKittyImages.clear();\n\t\tif (capabilities.images === \"iterm2\") {\n\t\t\tthis.savedCapabilities = capabilities;\n\t\t\tsetCapabilities({ ...capabilities, images: null });\n\t\t\tthis.invalidate();\n\t\t}\n\t\tthis.lastDocument = [];\n\t\tthis.selectionAnchor = undefined;\n\t\tthis.selectionFocus = undefined;\n\t\tthis.selectionGranularity = \"character\";\n\t\tthis.selectionInitialRange = undefined;\n\t\tthis.lastClick = undefined;\n\t\tthis.pressedUrl = undefined;\n\t\tthis.selectionDragged = false;\n\t\tthis.resetRenderState();\n\t\tconst term = process.env.TERM?.toLowerCase() ?? \"\";\n\t\t// Multiplexers can lag when every pointer movement is forwarded. Button-motion\n\t\t// tracking preserves clicks, wheel events, selections, and scrollbar dragging.\n\t\tconst mouseSequence =\n\t\t\tprocess.env.TMUX !== undefined ||\n\t\t\tprocess.env.ZELLIJ !== undefined ||\n\t\t\tprocess.env.STY !== undefined ||\n\t\t\tterm.startsWith(\"tmux\") ||\n\t\t\tterm.startsWith(\"screen\")\n\t\t\t\t? ENABLE_BUTTON_MOTION_MOUSE\n\t\t\t\t: ENABLE_ALL_MOTION_MOUSE;\n\t\tthis.terminal.write(\n\t\t\t`${ENTER_ALT_SCREEN}${DISABLE_AUTOWRAP}${this.mouseEnabled ? mouseSequence : \"\"}\\x1b[2J\\x1b[H\\x1b[?25l`,\n\t\t);\n\t}\n\n\tprotected override beforeTerminalStop(_options: TuiStopOptions): void {\n\t\tthis.closeSearch();\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.stopScrollbarHover();\n\t\tthis.stopScrollbarDrag();\n\t\tthis.flashes.dispose();\n\t\tif (!this.altScreenActive) return;\n\t\tthis.terminal.write(\n\t\t\t`${BEGIN_SYNCHRONIZED_OUTPUT}${this.deleteKittyImages()}${this.mouseEnabled ? DISABLE_MOUSE : \"\"}${ENABLE_AUTOWRAP}${END_SYNCHRONIZED_OUTPUT}`,\n\t\t);\n\t\tthis.uploadedKittyImages.clear();\n\t}\n\n\tprotected override afterTerminalStop(options: TuiStopOptions): void {\n\t\tif (!this.altScreenActive) return;\n\t\tthis.altScreenActive = false;\n\t\tif (options.preserveScreen) {\n\t\t\tthis.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`);\n\t\t} else {\n\t\t\tconst width = Math.max(1, this.terminal.columns);\n\t\t\tconst documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, \"\"));\n\t\t\tthis.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, \"\"))).map(\n\t\t\t\t(line) => (isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true)),\n\t\t\t);\n\t\t\tlet buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;\n\t\t\tfor (let row = 0; row < this.lastDocument.length; row++) {\n\t\t\t\tif (row > 0) buffer += \"\\r\\n\";\n\t\t\t\tbuffer += `\\r\\x1b[2K${this.lastDocument[row] ?? \"\"}`;\n\t\t\t}\n\t\t\tbuffer += `\\x1b[0m${ENABLE_AUTOWRAP}\\r\\n\\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`;\n\t\t\tthis.terminal.write(buffer);\n\t\t}\n\t\tif (this.savedCapabilities) {\n\t\t\tsetCapabilities(this.savedCapabilities);\n\t\t\tthis.savedCapabilities = undefined;\n\t\t}\n\t}\n\n\tprivate deleteKittyImages(): string {\n\t\treturn this.imageProtocol === \"kitty\" ? deleteAllKittyImages() : \"\";\n\t}\n\n\tprivate prepareKittyScreen(screen: string[]): { lines: string[]; evictedImageDeletion: string } {\n\t\tconst visibleImageIds = new Set<number>();\n\t\tconst lines = screen.map((line) => {\n\t\t\tconst placement = getKittyImagePlacement(line);\n\t\t\tif (!placement) return line;\n\t\t\tvisibleImageIds.add(placement.imageId);\n\n\t\t\tconst cachedImage = this.uploadedKittyImages.get(placement.imageId);\n\t\t\tconst nextCachedImage = {\n\t\t\t\ttransmissionGeneration: placement.transmissionGeneration,\n\t\t\t\ttransmissionBytes: placement.transmissionBytes,\n\t\t\t\testimatedDecodedBytes: placement.estimatedDecodedBytes,\n\t\t\t};\n\t\t\tif (cachedImage) this.uploadedKittyImages.delete(placement.imageId);\n\t\t\tthis.uploadedKittyImages.set(placement.imageId, nextCachedImage);\n\n\t\t\treturn cachedImage?.transmissionGeneration === placement.transmissionGeneration\n\t\t\t\t? placement.replacementLine\n\t\t\t\t: line;\n\t\t});\n\n\t\tlet cachedOffscreenImageCount = 0;\n\t\tlet cachedOffscreenTransmissionBytes = 0;\n\t\tlet cachedOffscreenDecodedBytes = 0;\n\t\tfor (const [imageId, cachedImage] of this.uploadedKittyImages) {\n\t\t\tif (visibleImageIds.has(imageId)) continue;\n\t\t\tcachedOffscreenImageCount += 1;\n\t\t\tcachedOffscreenTransmissionBytes += cachedImage.transmissionBytes;\n\t\t\tcachedOffscreenDecodedBytes += cachedImage.estimatedDecodedBytes;\n\t\t}\n\n\t\tlet evictedImageDeletion = \"\";\n\t\tfor (const [imageId, cachedImage] of this.uploadedKittyImages) {\n\t\t\tif (\n\t\t\t\tcachedOffscreenImageCount <= MAX_CACHED_OFFSCREEN_KITTY_IMAGES &&\n\t\t\t\tcachedOffscreenTransmissionBytes <= MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES &&\n\t\t\t\tcachedOffscreenDecodedBytes <= MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (visibleImageIds.has(imageId)) continue;\n\t\t\tevictedImageDeletion += deleteKittyImage(imageId);\n\t\t\tthis.uploadedKittyImages.delete(imageId);\n\t\t\tcachedOffscreenImageCount -= 1;\n\t\t\tcachedOffscreenTransmissionBytes -= cachedImage.transmissionBytes;\n\t\t\tcachedOffscreenDecodedBytes -= cachedImage.estimatedDecodedBytes;\n\t\t}\n\t\treturn { lines, evictedImageDeletion };\n\t}\n\n\tprotected override resetRenderState(): void {\n\t\tthis.previousScreen = [];\n\t\tthis.previousScreenWidth = 0;\n\t\tthis.previousScreenHeight = 0;\n\t\tthis.currentLayout = undefined;\n\t}\n\n\tscrollBy(lines: number): void {\n\t\tthis.getPrimaryScrollView().scrollBy(lines);\n\t\tthis.requestRender();\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.getPrimaryScrollView().scrollToStart();\n\t\tthis.requestRender();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.getPrimaryScrollView().scrollToEnd();\n\t\tthis.requestRender();\n\t}\n\n\tprivate scrollToPrompt(direction: -1 | 1): void {\n\t\tif (!this.currentLayout) return;\n\t\tconst scrollView = this.getPrimaryScrollView();\n\t\tconst lines = getScrollViewBox(this.currentLayout, scrollView)?.scrollContentLines;\n\t\tif (!lines) return;\n\n\t\tfor (let row = scrollView.scrollTop + direction; row >= 0 && row < lines.length; row += direction) {\n\t\t\tif (!OSC133_PROMPT_START.test(lines[row] ?? \"\")) continue;\n\t\t\tscrollView.scrollTo(row);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate openSearch(): void {\n\t\tif (this.activeSearch) {\n\t\t\tthis.activeSearch.overlay?.focus();\n\t\t\treturn;\n\t\t}\n\t\tconst component = new AltScreenSearchComponent((query) => this.updateSearchQuery(query));\n\t\tconst search: ActiveSearch = {\n\t\t\tcomponent,\n\t\t\tquery: \"\",\n\t\t\tmatches: [],\n\t\t\tselectedIndex: -1,\n\t\t\tanchorRow: this.getPrimaryScrollView().scrollTop,\n\t\t\tselectionMode: \"query\",\n\t\t};\n\t\tthis.activeSearch = search;\n\t\tsearch.overlay = this.showOverlay(component, {\n\t\t\tanchor: \"top-right\",\n\t\t\twidth: \"40%\",\n\t\t\tminWidth: 24,\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeSearch(): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search) return;\n\t\tthis.activeSearch = undefined;\n\t\tsearch.overlay?.hide();\n\t\tthis.requestRender();\n\t}\n\n\tprivate updateSearchQuery(query: string): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search || query === search.query) return;\n\t\tconst selected = search.matches[search.selectedIndex];\n\t\tsearch.anchorRow = selected?.segments[0]?.row ?? this.getPrimaryScrollView().scrollTop;\n\t\tsearch.query = query;\n\t\tsearch.selectionMode = \"query\";\n\t\tsearch.component.setResult(-1, 0);\n\t\tthis.requestRender();\n\t}\n\n\tprivate navigateSearch(direction: -1 | 1): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search?.query) return;\n\t\tsearch.selectionMode = direction < 0 ? \"previous\" : \"next\";\n\t\tthis.requestRender();\n\t}\n\n\tprivate refreshSearch(layout: LayoutFrame): boolean {\n\t\tconst search = this.activeSearch;\n\t\tif (!search) return false;\n\t\tconst scrollView = layout.primaryScrollView ?? this.implicitScrollView;\n\t\tconst box = getScrollViewBox(layout, scrollView);\n\t\tconst lines = box?.scrollContentLines;\n\t\tif (!lines || !search.query.trim()) {\n\t\t\tsearch.matches = [];\n\t\t\tsearch.selectedIndex = -1;\n\t\t\tsearch.selectedKey = undefined;\n\t\t\tsearch.selectionMode = \"retain\";\n\t\t\tsearch.component.setResult(-1, 0);\n\t\t\treturn false;\n\t\t}\n\n\t\tconst shouldRevealSelection = search.selectionMode !== \"retain\";\n\t\tconst matches = findAltScreenSearchMatches(lines, search.query);\n\t\tconst exactIndex = search.selectedKey\n\t\t\t? matches.findIndex((match) => getAltScreenSearchMatchKey(match) === search.selectedKey)\n\t\t\t: -1;\n\t\tlet selectedIndex = -1;\n\t\tif (matches.length > 0) {\n\t\t\tif (search.selectionMode === \"query\") {\n\t\t\t\tselectedIndex = matches.findIndex((match) => (match.segments[0]?.row ?? 0) >= search.anchorRow);\n\t\t\t\tif (selectedIndex < 0) selectedIndex = 0;\n\t\t\t} else if (search.selectionMode === \"next\") {\n\t\t\t\tconst baseIndex = exactIndex >= 0 ? exactIndex : Math.min(search.selectedIndex, matches.length - 1);\n\t\t\t\tselectedIndex = baseIndex < 0 ? 0 : (baseIndex + 1) % matches.length;\n\t\t\t} else if (search.selectionMode === \"previous\") {\n\t\t\t\tconst baseIndex = exactIndex >= 0 ? exactIndex : Math.min(search.selectedIndex, matches.length - 1);\n\t\t\t\tselectedIndex = baseIndex < 0 ? matches.length - 1 : (baseIndex - 1 + matches.length) % matches.length;\n\t\t\t} else {\n\t\t\t\tselectedIndex =\n\t\t\t\t\texactIndex >= 0 ? exactIndex : Math.min(Math.max(0, search.selectedIndex), matches.length - 1);\n\t\t\t}\n\t\t}\n\n\t\tsearch.matches = matches;\n\t\tsearch.selectedIndex = selectedIndex;\n\t\tsearch.selectedKey = selectedIndex >= 0 ? getAltScreenSearchMatchKey(matches[selectedIndex]!) : undefined;\n\t\tsearch.selectionMode = \"retain\";\n\t\tsearch.component.setResult(selectedIndex, matches.length);\n\t\tif (!shouldRevealSelection) return false;\n\n\t\tconst selected = matches[selectedIndex];\n\t\tconst firstSegment = selected?.segments[0];\n\t\tconst lastSegment = selected?.segments[selected.segments.length - 1];\n\t\tif (!box || !firstSegment || !lastSegment || scrollView.viewportHeight <= 0) return false;\n\t\tconst before = scrollView.scrollTop;\n\t\tconst visibleBottom = before + scrollView.viewportHeight - 1;\n\t\tlet target = before;\n\t\tif (firstSegment.row < before || lastSegment.row > visibleBottom) {\n\t\t\ttarget = firstSegment.row - Math.floor(scrollView.viewportHeight / 3);\n\t\t}\n\t\tscrollView.scrollTo(target, { disableFollow: true });\n\t\treturn scrollView.scrollTop !== before;\n\t}\n\n\t/** Show a transient message in the alternate-screen flash stack. */\n\tflash(message: string, durationMs?: number): void {\n\t\tthis.flashes.flash(message, durationMs);\n\t}\n\n\tprivate shouldDeferViewportInputToOverlay(): boolean {\n\t\treturn this.isOverlayFocused() && this.activeSearch?.overlay?.isFocused() !== true;\n\t}\n\n\tprivate handleViewportInput(data: string): { consume?: boolean } | undefined {\n\t\tif (data === FOCUS_OUT) {\n\t\t\tconst hadActiveSelection = this.selectionPressActive;\n\t\t\tconst hadNonEmptyActiveSelection = hadActiveSelection && this.getSelectionBounds() !== undefined;\n\t\t\tthis.selectionPressActive = false;\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\tthis.stopScrollbarHover();\n\t\t\tthis.stopScrollbarDrag();\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tthis.selectionDragged = false;\n\t\t\tif (hadActiveSelection) {\n\t\t\t\tthis.selectionAnchor = undefined;\n\t\t\t\tthis.selectionFocus = undefined;\n\t\t\t\tthis.selectionGranularity = \"character\";\n\t\t\t\tthis.selectionInitialRange = undefined;\n\t\t\t\tif (hadNonEmptyActiveSelection) this.requestRender();\n\t\t\t}\n\t\t\tthis.lastClick = undefined;\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (data === FOCUS_IN) return { consume: true };\n\n\t\tconst wheelEvent = this.parseWheelEvent(data);\n\t\tif (wheelEvent) {\n\t\t\tif (this.shouldDeferViewportInputToOverlay()) return undefined;\n\t\t\tthis.routeWheel(wheelEvent);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tconst mouseEvent = this.parseSgrMouseEvent(data);\n\t\tif (mouseEvent) {\n\t\t\tif (this.handleRightClickPaste(mouseEvent)) return { consume: true };\n\t\t\tconst handled = this.handleScrollbarMouseEvent(mouseEvent);\n\t\t\tif (!this.scrollbarDrag) this.updateScrollbarHover(mouseEvent.x, mouseEvent.y);\n\t\t\tif (!handled) this.handleSelectionMouseEvent(mouseEvent);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (this.isMouseSequence(data)) return { consume: true };\n\n\t\tconst keybindings = getKeybindings();\n\t\tconst isRelease = isKeyRelease(data);\n\t\tif (keybindings.matches(data, \"tui.altScreen.search\")) {\n\t\t\tif (!isRelease) this.openSearch();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (this.activeSearch?.overlay?.isFocused()) {\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchNext\")) {\n\t\t\t\tif (!isRelease) this.navigateSearch(1);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchPrevious\")) {\n\t\t\t\tif (!isRelease) this.navigateSearch(-1);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchClose\")) {\n\t\t\t\tif (!isRelease) this.closeSearch();\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t}\n\t\tif (this.shouldDeferViewportInputToOverlay()) return undefined;\n\t\tif (keybindings.matches(data, \"tui.altScreen.pageUp\")) {\n\t\t\tif (!isRelease) {\n\t\t\t\tthis.scrollBy(-Math.max(1, this.getPrimaryScrollView().viewportHeight - PAGE_SCROLL_OVERLAP));\n\t\t\t}\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.pageDown\")) {\n\t\t\tif (!isRelease) {\n\t\t\t\tthis.scrollBy(Math.max(1, this.getPrimaryScrollView().viewportHeight - PAGE_SCROLL_OVERLAP));\n\t\t\t}\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.halfPageUp\")) {\n\t\t\tif (!isRelease) this.scrollBy(-Math.max(1, Math.floor(this.getPrimaryScrollView().viewportHeight / 2)));\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.halfPageDown\")) {\n\t\t\tif (!isRelease) this.scrollBy(Math.max(1, Math.floor(this.getPrimaryScrollView().viewportHeight / 2)));\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.lineUp\")) {\n\t\t\tif (!isRelease) this.scrollBy(-1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.lineDown\")) {\n\t\t\tif (!isRelease) this.scrollBy(1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.previousPrompt\")) {\n\t\t\tif (!isRelease) this.scrollToPrompt(-1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.nextPrompt\")) {\n\t\t\tif (!isRelease) this.scrollToPrompt(1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.top\")) {\n\t\t\tif (!isRelease) this.scrollToTop();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.bottom\")) {\n\t\t\tif (!isRelease) this.scrollToBottom();\n\t\t\treturn { consume: true };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate parseWheelEvent(data: string): WheelEvent | undefined {\n\t\tconst sgr = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)[Mm]$/.exec(data);\n\t\tif (sgr) {\n\t\t\tconst button = Number.parseInt(sgr[1], 10);\n\t\t\tif ((button & 64) === 0) return undefined;\n\t\t\tconst direction = button & 3;\n\t\t\tif (direction !== 0 && direction !== 1) return undefined;\n\t\t\treturn {\n\t\t\t\tdirection: direction === 0 ? -1 : 1,\n\t\t\t\tx: Number.parseInt(sgr[2], 10) - 1,\n\t\t\t\ty: Number.parseInt(sgr[3], 10) - 1,\n\t\t\t};\n\t\t}\n\t\tif (data.length === 6 && data.startsWith(\"\\x1b[M\")) {\n\t\t\tconst button = data.charCodeAt(3) - 32;\n\t\t\tif ((button & 64) === 0) return undefined;\n\t\t\tconst direction = button & 3;\n\t\t\tif (direction !== 0 && direction !== 1) return undefined;\n\t\t\treturn {\n\t\t\t\tdirection: direction === 0 ? -1 : 1,\n\t\t\t\tx: data.charCodeAt(4) - 33,\n\t\t\t\ty: data.charCodeAt(5) - 33,\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate routeWheel(event: WheelEvent): void {\n\t\tlet remaining = event.direction * this.wheelScrollLines;\n\t\tconst seen = new Set<ScrollView>();\n\t\tfor (const scrollView of this.currentLayout ? getScrollViewsAt(this.currentLayout, event.x, event.y) : []) {\n\t\t\tseen.add(scrollView);\n\t\t\tremaining = scrollView.scrollBy(remaining);\n\t\t\tif (remaining === 0 || scrollView.overscroll === \"contain\") break;\n\t\t}\n\t\tconst primary = this.getPrimaryScrollView();\n\t\tif (remaining !== 0 && !seen.has(primary)) primary.scrollBy(remaining);\n\t\tthis.updateScrollbarHover(event.x, event.y);\n\t\tthis.requestRender();\n\t}\n\n\tprivate parseSgrMouseEvent(data: string): SgrMouseEvent | undefined {\n\t\tconst match = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)([Mm])$/.exec(data);\n\t\tif (!match) return undefined;\n\t\treturn {\n\t\t\tbutton: Number.parseInt(match[1], 10),\n\t\t\tx: Number.parseInt(match[2], 10) - 1,\n\t\t\ty: Number.parseInt(match[3], 10) - 1,\n\t\t\trelease: match[4] === \"m\",\n\t\t};\n\t}\n\n\tprivate handleRightClickPaste(event: SgrMouseEvent): boolean {\n\t\tif (!this.onRightClickPaste || process.platform !== \"win32\" || event.release || event.button !== 2) {\n\t\t\treturn false;\n\t\t}\n\t\ttry {\n\t\t\tthis.onRightClickPaste();\n\t\t} catch {\n\t\t\t// Clipboard paste is best-effort.\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate getScrollbarTargetAt(x: number, y: number): ScrollbarTarget | undefined {\n\t\tif (this.hasOverlay() || !this.currentLayout) return undefined;\n\t\tfor (const scrollView of getScrollViewsAt(this.currentLayout, x, y)) {\n\t\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\t\tconst geometry = box ? getScrollbarGeometry(box) : undefined;\n\t\t\tif (\n\t\t\t\tgeometry &&\n\t\t\t\tx === geometry.column &&\n\t\t\t\ty >= geometry.thumbTop &&\n\t\t\t\ty < geometry.thumbTop + geometry.thumbHeight\n\t\t\t) {\n\t\t\t\treturn { scrollView, geometry };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setScrollbarHover(scrollView: ScrollView | undefined): void {\n\t\tif (scrollView === this.scrollbarHover) return;\n\t\tthis.scrollbarHover?.setScrollbarActive(false);\n\t\tthis.scrollbarHover = scrollView;\n\t\tthis.scrollbarHover?.setScrollbarActive(true);\n\t}\n\n\tprivate updateScrollbarHover(x: number, y: number): void {\n\t\tthis.setScrollbarHover(this.getScrollbarTargetAt(x, y)?.scrollView);\n\t}\n\n\tprivate stopScrollbarHover(): void {\n\t\tthis.setScrollbarHover(undefined);\n\t}\n\n\tprivate handleScrollbarMouseEvent(event: SgrMouseEvent): boolean {\n\t\tif (this.scrollbarDrag) {\n\t\t\tif (event.release) {\n\t\t\t\tthis.stopScrollbarDrag();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst box = this.currentLayout\n\t\t\t\t? getScrollViewBox(this.currentLayout, this.scrollbarDrag.scrollView)\n\t\t\t\t: undefined;\n\t\t\tconst geometry = box ? getScrollbarGeometry(box) : undefined;\n\t\t\tif (geometry) {\n\t\t\t\tconst maxThumbOffset = geometry.trackHeight - geometry.thumbHeight;\n\t\t\t\tconst thumbOffset = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min(maxThumbOffset, event.y - geometry.trackTop - this.scrollbarDrag.grabOffset),\n\t\t\t\t);\n\t\t\t\tconst scrollTop =\n\t\t\t\t\tmaxThumbOffset === 0 ? 0 : Math.round((thumbOffset / maxThumbOffset) * geometry.maxScrollTop);\n\t\t\t\tthis.scrollbarDrag.scrollView.scrollTo(scrollTop);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (event.release || (event.button & 32) !== 0 || (event.button & 3) !== 0) return false;\n\t\tconst target = this.getScrollbarTargetAt(event.x, event.y);\n\t\tif (!target) return false;\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.selectionAnchor = undefined;\n\t\tthis.selectionFocus = undefined;\n\t\tthis.selectionGranularity = \"character\";\n\t\tthis.selectionInitialRange = undefined;\n\t\tthis.lastClick = undefined;\n\t\tthis.pressedUrl = undefined;\n\t\tthis.selectionDragged = false;\n\t\tthis.setScrollbarHover(target.scrollView);\n\t\tthis.scrollbarDrag = {\n\t\t\tscrollView: target.scrollView,\n\t\t\tgrabOffset: event.y - target.geometry.thumbTop,\n\t\t};\n\t\treturn true;\n\t}\n\n\tprivate stopScrollbarDrag(): void {\n\t\tthis.scrollbarDrag = undefined;\n\t}\n\n\tprivate getScrollSelectionPoint(scrollView: ScrollView, x: number, y: number): SelectionPoint | undefined {\n\t\tif (!this.currentLayout) return undefined;\n\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\tif (!box || box.rect.height <= 0 || box.clip.height <= 0) return undefined;\n\t\tconst visibleTop = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst visibleBottom = Math.min(\n\t\t\tthis.terminal.rows - 1,\n\t\t\tbox.rect.y + box.rect.height - 1,\n\t\t\tbox.clip.y + box.clip.height - 1,\n\t\t);\n\t\tif (visibleBottom < visibleTop) return undefined;\n\t\tconst pointerRow = Math.max(visibleTop, Math.min(visibleBottom, y));\n\t\tconst maxContentRow = Math.max(0, (box.scrollContentLines?.length ?? 1) - 1);\n\t\treturn {\n\t\t\trow: Math.max(0, Math.min(maxContentRow, scrollView.scrollTop + pointerRow - box.rect.y)),\n\t\t\tcol: Math.max(0, Math.min(box.rect.width - 1, x - box.rect.x)),\n\t\t\tscrollView,\n\t\t};\n\t}\n\n\tprivate getSelectionPoint(event: SgrMouseEvent, scrollView?: ScrollView): SelectionPoint {\n\t\tif (scrollView) {\n\t\t\tconst point = this.getScrollSelectionPoint(scrollView, event.x, event.y);\n\t\t\tif (point) return point;\n\t\t}\n\t\treturn {\n\t\t\trow: Math.max(0, Math.min(this.terminal.rows - 1, event.y)),\n\t\t\tcol: Math.max(0, Math.min(this.terminal.columns - 1, event.x)),\n\t\t};\n\t}\n\n\tprivate getSelectionSourceLine(point: SelectionPoint): string {\n\t\tif (point.scrollView && this.currentLayout) {\n\t\t\tconst lines = getScrollViewBox(this.currentLayout, point.scrollView)?.scrollContentLines;\n\t\t\tif (lines) return lines[point.row] ?? \"\";\n\t\t}\n\t\treturn this.previousScreen[point.row] ?? \"\";\n\t}\n\n\tprivate getWordSelection(point: SelectionPoint): SelectionRange | undefined {\n\t\tconst line = stripTerminalSequences(this.getSelectionSourceLine(point));\n\t\tlet start = 0;\n\t\tfor (const segment of wordSegmenter.segment(line)) {\n\t\t\tconst end = start + visibleWidth(segment.segment);\n\t\t\tif (point.col >= start && point.col < end) {\n\t\t\t\treturn {\n\t\t\t\t\tstart: { ...point, col: start },\n\t\t\t\t\tend: { ...point, col: end, boundary: true },\n\t\t\t\t};\n\t\t\t}\n\t\t\tstart = end;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate getLineSelection(point: SelectionPoint): SelectionRange {\n\t\treturn {\n\t\t\tstart: { ...point, col: 0 },\n\t\t\tend: { ...point, col: visibleWidth(this.getSelectionSourceLine(point)), boundary: true },\n\t\t};\n\t}\n\n\tprivate updateSelectionFocus(point: SelectionPoint): void {\n\t\tif (this.selectionGranularity === \"character\" || !this.selectionInitialRange) {\n\t\t\tthis.selectionFocus = point;\n\t\t\treturn;\n\t\t}\n\t\tconst range = this.selectionGranularity === \"word\" ? this.getWordSelection(point) : this.getLineSelection(point);\n\t\tif (!range) return;\n\t\tconst initial = this.selectionInitialRange;\n\t\tconst targetBeforeInitial =\n\t\t\trange.start.row < initial.start.row ||\n\t\t\t(range.start.row === initial.start.row && range.start.col < initial.start.col);\n\t\tif (targetBeforeInitial) {\n\t\t\tthis.selectionAnchor = initial.end;\n\t\t\tthis.selectionFocus = range.start;\n\t\t} else {\n\t\t\tthis.selectionAnchor = initial.start;\n\t\t\tthis.selectionFocus = range.end;\n\t\t}\n\t}\n\n\tprivate getClickCount(point: SelectionPoint, word: SelectionRange | undefined): number {\n\t\tconst now = Date.now();\n\t\tconst previous = this.lastClick;\n\t\tconst count =\n\t\t\tword &&\n\t\t\tprevious &&\n\t\t\tnow - previous.timestamp <= DOUBLE_CLICK_INTERVAL_MS &&\n\t\t\tprevious.row === point.row &&\n\t\t\tprevious.scrollView === point.scrollView &&\n\t\t\tprevious.wordStart === word.start.col &&\n\t\t\tprevious.wordEnd === word.end.col\n\t\t\t\t? (previous.count % 3) + 1\n\t\t\t\t: 1;\n\t\tthis.lastClick = word\n\t\t\t? {\n\t\t\t\t\ttimestamp: now,\n\t\t\t\t\tcount,\n\t\t\t\t\trow: point.row,\n\t\t\t\t\tscrollView: point.scrollView,\n\t\t\t\t\twordStart: word.start.col,\n\t\t\t\t\twordEnd: word.end.col,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn count;\n\t}\n\n\tprivate updateSelectionAutoScroll(event: SgrMouseEvent): void {\n\t\tconst scrollView = this.selectionAnchor?.scrollView;\n\t\tif (!scrollView || !this.currentLayout) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\tif (!box || box.rect.height <= 0 || box.clip.height <= 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst visibleTop = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst visibleBottom = Math.min(\n\t\t\tthis.terminal.rows - 1,\n\t\t\tbox.rect.y + box.rect.height - 1,\n\t\t\tbox.clip.y + box.clip.height - 1,\n\t\t);\n\t\tthis.selectionDragPointer = { x: event.x, y: event.y };\n\t\tthis.selectionAutoScrollDirection = event.y <= visibleTop ? -1 : event.y >= visibleBottom ? 1 : 0;\n\t\tif (this.selectionAutoScrollDirection === 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tif (this.selectionAutoScrollTimer) return;\n\t\tthis.selectionAutoScrollTimer = setInterval(() => this.autoScrollSelection(), 50);\n\t\tthis.selectionAutoScrollTimer.unref();\n\t}\n\n\tprivate autoScrollSelection(): void {\n\t\tconst scrollView = this.selectionAnchor?.scrollView;\n\t\tconst pointer = this.selectionDragPointer;\n\t\tconst direction = this.selectionAutoScrollDirection;\n\t\tif (!scrollView || !pointer || direction === 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst remaining = scrollView.scrollBy(direction);\n\t\tif (remaining === direction) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst point = this.getScrollSelectionPoint(scrollView, pointer.x, pointer.y);\n\t\tif (point) this.updateSelectionFocus(point);\n\t\tthis.requestRender();\n\t}\n\n\tprivate stopSelectionAutoScroll(): void {\n\t\tif (this.selectionAutoScrollTimer) {\n\t\t\tclearInterval(this.selectionAutoScrollTimer);\n\t\t\tthis.selectionAutoScrollTimer = undefined;\n\t\t}\n\t\tthis.selectionAutoScrollDirection = 0;\n\t\tthis.selectionDragPointer = undefined;\n\t}\n\n\tprivate handleSelectionMouseEvent(event: SgrMouseEvent): void {\n\t\tconst button = event.button & 3;\n\t\tif (button !== 0 && !(event.release && button === 3)) return;\n\t\tconst anchorScrollView = this.selectionAnchor?.scrollView;\n\t\tconst point = this.getSelectionPoint(event, anchorScrollView);\n\t\tif (event.release) {\n\t\t\tif (!this.selectionPressActive) return;\n\t\t\tthis.selectionPressActive = false;\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\tif (!this.selectionAnchor) return;\n\t\t\tthis.updateSelectionFocus(point);\n\t\t\tconst clickedUrl =\n\t\t\t\t!this.selectionDragged &&\n\t\t\t\tthis.selectionAnchor.scrollView === point.scrollView &&\n\t\t\t\tthis.selectionAnchor.row === point.row &&\n\t\t\t\tthis.selectionAnchor.col === point.col\n\t\t\t\t\t? this.pressedUrl\n\t\t\t\t\t: undefined;\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tif (clickedUrl && this.openUrl) {\n\t\t\t\tthis.selectionAnchor = undefined;\n\t\t\t\tthis.selectionFocus = undefined;\n\t\t\t\ttry {\n\t\t\t\t\tthis.openUrl(clickedUrl);\n\t\t\t\t} catch {\n\t\t\t\t\t// URL activation is best-effort.\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvoid this.copySelectionToClipboard();\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tif ((event.button & 32) !== 0) {\n\t\t\tif (!this.selectionPressActive || !this.selectionAnchor) return;\n\t\t\tthis.selectionDragged = true;\n\t\t\tthis.lastClick = undefined;\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tthis.updateSelectionFocus(point);\n\t\t\tthis.updateSelectionAutoScroll(event);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = true;\n\t\tconst scrollView =\n\t\t\t!this.hasOverlay() && this.currentLayout\n\t\t\t\t? getScrollViewsAt(this.currentLayout, event.x, event.y)[0]\n\t\t\t\t: undefined;\n\t\tconst anchor = this.getSelectionPoint(event, scrollView);\n\t\tconst word = this.getWordSelection(anchor);\n\t\tconst clickCount = this.getClickCount(anchor, word);\n\t\tconst range = clickCount === 2 ? word : clickCount === 3 ? this.getLineSelection(anchor) : undefined;\n\t\tthis.selectionGranularity = range ? (clickCount === 2 ? \"word\" : \"line\") : \"character\";\n\t\tthis.selectionInitialRange = range;\n\t\tthis.selectionAnchor = range?.start ?? anchor;\n\t\tthis.selectionFocus = range?.end ?? anchor;\n\t\tthis.selectionDragged = false;\n\t\tthis.pressedUrl = range\n\t\t\t? undefined\n\t\t\t: getOsc8LinkAtColumn(\n\t\t\t\t\tthis.previousScreen[Math.max(0, Math.min(this.terminal.rows - 1, event.y))] ?? \"\",\n\t\t\t\t\tMath.max(0, Math.min(this.terminal.columns - 1, event.x)),\n\t\t\t\t);\n\t\tthis.requestRender();\n\t}\n\n\tprivate getSelectionBounds(): { start: SelectionPoint; end: SelectionPoint } | undefined {\n\t\tif (!this.selectionAnchor || !this.selectionFocus) return undefined;\n\t\tif (this.selectionAnchor.scrollView !== this.selectionFocus.scrollView) return undefined;\n\t\tconst anchorBeforeFocus =\n\t\t\tthis.selectionAnchor.row < this.selectionFocus.row ||\n\t\t\t(this.selectionAnchor.row === this.selectionFocus.row && this.selectionAnchor.col < this.selectionFocus.col);\n\t\tif (\n\t\t\tthis.selectionAnchor.row === this.selectionFocus.row &&\n\t\t\tthis.selectionAnchor.col === this.selectionFocus.col\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn anchorBeforeFocus\n\t\t\t? { start: this.selectionAnchor, end: this.selectionFocus }\n\t\t\t: { start: this.selectionFocus, end: this.selectionAnchor };\n\t}\n\n\tprivate getSelectionColumns(\n\t\tline: string,\n\t\trow: number,\n\t\tselection: { start: SelectionPoint; end: SelectionPoint },\n\t\tminColumn = 0,\n\t\tmaxColumn = visibleWidth(line),\n\t): { start: number; end: number } {\n\t\tconst lineWidth = visibleWidth(line);\n\t\tlet start = Math.max(0, minColumn);\n\t\tlet end = Math.min(lineWidth, maxColumn);\n\t\tif (row === selection.start.row) {\n\t\t\tstart = getGraphemeCellRange(line, selection.start.col)?.start ?? Math.min(selection.start.col, lineWidth);\n\t\t}\n\t\tif (row === selection.end.row) {\n\t\t\tend = selection.end.boundary\n\t\t\t\t? Math.min(selection.end.col, lineWidth)\n\t\t\t\t: (getGraphemeCellRange(line, selection.end.col)?.end ?? Math.min(selection.end.col + 1, lineWidth));\n\t\t}\n\t\treturn { start: Math.max(minColumn, start), end: Math.min(maxColumn, end) };\n\t}\n\n\tprivate async copySelectionToClipboard(): Promise<void> {\n\t\tconst selection = this.getSelectionBounds();\n\t\tif (!selection) return;\n\t\tlet sourceLines: readonly string[] = this.previousScreen;\n\t\tif (selection.start.scrollView) {\n\t\t\tif (!this.currentLayout) return;\n\t\t\tconst box = getScrollViewBox(this.currentLayout, selection.start.scrollView);\n\t\t\tif (!box?.scrollContentLines) return;\n\t\t\tsourceLines = box.scrollContentLines;\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tfor (let row = selection.start.row; row <= selection.end.row; row++) {\n\t\t\tconst line = sourceLines[row] ?? \"\";\n\t\t\tconst columns = this.getSelectionColumns(line, row, selection);\n\t\t\tlines.push(\n\t\t\t\tstripTerminalSequences(\n\t\t\t\t\tsliceByColumn(line, columns.start, Math.max(0, columns.end - columns.start), true),\n\t\t\t\t).trimEnd(),\n\t\t\t);\n\t\t}\n\t\tconst text = lines.join(\"\\n\");\n\t\tif (text.length === 0) return;\n\t\t// Prefer an injected clipboard implementation (native clipboard + platform tools with a\n\t\t// verified success path) when the host app provides one. A bare OSC 52 write can show\n\t\t// \"Copied!\" while leaving the system clipboard untouched (e.g. macOS Terminal.app, tmux\n\t\t// without OSC 52 clipboard passthrough), so only report success when it actually copies.\n\t\tif (this.copySelection) {\n\t\t\tconst ok = await this.copySelection(text);\n\t\t\tthis.flash(ok ? \"Copied!\" : \"Copy failed\");\n\t\t\treturn;\n\t\t}\n\t\tthis.terminal.write(`\\x1b]52;c;${Buffer.from(text).toString(\"base64\")}\\x07`);\n\t\tthis.flash(\"Copied!\");\n\t}\n\n\tprivate applySearchTextHighlight(text: string, current: boolean): string {\n\t\tconst style = current ? this.searchCurrentMatchStyle : this.searchMatchStyle;\n\t\tlet result = \"\";\n\t\tlet plainStart = 0;\n\t\tlet index = 0;\n\t\twhile (index < text.length) {\n\t\t\tconst ansi = extractAnsiCode(text, index);\n\t\t\tif (!ansi) {\n\t\t\t\tindex += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (index > plainStart) result += style(text.slice(plainStart, index));\n\t\t\tresult += ansi.code;\n\t\t\tindex += ansi.length;\n\t\t\tplainStart = index;\n\t\t}\n\t\tif (plainStart < text.length) result += style(text.slice(plainStart));\n\t\treturn result;\n\t}\n\n\tprivate applySearchHighlights(screen: string[], layout: LayoutFrame): string[] {\n\t\tconst search = this.activeSearch;\n\t\tif (!search || search.selectedIndex < 0 || search.matches.length === 0) return screen;\n\t\tconst scrollView = layout.primaryScrollView ?? this.implicitScrollView;\n\t\tconst box = getScrollViewBox(layout, scrollView);\n\t\tif (!box) return screen;\n\n\t\tconst rangesByRow = new Map<number, SearchHighlightRange[]>();\n\t\tconst scrollbarColumn = getScrollbarGeometry(box)?.column;\n\t\tconst minRow = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst maxRow = Math.min(screen.length, box.rect.y + box.rect.height, box.clip.y + box.clip.height);\n\t\tconst minColumn = Math.max(0, box.rect.x, box.clip.x);\n\t\tconst maxColumn = Math.min(\n\t\t\tthis.terminal.columns,\n\t\t\tbox.rect.x + box.rect.width,\n\t\t\tbox.clip.x + box.clip.width,\n\t\t\tscrollbarColumn ?? Number.POSITIVE_INFINITY,\n\t\t);\n\t\tfor (let matchIndex = 0; matchIndex < search.matches.length; matchIndex++) {\n\t\t\tfor (const segment of search.matches[matchIndex]!.segments) {\n\t\t\t\tconst row = box.rect.y + segment.row - scrollView.scrollTop;\n\t\t\t\tif (row < minRow || row >= maxRow) continue;\n\t\t\t\tconst startCol = Math.max(minColumn, box.rect.x + segment.startCol);\n\t\t\t\tconst endCol = Math.min(maxColumn, box.rect.x + segment.endCol);\n\t\t\t\tif (endCol <= startCol) continue;\n\t\t\t\tconst ranges = rangesByRow.get(row) ?? [];\n\t\t\t\tranges.push({ startCol, endCol, current: matchIndex === search.selectedIndex });\n\t\t\t\trangesByRow.set(row, ranges);\n\t\t\t}\n\t\t}\n\n\t\tconst result = [...screen];\n\t\tfor (const [row, ranges] of rangesByRow) {\n\t\t\tlet line = result[row] ?? \"\";\n\t\t\tif (isImageLine(line)) continue;\n\t\t\tconst lineWidth = visibleWidth(line);\n\t\t\tfor (const range of ranges.sort((a, b) => b.startCol - a.startCol)) {\n\t\t\t\tconst startCol = Math.min(range.startCol, lineWidth);\n\t\t\t\tconst endCol = Math.min(range.endCol, lineWidth);\n\t\t\t\tif (endCol <= startCol) continue;\n\t\t\t\tconst before = sliceByColumn(line, 0, startCol, true);\n\t\t\t\tconst highlighted = sliceByColumn(line, startCol, endCol - startCol, true);\n\t\t\t\tconst after = sliceByColumn(line, endCol, Math.max(0, lineWidth - endCol), true);\n\t\t\t\tline = `${before}${this.applySearchTextHighlight(highlighted, range.current)}${after}`;\n\t\t\t}\n\t\t\tresult[row] = line;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate applySelectionHighlight(text: string): string {\n\t\tlet result = \"\\x1b[7m\";\n\t\tlet index = 0;\n\t\twhile (index < text.length) {\n\t\t\tconst ansi = extractAnsiCode(text, index);\n\t\t\tif (!ansi) {\n\t\t\t\tresult += text[index];\n\t\t\t\tindex += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult += ansi.code;\n\t\t\tif (ansi.code.endsWith(\"m\")) result += \"\\x1b[7m\";\n\t\t\tindex += ansi.length;\n\t\t}\n\t\treturn `${result}\\x1b[27m`;\n\t}\n\n\tprivate applySelection(screen: string[], layout = this.currentLayout): string[] {\n\t\tconst selection = this.getSelectionBounds();\n\t\tif (!selection) return screen;\n\t\tlet screenSelection = selection;\n\t\tlet minRow = 0;\n\t\tlet maxRow = screen.length - 1;\n\t\tlet minColumn = 0;\n\t\tlet maxColumn = this.terminal.columns;\n\t\tif (selection.start.scrollView) {\n\t\t\tif (!layout) return screen;\n\t\t\tconst box = getScrollViewBox(layout, selection.start.scrollView);\n\t\t\tif (!box) return screen;\n\t\t\tminRow = Math.max(0, box.rect.y, box.clip.y);\n\t\t\tmaxRow = Math.min(screen.length - 1, box.rect.y + box.rect.height - 1, box.clip.y + box.clip.height - 1);\n\t\t\tminColumn = Math.max(0, box.rect.x, box.clip.x);\n\t\t\tmaxColumn = Math.min(this.terminal.columns, box.rect.x + box.rect.width, box.clip.x + box.clip.width);\n\t\t\tscreenSelection = {\n\t\t\t\tstart: {\n\t\t\t\t\t...selection.start,\n\t\t\t\t\trow: box.rect.y + selection.start.row - selection.start.scrollView.scrollTop,\n\t\t\t\t\tcol: box.rect.x + selection.start.col,\n\t\t\t\t},\n\t\t\t\tend: {\n\t\t\t\t\t...selection.end,\n\t\t\t\t\trow: box.rect.y + selection.end.row - selection.start.scrollView.scrollTop,\n\t\t\t\t\tcol: box.rect.x + selection.end.col,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn screen.map((line, row) => {\n\t\t\tif (\n\t\t\t\trow < minRow ||\n\t\t\t\trow > maxRow ||\n\t\t\t\trow < screenSelection.start.row ||\n\t\t\t\trow > screenSelection.end.row ||\n\t\t\t\tisImageLine(line)\n\t\t\t) {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\tconst lineWidth = visibleWidth(line);\n\t\t\tconst columns = this.getSelectionColumns(line, row, screenSelection, minColumn, maxColumn);\n\t\t\tif (columns.end <= columns.start) return line;\n\t\t\tconst before = sliceByColumn(line, 0, columns.start, true);\n\t\t\tconst selected = sliceByColumn(line, columns.start, columns.end - columns.start, true);\n\t\t\tconst after = sliceByColumn(line, columns.end, Math.max(0, lineWidth - columns.end), true);\n\t\t\treturn `${before}${this.applySelectionHighlight(selected)}${after}`;\n\t\t});\n\t}\n\n\tprivate isMouseSequence(data: string): boolean {\n\t\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[Mm]$/.test(data) || (data.length === 6 && data.startsWith(\"\\x1b[M\"));\n\t}\n\n\tprivate compositeFlashes(screen: string[], width: number, height: number): string[] {\n\t\tconst flashLines = this.flashes.render(width).slice(-height);\n\t\tif (flashLines.length === 0) return screen;\n\t\tconst result = [...screen];\n\t\twhile (result.length < height) result.push(\"\");\n\t\tfor (let row = 0; row < flashLines.length; row++) {\n\t\t\tconst line = flashLines[row]!;\n\t\t\tconst flashWidth = visibleWidth(line);\n\t\t\tif (flashWidth === 0) continue;\n\t\t\tresult[row] = compositeTuiLine(result[row] ?? \"\", line, width - flashWidth, flashWidth, width);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override doRender(): void {\n\t\tif (this.stopped || !this.altScreenActive) return;\n\t\tconst width = Math.max(1, this.terminal.columns);\n\t\tconst height = Math.max(1, this.terminal.rows);\n\t\tconst root = this.layoutRoot ?? this.implicitScrollView;\n\t\tlet nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());\n\t\tif (this.refreshSearch(nextLayout)) {\n\t\t\tnextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());\n\t\t}\n\t\tlet screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX, \"\"));\n\t\tscreen = this.applySearchHighlights(screen, nextLayout);\n\t\tscreen = this.compositeOverlays(screen, width, height);\n\t\tif (screen.length > height) screen = screen.slice(screen.length - height);\n\t\tscreen = this.applySelection(screen, nextLayout);\n\t\tscreen = this.compositeFlashes(screen, width, height);\n\n\t\tconst cursorPos = this.extractCursorPosition(screen, height);\n\t\tscreen = this.applyLineResets(screen).map((line) => {\n\t\t\tif (isImageLine(line) || visibleWidth(line) <= width) return line;\n\t\t\treturn sliceByColumn(line, 0, width, true);\n\t\t});\n\n\t\tconst fullRedraw =\n\t\t\tthis.previousScreen.length === 0 || this.previousScreenWidth !== width || this.previousScreenHeight !== height;\n\t\tconst imagesNeedRedraw = screen.some(\n\t\t\t(line, row) =>\n\t\t\t\tline !== this.previousScreen[row] && (isImageLine(line) || isImageLine(this.previousScreen[row] ?? \"\")),\n\t\t);\n\t\tconst redrawImages = fullRedraw || imagesNeedRedraw;\n\t\tconst hadUploadedKittyImages = this.uploadedKittyImages.size > 0;\n\t\tconst preparedKittyScreen =\n\t\t\tredrawImages && this.imageProtocol === \"kitty\"\n\t\t\t\t? this.prepareKittyScreen(screen)\n\t\t\t\t: { lines: screen, evictedImageDeletion: \"\" };\n\n\t\tlet buffer = BEGIN_SYNCHRONIZED_OUTPUT;\n\t\tif (fullRedraw) {\n\t\t\tthis.fullRedrawCount += 1;\n\t\t\tconst clearImages =\n\t\t\t\tthis.imageProtocol === \"kitty\" && hadUploadedKittyImages\n\t\t\t\t\t? deleteAllKittyPlacements()\n\t\t\t\t\t: this.deleteKittyImages();\n\t\t\tbuffer += `${clearImages}\\x1b[2J`;\n\t\t} else if (imagesNeedRedraw) {\n\t\t\tif (this.imageProtocol === \"iterm2\") buffer += \"\\x1b[2J\";\n\t\t\telse if (this.imageProtocol === \"kitty\") buffer += deleteAllKittyPlacements();\n\t\t}\n\t\tbuffer += preparedKittyScreen.evictedImageDeletion;\n\n\t\tfor (let row = 0; row < height; row++) {\n\t\t\tif (!fullRedraw && !imagesNeedRedraw && screen[row] === this.previousScreen[row]) continue;\n\t\t\tbuffer += `\\x1b[${row + 1};1H\\x1b[2K${preparedKittyScreen.lines[row] ?? \"\"}`;\n\t\t}\n\n\t\tif (cursorPos) {\n\t\t\tbuffer += `\\x1b[${cursorPos.row + 1};${Math.min(width, cursorPos.col) + 1}H`;\n\t\t\tbuffer += this.getShowHardwareCursor() ? \"\\x1b[?25h\" : \"\\x1b[?25l\";\n\t\t} else {\n\t\t\tbuffer += \"\\x1b[?25l\";\n\t\t}\n\t\tbuffer += END_SYNCHRONIZED_OUTPUT;\n\t\tthis.terminal.write(buffer);\n\n\t\tthis.previousScreen = screen;\n\t\tthis.previousScreenWidth = width;\n\t\tthis.previousScreenHeight = height;\n\t\tthis.currentLayout = nextLayout;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tui-alt-screen.d.ts","sourceRoot":"","sources":["../src/tui-alt-screen.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAY9C,OAAO,EACN,KAAK,SAAS,EAId,OAAO,EACP,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,WAAW,EAChB,MAAM,UAAU,CAAC;AAuGlB,MAAM,WAAW,mBAAmB;IACnC,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAA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,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;IAcxB,UAAmB,QAAQ,IAAI,IAAI,CAmElC;CACD","sourcesContent":["import {\n\tAltScreenSearchComponent,\n\ttype AltScreenSearchMatch,\n\tfindAltScreenSearchMatches,\n\tgetAltScreenSearchMatchKey,\n} from \"./alt-screen-search.ts\";\nimport { AltScreenFlashContainer } from \"./components/alt-screen-flash.ts\";\nimport { ScrollView } from \"./components/scroll-view.ts\";\nimport { getKeybindings } from \"./keybindings.ts\";\nimport { isKeyRelease } from \"./keys.ts\";\nimport {\n\tgetScrollbarGeometry,\n\tgetScrollViewBox,\n\tgetScrollViewsAt,\n\ttype LayoutFrame,\n\trenderLayoutFrame,\n\ttype ScrollbarGeometry,\n} from \"./layout.ts\";\nimport type { Terminal } from \"./terminal.ts\";\nimport {\n\tdeleteAllKittyImages,\n\tdeleteAllKittyPlacements,\n\tdeleteKittyImage,\n\tgetCapabilities,\n\tgetKittyImagePlacement,\n\ttype ImageProtocol,\n\tisImageLine,\n\tsetCapabilities,\n\ttype TerminalCapabilities,\n} from \"./terminal-image.ts\";\nimport {\n\ttype Component,\n\tCURSOR_MARKER,\n\tcompositeTuiLine,\n\ttype OverlayHandle,\n\tTuiBase,\n\ttype TuiStopOptions,\n\tVIEWPORT_TUI,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nimport {\n\textractAnsiCode,\n\tgetGraphemeCellRange,\n\tgetOsc8LinkAtColumn,\n\tgetWordSegmenter,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\tvisibleWidth,\n} from \"./utils.ts\";\n\nconst ENTER_ALT_SCREEN = \"\\x1b[?1049h\";\nconst EXIT_ALT_SCREEN = \"\\x1b[?1049l\";\nconst DISABLE_AUTOWRAP = \"\\x1b[?7l\";\nconst ENABLE_AUTOWRAP = \"\\x1b[?7h\";\nconst ENABLE_BUTTON_MOTION_MOUSE = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1004h\\x1b[?1006h\";\nconst ENABLE_ALL_MOTION_MOUSE = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1003h\\x1b[?1004h\\x1b[?1006h\";\nconst DISABLE_MOUSE = \"\\x1b[?1006l\\x1b[?1004l\\x1b[?1003l\\x1b[?1002l\\x1b[?1000l\";\nconst FOCUS_IN = \"\\x1b[I\";\nconst FOCUS_OUT = \"\\x1b[O\";\nconst BEGIN_SYNCHRONIZED_OUTPUT = \"\\x1b[?2026h\";\nconst END_SYNCHRONIZED_OUTPUT = \"\\x1b[?2026l\";\nconst OSC133_ZONE_PREFIX = /^(?:\\x1b\\]133;[ABC](?:\\x07|\\x1b\\\\))+/;\nconst OSC133_PROMPT_START = /^\\x1b\\]133;A(?:\\x07|\\x1b\\\\)/;\nconst PAGE_SCROLL_OVERLAP = 4;\nconst MAX_CACHED_OFFSCREEN_KITTY_IMAGES = 16;\nconst MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES = 32 * 1024 * 1024;\nconst MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES = 64 * 1024 * 1024;\nconst DOUBLE_CLICK_INTERVAL_MS = 500;\nconst wordSegmenter = getWordSegmenter();\n\ninterface CachedKittyImage {\n\ttransmissionGeneration: number;\n\ttransmissionBytes: number;\n\testimatedDecodedBytes: number;\n}\n\ninterface SelectionPoint {\n\trow: number;\n\tcol: number;\n\tscrollView?: ScrollView;\n\t/** Whether this point lies between terminal cells rather than on a cell. */\n\tboundary?: boolean;\n}\n\ninterface SelectionRange {\n\tstart: SelectionPoint;\n\tend: SelectionPoint;\n}\n\ntype SelectionGranularity = \"character\" | \"word\" | \"line\";\n\ninterface ClickTarget {\n\ttimestamp: number;\n\tcount: number;\n\trow: number;\n\tscrollView?: ScrollView;\n\twordStart: number;\n\twordEnd: number;\n}\n\ninterface SgrMouseEvent {\n\tbutton: number;\n\tx: number;\n\ty: number;\n\trelease: boolean;\n}\n\ninterface WheelEvent {\n\tdirection: -1 | 1;\n\tx: number;\n\ty: number;\n}\n\ninterface ScrollbarDrag {\n\tscrollView: ScrollView;\n\tgrabOffset: number;\n}\n\ninterface ScrollbarTarget {\n\tscrollView: ScrollView;\n\tgeometry: ScrollbarGeometry;\n}\n\ntype SearchSelectionMode = \"query\" | \"retain\" | \"next\" | \"previous\";\n\ninterface ActiveSearch {\n\tcomponent: AltScreenSearchComponent;\n\toverlay?: OverlayHandle;\n\tquery: string;\n\tmatches: AltScreenSearchMatch[];\n\tselectedIndex: number;\n\tselectedKey?: string;\n\tanchorRow: number;\n\tselectionMode: SearchSelectionMode;\n}\n\ninterface SearchHighlightRange {\n\tstartCol: number;\n\tendCol: number;\n\tcurrent: boolean;\n}\n\nexport interface TuiAltScreenOptions {\n\t/** Number of logical lines moved for each mouse-wheel event. */\n\twheelScrollLines?: number;\n\t/** Capture mouse events for viewport scrolling and application-owned text selection. */\n\tmouse?: boolean;\n\t/** Style a non-current transcript search match. */\n\tsearchMatchStyle?: (text: string) => string;\n\t/** Style the current transcript search match. */\n\tsearchCurrentMatchStyle?: (text: string) => string;\n\t/** Open an OSC 8 hyperlink activated with a primary-button click. */\n\topenUrl?: (url: string) => void;\n\t/** Handle an unmodified secondary-button press for clipboard paste. Currently enabled on Windows only. */\n\tonRightClickPaste?: () => void;\n\t/**\n\t * Copy selected text to the system clipboard. Return `true` on success; the caller flashes\n\t * an error otherwise. When omitted, the selection is copied via an OSC 52 write.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean>;\n}\n\n/** Alternate-screen TUI with a scrollable, application-owned viewport. */\nexport class TuiAltScreen extends TuiBase implements ViewportTUI {\n\treadonly mode = \"fullscreen\" as const;\n\treadonly [VIEWPORT_TUI] = true as const;\n\tprivate previousScreen: string[] = [];\n\tprivate lastDocument: string[] = [];\n\tprivate previousScreenWidth = 0;\n\tprivate previousScreenHeight = 0;\n\tprivate layoutRoot: Component | undefined;\n\tprivate currentLayout: LayoutFrame | undefined;\n\tprivate readonly implicitDocument: Component;\n\tprivate readonly implicitScrollView: ScrollView;\n\tprivate readonly flashes: AltScreenFlashContainer;\n\tprivate altScreenActive = false;\n\tprivate imageProtocol: ImageProtocol = null;\n\tprivate savedCapabilities?: TerminalCapabilities;\n\tprivate readonly uploadedKittyImages = new Map<number, CachedKittyImage>();\n\tprivate selectionAnchor?: SelectionPoint;\n\tprivate selectionFocus?: SelectionPoint;\n\tprivate selectionGranularity: SelectionGranularity = \"character\";\n\tprivate selectionInitialRange?: SelectionRange;\n\tprivate lastClick?: ClickTarget;\n\tprivate selectionDragPointer?: { x: number; y: number };\n\tprivate selectionAutoScrollDirection: -1 | 0 | 1 = 0;\n\tprivate selectionAutoScrollTimer?: NodeJS.Timeout;\n\tprivate selectionPressActive = false;\n\tprivate scrollbarDrag?: ScrollbarDrag;\n\tprivate scrollbarHover?: ScrollView;\n\tprivate activeSearch?: ActiveSearch;\n\tprivate pressedUrl?: string;\n\tprivate selectionDragged = false;\n\tprivate readonly wheelScrollLines: number;\n\tprivate readonly mouseEnabled: boolean;\n\tprivate readonly searchMatchStyle: (text: string) => string;\n\tprivate readonly searchCurrentMatchStyle: (text: string) => string;\n\tprivate readonly openUrl?: (url: string) => void;\n\tprivate readonly onRightClickPaste?: () => void;\n\tprivate readonly copySelection?: (text: string) => Promise<boolean>;\n\n\tconstructor(\n\t\tterminal: Terminal,\n\t\tshowHardwareCursor?: boolean,\n\t\tlogDirectory?: string,\n\t\toptions: TuiAltScreenOptions = {},\n\t) {\n\t\tsuper(terminal, showHardwareCursor, logDirectory);\n\t\tthis.implicitDocument = {\n\t\t\trender: (width) => super.render(width),\n\t\t\tinvalidate: () => {\n\t\t\t\tfor (const child of this.children) child.invalidate();\n\t\t\t},\n\t\t};\n\t\tthis.implicitScrollView = new ScrollView(this.implicitDocument, { follow: \"end\", primary: true });\n\t\tthis.flashes = new AltScreenFlashContainer(() => this.requestRender());\n\t\tthis.wheelScrollLines = Math.max(1, Math.floor(options.wheelScrollLines ?? 1));\n\t\tthis.mouseEnabled = options.mouse ?? true;\n\t\tthis.searchMatchStyle = options.searchMatchStyle ?? ((text) => `\\x1b[4m${text}\\x1b[24m`);\n\t\tthis.searchCurrentMatchStyle = options.searchCurrentMatchStyle ?? ((text) => `\\x1b[1;7m${text}\\x1b[22;27m`);\n\t\tthis.openUrl = options.openUrl;\n\t\tthis.onRightClickPaste = options.onRightClickPaste;\n\t\tthis.copySelection = options.copySelection;\n\t\tthis.addInputListener((data) => this.handleViewportInput(data));\n\t}\n\n\tget viewportTop(): number {\n\t\treturn this.getPrimaryScrollView().scrollTop;\n\t}\n\n\tget isFollowingOutput(): boolean {\n\t\treturn this.getPrimaryScrollView().isFollowingEnd;\n\t}\n\n\tsetLayoutRoot(component: Component | undefined): void {\n\t\tif (this.layoutRoot === component) return;\n\t\tthis.layoutRoot = component;\n\t\tthis.currentLayout = undefined;\n\t\tthis.requestRender();\n\t}\n\n\toverride render(width: number): string[] {\n\t\treturn this.layoutRoot?.render(width) ?? super.render(width);\n\t}\n\n\tprotected override getMountedRoots(): readonly Component[] {\n\t\treturn this.layoutRoot ? [this.layoutRoot] : this.children;\n\t}\n\n\tprivate getPrimaryScrollView(): ScrollView {\n\t\treturn this.currentLayout?.primaryScrollView ?? this.implicitScrollView;\n\t}\n\n\tprotected override beforeTerminalStart(): void {\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.stopScrollbarHover();\n\t\tthis.stopScrollbarDrag();\n\t\tthis.flashes.dispose();\n\t\tthis.altScreenActive = true;\n\t\tconst capabilities = getCapabilities();\n\t\tthis.imageProtocol = capabilities.images;\n\t\tthis.uploadedKittyImages.clear();\n\t\tif (capabilities.images === \"iterm2\") {\n\t\t\tthis.savedCapabilities = capabilities;\n\t\t\tsetCapabilities({ ...capabilities, images: null });\n\t\t\tthis.invalidate();\n\t\t}\n\t\tthis.lastDocument = [];\n\t\tthis.selectionAnchor = undefined;\n\t\tthis.selectionFocus = undefined;\n\t\tthis.selectionGranularity = \"character\";\n\t\tthis.selectionInitialRange = undefined;\n\t\tthis.lastClick = undefined;\n\t\tthis.pressedUrl = undefined;\n\t\tthis.selectionDragged = false;\n\t\tthis.resetRenderState();\n\t\tconst term = process.env.TERM?.toLowerCase() ?? \"\";\n\t\t// Multiplexers can lag when every pointer movement is forwarded. Button-motion\n\t\t// tracking preserves clicks, wheel events, selections, and scrollbar dragging.\n\t\tconst mouseSequence =\n\t\t\tprocess.env.TMUX !== undefined ||\n\t\t\tprocess.env.ZELLIJ !== undefined ||\n\t\t\tprocess.env.STY !== undefined ||\n\t\t\tterm.startsWith(\"tmux\") ||\n\t\t\tterm.startsWith(\"screen\")\n\t\t\t\t? ENABLE_BUTTON_MOTION_MOUSE\n\t\t\t\t: ENABLE_ALL_MOTION_MOUSE;\n\t\tthis.terminal.write(\n\t\t\t`${ENTER_ALT_SCREEN}${DISABLE_AUTOWRAP}${this.mouseEnabled ? mouseSequence : \"\"}\\x1b[2J\\x1b[H\\x1b[?25l`,\n\t\t);\n\t}\n\n\tprotected override beforeTerminalStop(_options: TuiStopOptions): void {\n\t\tthis.closeSearch();\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.stopScrollbarHover();\n\t\tthis.stopScrollbarDrag();\n\t\tthis.flashes.dispose();\n\t\tif (!this.altScreenActive) return;\n\t\tthis.terminal.write(\n\t\t\t`${BEGIN_SYNCHRONIZED_OUTPUT}${this.deleteKittyImages()}${this.mouseEnabled ? DISABLE_MOUSE : \"\"}${ENABLE_AUTOWRAP}${END_SYNCHRONIZED_OUTPUT}`,\n\t\t);\n\t\tthis.uploadedKittyImages.clear();\n\t}\n\n\tprotected override afterTerminalStop(options: TuiStopOptions): void {\n\t\tif (!this.altScreenActive) return;\n\t\tthis.altScreenActive = false;\n\t\tif (options.preserveScreen) {\n\t\t\tthis.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`);\n\t\t} else {\n\t\t\tconst width = Math.max(1, this.terminal.columns);\n\t\t\tconst documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, \"\"));\n\t\t\tthis.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, \"\"))).map(\n\t\t\t\t(line) => (isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true)),\n\t\t\t);\n\t\t\tlet buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;\n\t\t\tfor (let row = 0; row < this.lastDocument.length; row++) {\n\t\t\t\tif (row > 0) buffer += \"\\r\\n\";\n\t\t\t\tbuffer += `\\r\\x1b[2K${this.lastDocument[row] ?? \"\"}`;\n\t\t\t}\n\t\t\tbuffer += `\\x1b[0m${ENABLE_AUTOWRAP}\\r\\n\\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`;\n\t\t\tthis.terminal.write(buffer);\n\t\t}\n\t\tif (this.savedCapabilities) {\n\t\t\tsetCapabilities(this.savedCapabilities);\n\t\t\tthis.savedCapabilities = undefined;\n\t\t}\n\t}\n\n\tprivate deleteKittyImages(): string {\n\t\treturn this.imageProtocol === \"kitty\" ? deleteAllKittyImages() : \"\";\n\t}\n\n\tprivate prepareKittyScreen(screen: string[]): { lines: string[]; evictedImageDeletion: string } {\n\t\tconst visibleImageIds = new Set<number>();\n\t\tconst lines = screen.map((line) => {\n\t\t\tconst placement = getKittyImagePlacement(line);\n\t\t\tif (!placement) return line;\n\t\t\tvisibleImageIds.add(placement.imageId);\n\n\t\t\tconst cachedImage = this.uploadedKittyImages.get(placement.imageId);\n\t\t\tconst nextCachedImage = {\n\t\t\t\ttransmissionGeneration: placement.transmissionGeneration,\n\t\t\t\ttransmissionBytes: placement.transmissionBytes,\n\t\t\t\testimatedDecodedBytes: placement.estimatedDecodedBytes,\n\t\t\t};\n\t\t\tif (cachedImage) this.uploadedKittyImages.delete(placement.imageId);\n\t\t\tthis.uploadedKittyImages.set(placement.imageId, nextCachedImage);\n\n\t\t\treturn cachedImage?.transmissionGeneration === placement.transmissionGeneration\n\t\t\t\t? placement.replacementLine\n\t\t\t\t: line;\n\t\t});\n\n\t\tlet cachedOffscreenImageCount = 0;\n\t\tlet cachedOffscreenTransmissionBytes = 0;\n\t\tlet cachedOffscreenDecodedBytes = 0;\n\t\tfor (const [imageId, cachedImage] of this.uploadedKittyImages) {\n\t\t\tif (visibleImageIds.has(imageId)) continue;\n\t\t\tcachedOffscreenImageCount += 1;\n\t\t\tcachedOffscreenTransmissionBytes += cachedImage.transmissionBytes;\n\t\t\tcachedOffscreenDecodedBytes += cachedImage.estimatedDecodedBytes;\n\t\t}\n\n\t\tlet evictedImageDeletion = \"\";\n\t\tfor (const [imageId, cachedImage] of this.uploadedKittyImages) {\n\t\t\tif (\n\t\t\t\tcachedOffscreenImageCount <= MAX_CACHED_OFFSCREEN_KITTY_IMAGES &&\n\t\t\t\tcachedOffscreenTransmissionBytes <= MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES &&\n\t\t\t\tcachedOffscreenDecodedBytes <= MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (visibleImageIds.has(imageId)) continue;\n\t\t\tevictedImageDeletion += deleteKittyImage(imageId);\n\t\t\tthis.uploadedKittyImages.delete(imageId);\n\t\t\tcachedOffscreenImageCount -= 1;\n\t\t\tcachedOffscreenTransmissionBytes -= cachedImage.transmissionBytes;\n\t\t\tcachedOffscreenDecodedBytes -= cachedImage.estimatedDecodedBytes;\n\t\t}\n\t\treturn { lines, evictedImageDeletion };\n\t}\n\n\tprotected override resetRenderState(): void {\n\t\tthis.previousScreen = [];\n\t\tthis.previousScreenWidth = 0;\n\t\tthis.previousScreenHeight = 0;\n\t\tthis.currentLayout = undefined;\n\t}\n\n\tscrollBy(lines: number): void {\n\t\tthis.getPrimaryScrollView().scrollBy(lines);\n\t\tthis.requestRender();\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.getPrimaryScrollView().scrollToStart();\n\t\tthis.requestRender();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.getPrimaryScrollView().scrollToEnd();\n\t\tthis.requestRender();\n\t}\n\n\tprivate scrollToPrompt(direction: -1 | 1): void {\n\t\tif (!this.currentLayout) return;\n\t\tconst scrollView = this.getPrimaryScrollView();\n\t\tconst lines = getScrollViewBox(this.currentLayout, scrollView)?.scrollContentLines;\n\t\tif (!lines) return;\n\n\t\tfor (let row = scrollView.scrollTop + direction; row >= 0 && row < lines.length; row += direction) {\n\t\t\tif (!OSC133_PROMPT_START.test(lines[row] ?? \"\")) continue;\n\t\t\tscrollView.scrollTo(row);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate openSearch(): void {\n\t\tif (this.activeSearch) {\n\t\t\tthis.activeSearch.overlay?.focus();\n\t\t\treturn;\n\t\t}\n\t\tconst component = new AltScreenSearchComponent((query) => this.updateSearchQuery(query));\n\t\tconst search: ActiveSearch = {\n\t\t\tcomponent,\n\t\t\tquery: \"\",\n\t\t\tmatches: [],\n\t\t\tselectedIndex: -1,\n\t\t\tanchorRow: this.getPrimaryScrollView().scrollTop,\n\t\t\tselectionMode: \"query\",\n\t\t};\n\t\tthis.activeSearch = search;\n\t\tsearch.overlay = this.showOverlay(component, {\n\t\t\tanchor: \"top-right\",\n\t\t\twidth: \"40%\",\n\t\t\tminWidth: 24,\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeSearch(): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search) return;\n\t\tthis.activeSearch = undefined;\n\t\tsearch.overlay?.hide();\n\t\tthis.requestRender();\n\t}\n\n\tprivate updateSearchQuery(query: string): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search || query === search.query) return;\n\t\tconst selected = search.matches[search.selectedIndex];\n\t\tsearch.anchorRow = selected?.segments[0]?.row ?? this.getPrimaryScrollView().scrollTop;\n\t\tsearch.query = query;\n\t\tsearch.selectionMode = \"query\";\n\t\tsearch.component.setResult(-1, 0);\n\t\tthis.requestRender();\n\t}\n\n\tprivate navigateSearch(direction: -1 | 1): void {\n\t\tconst search = this.activeSearch;\n\t\tif (!search?.query) return;\n\t\tsearch.selectionMode = direction < 0 ? \"previous\" : \"next\";\n\t\tthis.requestRender();\n\t}\n\n\tprivate refreshSearch(layout: LayoutFrame): boolean {\n\t\tconst search = this.activeSearch;\n\t\tif (!search) return false;\n\t\tconst scrollView = layout.primaryScrollView ?? this.implicitScrollView;\n\t\tconst box = getScrollViewBox(layout, scrollView);\n\t\tconst lines = box?.scrollContentLines;\n\t\tif (!lines || !search.query.trim()) {\n\t\t\tsearch.matches = [];\n\t\t\tsearch.selectedIndex = -1;\n\t\t\tsearch.selectedKey = undefined;\n\t\t\tsearch.selectionMode = \"retain\";\n\t\t\tsearch.component.setResult(-1, 0);\n\t\t\treturn false;\n\t\t}\n\n\t\tconst shouldRevealSelection = search.selectionMode !== \"retain\";\n\t\tconst matches = findAltScreenSearchMatches(lines, search.query);\n\t\tconst exactIndex = search.selectedKey\n\t\t\t? matches.findIndex((match) => getAltScreenSearchMatchKey(match) === search.selectedKey)\n\t\t\t: -1;\n\t\tlet selectedIndex = -1;\n\t\tif (matches.length > 0) {\n\t\t\tif (search.selectionMode === \"query\") {\n\t\t\t\tselectedIndex = matches.findIndex((match) => (match.segments[0]?.row ?? 0) >= search.anchorRow);\n\t\t\t\tif (selectedIndex < 0) selectedIndex = 0;\n\t\t\t} else if (search.selectionMode === \"next\") {\n\t\t\t\tconst baseIndex = exactIndex >= 0 ? exactIndex : Math.min(search.selectedIndex, matches.length - 1);\n\t\t\t\tselectedIndex = baseIndex < 0 ? 0 : (baseIndex + 1) % matches.length;\n\t\t\t} else if (search.selectionMode === \"previous\") {\n\t\t\t\tconst baseIndex = exactIndex >= 0 ? exactIndex : Math.min(search.selectedIndex, matches.length - 1);\n\t\t\t\tselectedIndex = baseIndex < 0 ? matches.length - 1 : (baseIndex - 1 + matches.length) % matches.length;\n\t\t\t} else {\n\t\t\t\tselectedIndex =\n\t\t\t\t\texactIndex >= 0 ? exactIndex : Math.min(Math.max(0, search.selectedIndex), matches.length - 1);\n\t\t\t}\n\t\t}\n\n\t\tsearch.matches = matches;\n\t\tsearch.selectedIndex = selectedIndex;\n\t\tsearch.selectedKey = selectedIndex >= 0 ? getAltScreenSearchMatchKey(matches[selectedIndex]!) : undefined;\n\t\tsearch.selectionMode = \"retain\";\n\t\tsearch.component.setResult(selectedIndex, matches.length);\n\t\tif (!shouldRevealSelection) return false;\n\n\t\tconst selected = matches[selectedIndex];\n\t\tconst firstSegment = selected?.segments[0];\n\t\tconst lastSegment = selected?.segments[selected.segments.length - 1];\n\t\tif (!box || !firstSegment || !lastSegment || scrollView.viewportHeight <= 0) return false;\n\t\tconst before = scrollView.scrollTop;\n\t\tconst visibleBottom = before + scrollView.viewportHeight - 1;\n\t\tlet target = before;\n\t\tif (firstSegment.row < before || lastSegment.row > visibleBottom) {\n\t\t\ttarget = firstSegment.row - Math.floor(scrollView.viewportHeight / 3);\n\t\t}\n\t\tscrollView.scrollTo(target, { disableFollow: true });\n\t\treturn scrollView.scrollTop !== before;\n\t}\n\n\t/** Show a transient message in the alternate-screen flash stack. */\n\tflash(message: string, durationMs?: number): void {\n\t\tthis.flashes.flash(message, durationMs);\n\t}\n\n\tprivate shouldDeferViewportInputToOverlay(): boolean {\n\t\treturn this.isOverlayFocused() && this.activeSearch?.overlay?.isFocused() !== true;\n\t}\n\n\tprivate handleViewportInput(data: string): { consume?: boolean } | undefined {\n\t\tif (data === FOCUS_OUT) {\n\t\t\tconst hadActiveSelection = this.selectionPressActive;\n\t\t\tconst hadNonEmptyActiveSelection = hadActiveSelection && this.getSelectionBounds() !== undefined;\n\t\t\tthis.selectionPressActive = false;\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\tthis.stopScrollbarHover();\n\t\t\tthis.stopScrollbarDrag();\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tthis.selectionDragged = false;\n\t\t\tif (hadActiveSelection) {\n\t\t\t\tthis.selectionAnchor = undefined;\n\t\t\t\tthis.selectionFocus = undefined;\n\t\t\t\tthis.selectionGranularity = \"character\";\n\t\t\t\tthis.selectionInitialRange = undefined;\n\t\t\t\tif (hadNonEmptyActiveSelection) this.requestRender();\n\t\t\t}\n\t\t\tthis.lastClick = undefined;\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (data === FOCUS_IN) return { consume: true };\n\n\t\tconst wheelEvent = this.parseWheelEvent(data);\n\t\tif (wheelEvent) {\n\t\t\tif (this.shouldDeferViewportInputToOverlay()) return undefined;\n\t\t\tthis.routeWheel(wheelEvent);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tconst mouseEvent = this.parseSgrMouseEvent(data);\n\t\tif (mouseEvent) {\n\t\t\tif (this.handleRightClickPaste(mouseEvent)) return { consume: true };\n\t\t\tconst handled = this.handleScrollbarMouseEvent(mouseEvent);\n\t\t\tif (!this.scrollbarDrag) this.updateScrollbarHover(mouseEvent.x, mouseEvent.y);\n\t\t\tif (!handled) this.handleSelectionMouseEvent(mouseEvent);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (this.isMouseSequence(data)) return { consume: true };\n\n\t\tconst keybindings = getKeybindings();\n\t\tconst isRelease = isKeyRelease(data);\n\t\tif (keybindings.matches(data, \"tui.altScreen.search\")) {\n\t\t\tif (!isRelease) this.openSearch();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (this.activeSearch?.overlay?.isFocused()) {\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchNext\")) {\n\t\t\t\tif (!isRelease) this.navigateSearch(1);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchPrevious\")) {\n\t\t\t\tif (!isRelease) this.navigateSearch(-1);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (keybindings.matches(data, \"tui.altScreen.searchClose\")) {\n\t\t\t\tif (!isRelease) this.closeSearch();\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t}\n\t\tif (this.shouldDeferViewportInputToOverlay()) return undefined;\n\t\tif (keybindings.matches(data, \"tui.altScreen.pageUp\")) {\n\t\t\tif (!isRelease) {\n\t\t\t\tthis.scrollBy(-Math.max(1, this.getPrimaryScrollView().viewportHeight - PAGE_SCROLL_OVERLAP));\n\t\t\t}\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.pageDown\")) {\n\t\t\tif (!isRelease) {\n\t\t\t\tthis.scrollBy(Math.max(1, this.getPrimaryScrollView().viewportHeight - PAGE_SCROLL_OVERLAP));\n\t\t\t}\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.halfPageUp\")) {\n\t\t\tif (!isRelease) this.scrollBy(-Math.max(1, Math.floor(this.getPrimaryScrollView().viewportHeight / 2)));\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.halfPageDown\")) {\n\t\t\tif (!isRelease) this.scrollBy(Math.max(1, Math.floor(this.getPrimaryScrollView().viewportHeight / 2)));\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.lineUp\")) {\n\t\t\tif (!isRelease) this.scrollBy(-1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.lineDown\")) {\n\t\t\tif (!isRelease) this.scrollBy(1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.previousPrompt\")) {\n\t\t\tif (!isRelease) this.scrollToPrompt(-1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.nextPrompt\")) {\n\t\t\tif (!isRelease) this.scrollToPrompt(1);\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.top\")) {\n\t\t\tif (!isRelease) this.scrollToTop();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (keybindings.matches(data, \"tui.altScreen.bottom\")) {\n\t\t\tif (!isRelease) this.scrollToBottom();\n\t\t\treturn { consume: true };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate parseWheelEvent(data: string): WheelEvent | undefined {\n\t\tconst sgr = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)[Mm]$/.exec(data);\n\t\tif (sgr) {\n\t\t\tconst button = Number.parseInt(sgr[1], 10);\n\t\t\tif ((button & 64) === 0) return undefined;\n\t\t\tconst direction = button & 3;\n\t\t\tif (direction !== 0 && direction !== 1) return undefined;\n\t\t\treturn {\n\t\t\t\tdirection: direction === 0 ? -1 : 1,\n\t\t\t\tx: Number.parseInt(sgr[2], 10) - 1,\n\t\t\t\ty: Number.parseInt(sgr[3], 10) - 1,\n\t\t\t};\n\t\t}\n\t\tif (data.length === 6 && data.startsWith(\"\\x1b[M\")) {\n\t\t\tconst button = data.charCodeAt(3) - 32;\n\t\t\tif ((button & 64) === 0) return undefined;\n\t\t\tconst direction = button & 3;\n\t\t\tif (direction !== 0 && direction !== 1) return undefined;\n\t\t\treturn {\n\t\t\t\tdirection: direction === 0 ? -1 : 1,\n\t\t\t\tx: data.charCodeAt(4) - 33,\n\t\t\t\ty: data.charCodeAt(5) - 33,\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate routeWheel(event: WheelEvent): void {\n\t\tlet remaining = event.direction * this.wheelScrollLines;\n\t\tconst seen = new Set<ScrollView>();\n\t\tfor (const scrollView of this.currentLayout ? getScrollViewsAt(this.currentLayout, event.x, event.y) : []) {\n\t\t\tseen.add(scrollView);\n\t\t\tremaining = scrollView.scrollBy(remaining);\n\t\t\tif (remaining === 0 || scrollView.overscroll === \"contain\") break;\n\t\t}\n\t\tconst primary = this.getPrimaryScrollView();\n\t\tif (remaining !== 0 && !seen.has(primary)) primary.scrollBy(remaining);\n\t\tthis.updateScrollbarHover(event.x, event.y);\n\t\tthis.requestRender();\n\t}\n\n\tprivate parseSgrMouseEvent(data: string): SgrMouseEvent | undefined {\n\t\tconst match = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)([Mm])$/.exec(data);\n\t\tif (!match) return undefined;\n\t\treturn {\n\t\t\tbutton: Number.parseInt(match[1], 10),\n\t\t\tx: Number.parseInt(match[2], 10) - 1,\n\t\t\ty: Number.parseInt(match[3], 10) - 1,\n\t\t\trelease: match[4] === \"m\",\n\t\t};\n\t}\n\n\tprivate handleRightClickPaste(event: SgrMouseEvent): boolean {\n\t\tif (\n\t\t\t!this.onRightClickPaste ||\n\t\t\tprocess.platform !== \"win32\" ||\n\t\t\tprocess.env.TERM_PROGRAM?.toLowerCase() === \"vscode\" ||\n\t\t\tevent.release ||\n\t\t\tevent.button !== 2\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\ttry {\n\t\t\tthis.onRightClickPaste();\n\t\t} catch {\n\t\t\t// Clipboard paste is best-effort.\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate getScrollbarTargetAt(x: number, y: number): ScrollbarTarget | undefined {\n\t\tif (this.hasOverlay() || !this.currentLayout) return undefined;\n\t\tfor (const scrollView of getScrollViewsAt(this.currentLayout, x, y)) {\n\t\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\t\tconst geometry = box ? getScrollbarGeometry(box) : undefined;\n\t\t\tif (\n\t\t\t\tgeometry &&\n\t\t\t\tx === geometry.column &&\n\t\t\t\ty >= geometry.thumbTop &&\n\t\t\t\ty < geometry.thumbTop + geometry.thumbHeight\n\t\t\t) {\n\t\t\t\treturn { scrollView, geometry };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setScrollbarHover(scrollView: ScrollView | undefined): void {\n\t\tif (scrollView === this.scrollbarHover) return;\n\t\tthis.scrollbarHover?.setScrollbarActive(false);\n\t\tthis.scrollbarHover = scrollView;\n\t\tthis.scrollbarHover?.setScrollbarActive(true);\n\t}\n\n\tprivate updateScrollbarHover(x: number, y: number): void {\n\t\tthis.setScrollbarHover(this.getScrollbarTargetAt(x, y)?.scrollView);\n\t}\n\n\tprivate stopScrollbarHover(): void {\n\t\tthis.setScrollbarHover(undefined);\n\t}\n\n\tprivate handleScrollbarMouseEvent(event: SgrMouseEvent): boolean {\n\t\tif (this.scrollbarDrag) {\n\t\t\tif (event.release) {\n\t\t\t\tthis.stopScrollbarDrag();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst box = this.currentLayout\n\t\t\t\t? getScrollViewBox(this.currentLayout, this.scrollbarDrag.scrollView)\n\t\t\t\t: undefined;\n\t\t\tconst geometry = box ? getScrollbarGeometry(box) : undefined;\n\t\t\tif (geometry) {\n\t\t\t\tconst maxThumbOffset = geometry.trackHeight - geometry.thumbHeight;\n\t\t\t\tconst thumbOffset = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min(maxThumbOffset, event.y - geometry.trackTop - this.scrollbarDrag.grabOffset),\n\t\t\t\t);\n\t\t\t\tconst scrollTop =\n\t\t\t\t\tmaxThumbOffset === 0 ? 0 : Math.round((thumbOffset / maxThumbOffset) * geometry.maxScrollTop);\n\t\t\t\tthis.scrollbarDrag.scrollView.scrollTo(scrollTop);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (event.release || (event.button & 32) !== 0 || (event.button & 3) !== 0) return false;\n\t\tconst target = this.getScrollbarTargetAt(event.x, event.y);\n\t\tif (!target) return false;\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = false;\n\t\tthis.selectionAnchor = undefined;\n\t\tthis.selectionFocus = undefined;\n\t\tthis.selectionGranularity = \"character\";\n\t\tthis.selectionInitialRange = undefined;\n\t\tthis.lastClick = undefined;\n\t\tthis.pressedUrl = undefined;\n\t\tthis.selectionDragged = false;\n\t\tthis.setScrollbarHover(target.scrollView);\n\t\tthis.scrollbarDrag = {\n\t\t\tscrollView: target.scrollView,\n\t\t\tgrabOffset: event.y - target.geometry.thumbTop,\n\t\t};\n\t\treturn true;\n\t}\n\n\tprivate stopScrollbarDrag(): void {\n\t\tthis.scrollbarDrag = undefined;\n\t}\n\n\tprivate getScrollSelectionPoint(scrollView: ScrollView, x: number, y: number): SelectionPoint | undefined {\n\t\tif (!this.currentLayout) return undefined;\n\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\tif (!box || box.rect.height <= 0 || box.clip.height <= 0) return undefined;\n\t\tconst visibleTop = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst visibleBottom = Math.min(\n\t\t\tthis.terminal.rows - 1,\n\t\t\tbox.rect.y + box.rect.height - 1,\n\t\t\tbox.clip.y + box.clip.height - 1,\n\t\t);\n\t\tif (visibleBottom < visibleTop) return undefined;\n\t\tconst pointerRow = Math.max(visibleTop, Math.min(visibleBottom, y));\n\t\tconst maxContentRow = Math.max(0, (box.scrollContentLines?.length ?? 1) - 1);\n\t\treturn {\n\t\t\trow: Math.max(0, Math.min(maxContentRow, scrollView.scrollTop + pointerRow - box.rect.y)),\n\t\t\tcol: Math.max(0, Math.min(box.rect.width - 1, x - box.rect.x)),\n\t\t\tscrollView,\n\t\t};\n\t}\n\n\tprivate getSelectionPoint(event: SgrMouseEvent, scrollView?: ScrollView): SelectionPoint {\n\t\tif (scrollView) {\n\t\t\tconst point = this.getScrollSelectionPoint(scrollView, event.x, event.y);\n\t\t\tif (point) return point;\n\t\t}\n\t\treturn {\n\t\t\trow: Math.max(0, Math.min(this.terminal.rows - 1, event.y)),\n\t\t\tcol: Math.max(0, Math.min(this.terminal.columns - 1, event.x)),\n\t\t};\n\t}\n\n\tprivate getSelectionSourceLine(point: SelectionPoint): string {\n\t\tif (point.scrollView && this.currentLayout) {\n\t\t\tconst lines = getScrollViewBox(this.currentLayout, point.scrollView)?.scrollContentLines;\n\t\t\tif (lines) return lines[point.row] ?? \"\";\n\t\t}\n\t\treturn this.previousScreen[point.row] ?? \"\";\n\t}\n\n\tprivate getWordSelection(point: SelectionPoint): SelectionRange | undefined {\n\t\tconst line = stripTerminalSequences(this.getSelectionSourceLine(point));\n\t\tlet start = 0;\n\t\tfor (const segment of wordSegmenter.segment(line)) {\n\t\t\tconst end = start + visibleWidth(segment.segment);\n\t\t\tif (point.col >= start && point.col < end) {\n\t\t\t\treturn {\n\t\t\t\t\tstart: { ...point, col: start },\n\t\t\t\t\tend: { ...point, col: end, boundary: true },\n\t\t\t\t};\n\t\t\t}\n\t\t\tstart = end;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate getLineSelection(point: SelectionPoint): SelectionRange {\n\t\treturn {\n\t\t\tstart: { ...point, col: 0 },\n\t\t\tend: { ...point, col: visibleWidth(this.getSelectionSourceLine(point)), boundary: true },\n\t\t};\n\t}\n\n\tprivate updateSelectionFocus(point: SelectionPoint): void {\n\t\tif (this.selectionGranularity === \"character\" || !this.selectionInitialRange) {\n\t\t\tthis.selectionFocus = point;\n\t\t\treturn;\n\t\t}\n\t\tconst range = this.selectionGranularity === \"word\" ? this.getWordSelection(point) : this.getLineSelection(point);\n\t\tif (!range) return;\n\t\tconst initial = this.selectionInitialRange;\n\t\tconst targetBeforeInitial =\n\t\t\trange.start.row < initial.start.row ||\n\t\t\t(range.start.row === initial.start.row && range.start.col < initial.start.col);\n\t\tif (targetBeforeInitial) {\n\t\t\tthis.selectionAnchor = initial.end;\n\t\t\tthis.selectionFocus = range.start;\n\t\t} else {\n\t\t\tthis.selectionAnchor = initial.start;\n\t\t\tthis.selectionFocus = range.end;\n\t\t}\n\t}\n\n\tprivate getClickCount(point: SelectionPoint, word: SelectionRange | undefined): number {\n\t\tconst now = Date.now();\n\t\tconst previous = this.lastClick;\n\t\tconst count =\n\t\t\tword &&\n\t\t\tprevious &&\n\t\t\tnow - previous.timestamp <= DOUBLE_CLICK_INTERVAL_MS &&\n\t\t\tprevious.row === point.row &&\n\t\t\tprevious.scrollView === point.scrollView &&\n\t\t\tprevious.wordStart === word.start.col &&\n\t\t\tprevious.wordEnd === word.end.col\n\t\t\t\t? (previous.count % 3) + 1\n\t\t\t\t: 1;\n\t\tthis.lastClick = word\n\t\t\t? {\n\t\t\t\t\ttimestamp: now,\n\t\t\t\t\tcount,\n\t\t\t\t\trow: point.row,\n\t\t\t\t\tscrollView: point.scrollView,\n\t\t\t\t\twordStart: word.start.col,\n\t\t\t\t\twordEnd: word.end.col,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn count;\n\t}\n\n\tprivate updateSelectionAutoScroll(event: SgrMouseEvent): void {\n\t\tconst scrollView = this.selectionAnchor?.scrollView;\n\t\tif (!scrollView || !this.currentLayout) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst box = getScrollViewBox(this.currentLayout, scrollView);\n\t\tif (!box || box.rect.height <= 0 || box.clip.height <= 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst visibleTop = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst visibleBottom = Math.min(\n\t\t\tthis.terminal.rows - 1,\n\t\t\tbox.rect.y + box.rect.height - 1,\n\t\t\tbox.clip.y + box.clip.height - 1,\n\t\t);\n\t\tthis.selectionDragPointer = { x: event.x, y: event.y };\n\t\tthis.selectionAutoScrollDirection = event.y <= visibleTop ? -1 : event.y >= visibleBottom ? 1 : 0;\n\t\tif (this.selectionAutoScrollDirection === 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tif (this.selectionAutoScrollTimer) return;\n\t\tthis.selectionAutoScrollTimer = setInterval(() => this.autoScrollSelection(), 50);\n\t\tthis.selectionAutoScrollTimer.unref();\n\t}\n\n\tprivate autoScrollSelection(): void {\n\t\tconst scrollView = this.selectionAnchor?.scrollView;\n\t\tconst pointer = this.selectionDragPointer;\n\t\tconst direction = this.selectionAutoScrollDirection;\n\t\tif (!scrollView || !pointer || direction === 0) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst remaining = scrollView.scrollBy(direction);\n\t\tif (remaining === direction) {\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\treturn;\n\t\t}\n\t\tconst point = this.getScrollSelectionPoint(scrollView, pointer.x, pointer.y);\n\t\tif (point) this.updateSelectionFocus(point);\n\t\tthis.requestRender();\n\t}\n\n\tprivate stopSelectionAutoScroll(): void {\n\t\tif (this.selectionAutoScrollTimer) {\n\t\t\tclearInterval(this.selectionAutoScrollTimer);\n\t\t\tthis.selectionAutoScrollTimer = undefined;\n\t\t}\n\t\tthis.selectionAutoScrollDirection = 0;\n\t\tthis.selectionDragPointer = undefined;\n\t}\n\n\tprivate handleSelectionMouseEvent(event: SgrMouseEvent): void {\n\t\tconst button = event.button & 3;\n\t\tif (button !== 0 && !(event.release && button === 3)) return;\n\t\tconst anchorScrollView = this.selectionAnchor?.scrollView;\n\t\tconst point = this.getSelectionPoint(event, anchorScrollView);\n\t\tif (event.release) {\n\t\t\tif (!this.selectionPressActive) return;\n\t\t\tthis.selectionPressActive = false;\n\t\t\tthis.stopSelectionAutoScroll();\n\t\t\tif (!this.selectionAnchor) return;\n\t\t\tthis.updateSelectionFocus(point);\n\t\t\tconst clickedUrl =\n\t\t\t\t!this.selectionDragged &&\n\t\t\t\tthis.selectionAnchor.scrollView === point.scrollView &&\n\t\t\t\tthis.selectionAnchor.row === point.row &&\n\t\t\t\tthis.selectionAnchor.col === point.col\n\t\t\t\t\t? this.pressedUrl\n\t\t\t\t\t: undefined;\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tif (clickedUrl && this.openUrl) {\n\t\t\t\tthis.selectionAnchor = undefined;\n\t\t\t\tthis.selectionFocus = undefined;\n\t\t\t\ttry {\n\t\t\t\t\tthis.openUrl(clickedUrl);\n\t\t\t\t} catch {\n\t\t\t\t\t// URL activation is best-effort.\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvoid this.copySelectionToClipboard();\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tif ((event.button & 32) !== 0) {\n\t\t\tif (!this.selectionPressActive || !this.selectionAnchor) return;\n\t\t\tthis.selectionDragged = true;\n\t\t\tthis.lastClick = undefined;\n\t\t\tthis.pressedUrl = undefined;\n\t\t\tthis.updateSelectionFocus(point);\n\t\t\tthis.updateSelectionAutoScroll(event);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.stopSelectionAutoScroll();\n\t\tthis.selectionPressActive = true;\n\t\tconst scrollView =\n\t\t\t!this.hasOverlay() && this.currentLayout\n\t\t\t\t? getScrollViewsAt(this.currentLayout, event.x, event.y)[0]\n\t\t\t\t: undefined;\n\t\tconst anchor = this.getSelectionPoint(event, scrollView);\n\t\tconst word = this.getWordSelection(anchor);\n\t\tconst clickCount = this.getClickCount(anchor, word);\n\t\tconst range = clickCount === 2 ? word : clickCount === 3 ? this.getLineSelection(anchor) : undefined;\n\t\tthis.selectionGranularity = range ? (clickCount === 2 ? \"word\" : \"line\") : \"character\";\n\t\tthis.selectionInitialRange = range;\n\t\tthis.selectionAnchor = range?.start ?? anchor;\n\t\tthis.selectionFocus = range?.end ?? anchor;\n\t\tthis.selectionDragged = false;\n\t\tthis.pressedUrl = range\n\t\t\t? undefined\n\t\t\t: getOsc8LinkAtColumn(\n\t\t\t\t\tthis.previousScreen[Math.max(0, Math.min(this.terminal.rows - 1, event.y))] ?? \"\",\n\t\t\t\t\tMath.max(0, Math.min(this.terminal.columns - 1, event.x)),\n\t\t\t\t);\n\t\tthis.requestRender();\n\t}\n\n\tprivate getSelectionBounds(): { start: SelectionPoint; end: SelectionPoint } | undefined {\n\t\tif (!this.selectionAnchor || !this.selectionFocus) return undefined;\n\t\tif (this.selectionAnchor.scrollView !== this.selectionFocus.scrollView) return undefined;\n\t\tconst anchorBeforeFocus =\n\t\t\tthis.selectionAnchor.row < this.selectionFocus.row ||\n\t\t\t(this.selectionAnchor.row === this.selectionFocus.row && this.selectionAnchor.col < this.selectionFocus.col);\n\t\tif (\n\t\t\tthis.selectionAnchor.row === this.selectionFocus.row &&\n\t\t\tthis.selectionAnchor.col === this.selectionFocus.col\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn anchorBeforeFocus\n\t\t\t? { start: this.selectionAnchor, end: this.selectionFocus }\n\t\t\t: { start: this.selectionFocus, end: this.selectionAnchor };\n\t}\n\n\tprivate getSelectionColumns(\n\t\tline: string,\n\t\trow: number,\n\t\tselection: { start: SelectionPoint; end: SelectionPoint },\n\t\tminColumn = 0,\n\t\tmaxColumn = visibleWidth(line),\n\t): { start: number; end: number } {\n\t\tconst lineWidth = visibleWidth(line);\n\t\tlet start = Math.max(0, minColumn);\n\t\tlet end = Math.min(lineWidth, maxColumn);\n\t\tif (row === selection.start.row) {\n\t\t\tstart = getGraphemeCellRange(line, selection.start.col)?.start ?? Math.min(selection.start.col, lineWidth);\n\t\t}\n\t\tif (row === selection.end.row) {\n\t\t\tend = selection.end.boundary\n\t\t\t\t? Math.min(selection.end.col, lineWidth)\n\t\t\t\t: (getGraphemeCellRange(line, selection.end.col)?.end ?? Math.min(selection.end.col + 1, lineWidth));\n\t\t}\n\t\treturn { start: Math.max(minColumn, start), end: Math.min(maxColumn, end) };\n\t}\n\n\tprivate async copySelectionToClipboard(): Promise<void> {\n\t\tconst selection = this.getSelectionBounds();\n\t\tif (!selection) return;\n\t\tlet sourceLines: readonly string[] = this.previousScreen;\n\t\tif (selection.start.scrollView) {\n\t\t\tif (!this.currentLayout) return;\n\t\t\tconst box = getScrollViewBox(this.currentLayout, selection.start.scrollView);\n\t\t\tif (!box?.scrollContentLines) return;\n\t\t\tsourceLines = box.scrollContentLines;\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tfor (let row = selection.start.row; row <= selection.end.row; row++) {\n\t\t\tconst line = sourceLines[row] ?? \"\";\n\t\t\tconst columns = this.getSelectionColumns(line, row, selection);\n\t\t\tlines.push(\n\t\t\t\tstripTerminalSequences(\n\t\t\t\t\tsliceByColumn(line, columns.start, Math.max(0, columns.end - columns.start), true),\n\t\t\t\t).trimEnd(),\n\t\t\t);\n\t\t}\n\t\tconst text = lines.join(\"\\n\");\n\t\tif (text.length === 0) return;\n\t\t// Prefer an injected clipboard implementation (native clipboard + platform tools with a\n\t\t// verified success path) when the host app provides one. A bare OSC 52 write can show\n\t\t// \"Copied!\" while leaving the system clipboard untouched (e.g. macOS Terminal.app, tmux\n\t\t// without OSC 52 clipboard passthrough), so only report success when it actually copies.\n\t\tif (this.copySelection) {\n\t\t\tconst ok = await this.copySelection(text);\n\t\t\tthis.flash(ok ? \"Copied!\" : \"Copy failed\");\n\t\t\treturn;\n\t\t}\n\t\tthis.terminal.write(`\\x1b]52;c;${Buffer.from(text).toString(\"base64\")}\\x07`);\n\t\tthis.flash(\"Copied!\");\n\t}\n\n\tprivate applySearchTextHighlight(text: string, current: boolean): string {\n\t\tconst style = current ? this.searchCurrentMatchStyle : this.searchMatchStyle;\n\t\tlet result = \"\";\n\t\tlet plainStart = 0;\n\t\tlet index = 0;\n\t\twhile (index < text.length) {\n\t\t\tconst ansi = extractAnsiCode(text, index);\n\t\t\tif (!ansi) {\n\t\t\t\tindex += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (index > plainStart) result += style(text.slice(plainStart, index));\n\t\t\tresult += ansi.code;\n\t\t\tindex += ansi.length;\n\t\t\tplainStart = index;\n\t\t}\n\t\tif (plainStart < text.length) result += style(text.slice(plainStart));\n\t\treturn result;\n\t}\n\n\tprivate applySearchHighlights(screen: string[], layout: LayoutFrame): string[] {\n\t\tconst search = this.activeSearch;\n\t\tif (!search || search.selectedIndex < 0 || search.matches.length === 0) return screen;\n\t\tconst scrollView = layout.primaryScrollView ?? this.implicitScrollView;\n\t\tconst box = getScrollViewBox(layout, scrollView);\n\t\tif (!box) return screen;\n\n\t\tconst rangesByRow = new Map<number, SearchHighlightRange[]>();\n\t\tconst scrollbarColumn = getScrollbarGeometry(box)?.column;\n\t\tconst minRow = Math.max(0, box.rect.y, box.clip.y);\n\t\tconst maxRow = Math.min(screen.length, box.rect.y + box.rect.height, box.clip.y + box.clip.height);\n\t\tconst minColumn = Math.max(0, box.rect.x, box.clip.x);\n\t\tconst maxColumn = Math.min(\n\t\t\tthis.terminal.columns,\n\t\t\tbox.rect.x + box.rect.width,\n\t\t\tbox.clip.x + box.clip.width,\n\t\t\tscrollbarColumn ?? Number.POSITIVE_INFINITY,\n\t\t);\n\t\tfor (let matchIndex = 0; matchIndex < search.matches.length; matchIndex++) {\n\t\t\tfor (const segment of search.matches[matchIndex]!.segments) {\n\t\t\t\tconst row = box.rect.y + segment.row - scrollView.scrollTop;\n\t\t\t\tif (row < minRow || row >= maxRow) continue;\n\t\t\t\tconst startCol = Math.max(minColumn, box.rect.x + segment.startCol);\n\t\t\t\tconst endCol = Math.min(maxColumn, box.rect.x + segment.endCol);\n\t\t\t\tif (endCol <= startCol) continue;\n\t\t\t\tconst ranges = rangesByRow.get(row) ?? [];\n\t\t\t\tranges.push({ startCol, endCol, current: matchIndex === search.selectedIndex });\n\t\t\t\trangesByRow.set(row, ranges);\n\t\t\t}\n\t\t}\n\n\t\tconst result = [...screen];\n\t\tfor (const [row, ranges] of rangesByRow) {\n\t\t\tlet line = result[row] ?? \"\";\n\t\t\tif (isImageLine(line)) continue;\n\t\t\tconst lineWidth = visibleWidth(line);\n\t\t\tfor (const range of ranges.sort((a, b) => b.startCol - a.startCol)) {\n\t\t\t\tconst startCol = Math.min(range.startCol, lineWidth);\n\t\t\t\tconst endCol = Math.min(range.endCol, lineWidth);\n\t\t\t\tif (endCol <= startCol) continue;\n\t\t\t\tconst before = sliceByColumn(line, 0, startCol, true);\n\t\t\t\tconst highlighted = sliceByColumn(line, startCol, endCol - startCol, true);\n\t\t\t\tconst after = sliceByColumn(line, endCol, Math.max(0, lineWidth - endCol), true);\n\t\t\t\tline = `${before}${this.applySearchTextHighlight(highlighted, range.current)}${after}`;\n\t\t\t}\n\t\t\tresult[row] = line;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate applySelectionHighlight(text: string): string {\n\t\tlet result = \"\\x1b[7m\";\n\t\tlet index = 0;\n\t\twhile (index < text.length) {\n\t\t\tconst ansi = extractAnsiCode(text, index);\n\t\t\tif (!ansi) {\n\t\t\t\tresult += text[index];\n\t\t\t\tindex += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult += ansi.code;\n\t\t\tif (ansi.code.endsWith(\"m\")) result += \"\\x1b[7m\";\n\t\t\tindex += ansi.length;\n\t\t}\n\t\treturn `${result}\\x1b[27m`;\n\t}\n\n\tprivate applySelection(screen: string[], layout = this.currentLayout): string[] {\n\t\tconst selection = this.getSelectionBounds();\n\t\tif (!selection) return screen;\n\t\tlet screenSelection = selection;\n\t\tlet minRow = 0;\n\t\tlet maxRow = screen.length - 1;\n\t\tlet minColumn = 0;\n\t\tlet maxColumn = this.terminal.columns;\n\t\tif (selection.start.scrollView) {\n\t\t\tif (!layout) return screen;\n\t\t\tconst box = getScrollViewBox(layout, selection.start.scrollView);\n\t\t\tif (!box) return screen;\n\t\t\tminRow = Math.max(0, box.rect.y, box.clip.y);\n\t\t\tmaxRow = Math.min(screen.length - 1, box.rect.y + box.rect.height - 1, box.clip.y + box.clip.height - 1);\n\t\t\tminColumn = Math.max(0, box.rect.x, box.clip.x);\n\t\t\tmaxColumn = Math.min(this.terminal.columns, box.rect.x + box.rect.width, box.clip.x + box.clip.width);\n\t\t\tscreenSelection = {\n\t\t\t\tstart: {\n\t\t\t\t\t...selection.start,\n\t\t\t\t\trow: box.rect.y + selection.start.row - selection.start.scrollView.scrollTop,\n\t\t\t\t\tcol: box.rect.x + selection.start.col,\n\t\t\t\t},\n\t\t\t\tend: {\n\t\t\t\t\t...selection.end,\n\t\t\t\t\trow: box.rect.y + selection.end.row - selection.start.scrollView.scrollTop,\n\t\t\t\t\tcol: box.rect.x + selection.end.col,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn screen.map((line, row) => {\n\t\t\tif (\n\t\t\t\trow < minRow ||\n\t\t\t\trow > maxRow ||\n\t\t\t\trow < screenSelection.start.row ||\n\t\t\t\trow > screenSelection.end.row ||\n\t\t\t\tisImageLine(line)\n\t\t\t) {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\tconst lineWidth = visibleWidth(line);\n\t\t\tconst columns = this.getSelectionColumns(line, row, screenSelection, minColumn, maxColumn);\n\t\t\tif (columns.end <= columns.start) return line;\n\t\t\tconst before = sliceByColumn(line, 0, columns.start, true);\n\t\t\tconst selected = sliceByColumn(line, columns.start, columns.end - columns.start, true);\n\t\t\tconst after = sliceByColumn(line, columns.end, Math.max(0, lineWidth - columns.end), true);\n\t\t\treturn `${before}${this.applySelectionHighlight(selected)}${after}`;\n\t\t});\n\t}\n\n\tprivate isMouseSequence(data: string): boolean {\n\t\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[Mm]$/.test(data) || (data.length === 6 && data.startsWith(\"\\x1b[M\"));\n\t}\n\n\tprivate compositeFlashes(screen: string[], width: number, height: number): string[] {\n\t\tconst flashLines = this.flashes.render(width).slice(-height);\n\t\tif (flashLines.length === 0) return screen;\n\t\tconst result = [...screen];\n\t\twhile (result.length < height) result.push(\"\");\n\t\tfor (let row = 0; row < flashLines.length; row++) {\n\t\t\tconst line = flashLines[row]!;\n\t\t\tconst flashWidth = visibleWidth(line);\n\t\t\tif (flashWidth === 0) continue;\n\t\t\tresult[row] = compositeTuiLine(result[row] ?? \"\", line, width - flashWidth, flashWidth, width);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override doRender(): void {\n\t\tif (this.stopped || !this.altScreenActive) return;\n\t\tconst width = Math.max(1, this.terminal.columns);\n\t\tconst height = Math.max(1, this.terminal.rows);\n\t\tconst root = this.layoutRoot ?? this.implicitScrollView;\n\t\tlet nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());\n\t\tif (this.refreshSearch(nextLayout)) {\n\t\t\tnextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());\n\t\t}\n\t\tlet screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX, \"\"));\n\t\tscreen = this.applySearchHighlights(screen, nextLayout);\n\t\tscreen = this.compositeOverlays(screen, width, height);\n\t\tif (screen.length > height) screen = screen.slice(screen.length - height);\n\t\tscreen = this.applySelection(screen, nextLayout);\n\t\tscreen = this.compositeFlashes(screen, width, height);\n\n\t\tconst cursorPos = this.extractCursorPosition(screen, height);\n\t\tscreen = this.applyLineResets(screen).map((line) => {\n\t\t\tif (isImageLine(line) || visibleWidth(line) <= width) return line;\n\t\t\treturn sliceByColumn(line, 0, width, true);\n\t\t});\n\n\t\tconst fullRedraw =\n\t\t\tthis.previousScreen.length === 0 || this.previousScreenWidth !== width || this.previousScreenHeight !== height;\n\t\tconst imagesNeedRedraw = screen.some(\n\t\t\t(line, row) =>\n\t\t\t\tline !== this.previousScreen[row] && (isImageLine(line) || isImageLine(this.previousScreen[row] ?? \"\")),\n\t\t);\n\t\tconst redrawImages = fullRedraw || imagesNeedRedraw;\n\t\tconst hadUploadedKittyImages = this.uploadedKittyImages.size > 0;\n\t\tconst preparedKittyScreen =\n\t\t\tredrawImages && this.imageProtocol === \"kitty\"\n\t\t\t\t? this.prepareKittyScreen(screen)\n\t\t\t\t: { lines: screen, evictedImageDeletion: \"\" };\n\n\t\tlet buffer = BEGIN_SYNCHRONIZED_OUTPUT;\n\t\tif (fullRedraw) {\n\t\t\tthis.fullRedrawCount += 1;\n\t\t\tconst clearImages =\n\t\t\t\tthis.imageProtocol === \"kitty\" && hadUploadedKittyImages\n\t\t\t\t\t? deleteAllKittyPlacements()\n\t\t\t\t\t: this.deleteKittyImages();\n\t\t\tbuffer += `${clearImages}\\x1b[2J`;\n\t\t} else if (imagesNeedRedraw) {\n\t\t\tif (this.imageProtocol === \"iterm2\") buffer += \"\\x1b[2J\";\n\t\t\telse if (this.imageProtocol === \"kitty\") buffer += deleteAllKittyPlacements();\n\t\t}\n\t\tbuffer += preparedKittyScreen.evictedImageDeletion;\n\n\t\tfor (let row = 0; row < height; row++) {\n\t\t\tif (!fullRedraw && !imagesNeedRedraw && screen[row] === this.previousScreen[row]) continue;\n\t\t\tbuffer += `\\x1b[${row + 1};1H\\x1b[2K${preparedKittyScreen.lines[row] ?? \"\"}`;\n\t\t}\n\n\t\tif (cursorPos) {\n\t\t\tbuffer += `\\x1b[${cursorPos.row + 1};${Math.min(width, cursorPos.col) + 1}H`;\n\t\t\tbuffer += this.getShowHardwareCursor() ? \"\\x1b[?25h\" : \"\\x1b[?25l\";\n\t\t} else {\n\t\t\tbuffer += \"\\x1b[?25l\";\n\t\t}\n\t\tbuffer += END_SYNCHRONIZED_OUTPUT;\n\t\tthis.terminal.write(buffer);\n\n\t\tthis.previousScreen = screen;\n\t\tthis.previousScreenWidth = width;\n\t\tthis.previousScreenHeight = height;\n\t\tthis.currentLayout = nextLayout;\n\t}\n}\n"]}
@@ -558,7 +558,11 @@ export class TuiAltScreen extends TuiBase {
558
558
  };
559
559
  }
560
560
  handleRightClickPaste(event) {
561
- if (!this.onRightClickPaste || process.platform !== "win32" || event.release || event.button !== 2) {
561
+ if (!this.onRightClickPaste ||
562
+ process.platform !== "win32" ||
563
+ process.env.TERM_PROGRAM?.toLowerCase() === "vscode" ||
564
+ event.release ||
565
+ event.button !== 2) {
562
566
  return false;
563
567
  }
564
568
  try {