@iaforged/context-code 2.1.5 → 2.1.7

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 (409) hide show
  1. package/dist/src/Task.js +1 -1
  2. package/dist/src/commands/add-dir/add-dir.js +1 -1
  3. package/dist/src/commands/add-dir/validation.js +1 -1
  4. package/dist/src/constants/oauth.js +1 -1
  5. package/dist/src/context/mailbox.js +1 -1
  6. package/dist/src/context/voice.js +1 -1
  7. package/dist/src/hooks/useTerminalSize.js +1 -1
  8. package/dist/src/ink/Ansi.js +1 -1
  9. package/dist/src/ink/clearTerminal.js +1 -1
  10. package/dist/src/ink/colorize.js +1 -1
  11. package/dist/src/ink/components/App.js +1 -1
  12. package/dist/src/ink/components/Button.js +1 -1
  13. package/dist/src/ink/components/ClockContext.js +1 -1
  14. package/dist/src/ink/components/CursorDeclarationContext.js +1 -1
  15. package/dist/src/ink/components/Link.js +1 -1
  16. package/dist/src/ink/components/StdinContext.js +1 -1
  17. package/dist/src/ink/components/TerminalFocusContext.js +1 -1
  18. package/dist/src/ink/dom.js +1 -1
  19. package/dist/src/ink/events/keyboard-event.js +1 -1
  20. package/dist/src/ink/hit-test.js +1 -1
  21. package/dist/src/ink/hooks/use-animation-frame.js +1 -1
  22. package/dist/src/ink/hooks/use-app.js +1 -1
  23. package/dist/src/ink/hooks/use-input.js +1 -1
  24. package/dist/src/ink/hooks/use-interval.js +1 -1
  25. package/dist/src/ink/hooks/use-selection.js +1 -1
  26. package/dist/src/ink/hooks/use-tab-status.js +1 -1
  27. package/dist/src/ink/hooks/use-terminal-focus.js +1 -1
  28. package/dist/src/ink/hooks/use-terminal-title.js +1 -1
  29. package/dist/src/ink/hooks/use-terminal-viewport.js +1 -1
  30. package/dist/src/ink/ink.js +1 -1
  31. package/dist/src/ink/layout/yoga.js +1 -1
  32. package/dist/src/ink/line-width-cache.js +1 -1
  33. package/dist/src/ink/log-update.js +1 -1
  34. package/dist/src/ink/measure-text.js +1 -1
  35. package/dist/src/ink/output.js +1 -1
  36. package/dist/src/ink/parse-keypress.js +1 -1
  37. package/dist/src/ink/reconciler.js +1 -1
  38. package/dist/src/ink/render-border.js +1 -1
  39. package/dist/src/ink/render-node-to-output.js +1 -1
  40. package/dist/src/ink/render-to-screen.js +1 -1
  41. package/dist/src/ink/renderer.js +1 -1
  42. package/dist/src/ink/root.js +1 -1
  43. package/dist/src/ink/screen.js +1 -1
  44. package/dist/src/ink/searchHighlight.js +1 -1
  45. package/dist/src/ink/selection.js +1 -1
  46. package/dist/src/ink/squash-text-nodes.js +1 -1
  47. package/dist/src/ink/stringWidth.js +1 -1
  48. package/dist/src/ink/tabstops.js +1 -1
  49. package/dist/src/ink/terminal.js +1 -1
  50. package/dist/src/ink/termio/osc.js +1 -1
  51. package/dist/src/ink/termio/parser.js +1 -1
  52. package/dist/src/ink/termio/tokenize.js +1 -1
  53. package/dist/src/ink/useTerminalNotification.js +1 -1
  54. package/dist/src/ink/warn.js +1 -1
  55. package/dist/src/ink/widest-line.js +1 -1
  56. package/dist/src/ink/wrap-text.js +1 -1
  57. package/dist/src/ink/wrapAnsi.js +1 -1
  58. package/dist/src/native-ts/yoga-layout/index.js +1 -1
  59. package/dist/src/schemas/hooks.js +1 -1
  60. package/dist/src/services/SessionMemory/sessionMemoryUtils.js +1 -1
  61. package/dist/src/services/api/client.js +1 -1
  62. package/dist/src/services/api/dumpPrompts.js +1 -1
  63. package/dist/src/services/api/errorUtils.js +1 -1
  64. package/dist/src/services/api/promptCacheBreakDetection.js +1 -1
  65. package/dist/src/services/api/withRetry.js +1 -1
  66. package/dist/src/services/autoDream/consolidationLock.js +1 -1
  67. package/dist/src/services/mcp/elicitationHandler.js +1 -1
  68. package/dist/src/services/mcp/mcpStringUtils.js +1 -1
  69. package/dist/src/services/mcp/oauthPort.js +1 -1
  70. package/dist/src/services/mcp/vscodeSdkMcp.js +1 -1
  71. package/dist/src/services/oauth/client.js +1 -1
  72. package/dist/src/services/oauth/getOauthProfile.js +1 -1
  73. package/dist/src/services/objetivo/types.js +1 -1
  74. package/dist/src/services/rateLimitMocking.js +1 -1
  75. package/dist/src/services/remoteManagedSettings/syncCacheState.js +1 -1
  76. package/dist/src/skills/bundledSkills.js +1 -1
  77. package/dist/src/tasks/DreamTask/DreamTask.js +1 -1
  78. package/dist/src/tools/AgentTool/agentMemory.js +1 -1
  79. package/dist/src/tools/AgentTool/forkSubagent.js +1 -1
  80. package/dist/src/tools/BashTool/BashToolResultMessage.js +1 -1
  81. package/dist/src/tools/BashTool/UI.js +1 -1
  82. package/dist/src/tools/BashTool/sedEditParser.js +1 -1
  83. package/dist/src/tools/BashTool/utils.js +1 -1
  84. package/dist/src/tools/FileReadTool/imageProcessor.js +1 -1
  85. package/dist/src/tools/FileReadTool/prompt.js +1 -1
  86. package/dist/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +1 -1
  87. package/dist/src/tools/ListMcpResourcesTool/UI.js +1 -1
  88. package/dist/src/tools/MCPTool/MCPTool.js +1 -1
  89. package/dist/src/tools/MCPTool/UI.js +1 -1
  90. package/dist/src/tools/McpAuthTool/McpAuthTool.js +1 -1
  91. package/dist/src/tools/NotebookEditTool/prompt.js +1 -1
  92. package/dist/src/tools/PowerShellTool/PowerShellTool.js +1 -1
  93. package/dist/src/tools/PowerShellTool/UI.js +1 -1
  94. package/dist/src/tools/PowerShellTool/gitSafety.js +1 -1
  95. package/dist/src/tools/PowerShellTool/modeValidation.js +1 -1
  96. package/dist/src/tools/PowerShellTool/pathValidation.js +1 -1
  97. package/dist/src/tools/PowerShellTool/powershellPermissions.js +1 -1
  98. package/dist/src/tools/PowerShellTool/powershellSecurity.js +1 -1
  99. package/dist/src/tools/PowerShellTool/prompt.js +1 -1
  100. package/dist/src/tools/PowerShellTool/readOnlyValidation.js +1 -1
  101. package/dist/src/tools/REPLTool/constants.js +1 -1
  102. package/dist/src/tools/REPLTool/primitiveTools.js +1 -1
  103. package/dist/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +1 -1
  104. package/dist/src/tools/ReadMcpResourceTool/UI.js +1 -1
  105. package/dist/src/tools/ScheduleCronTool/prompt.js +1 -1
  106. package/dist/src/tools/SkillTool/prompt.js +1 -1
  107. package/dist/src/tools/TodoWriteTool/TodoWriteTool.js +1 -1
  108. package/dist/src/tools/ToolSearchTool/prompt.js +1 -1
  109. package/dist/src/tools/WebSearchTool/prompt.js +1 -1
  110. package/dist/src/tools/shared/gitOperationTracking.js +1 -1
  111. package/dist/src/types/permissions.js +1 -1
  112. package/dist/src/utils/Cursor.js +1 -1
  113. package/dist/src/utils/QueryGuard.js +1 -1
  114. package/dist/src/utils/Shell.js +1 -1
  115. package/dist/src/utils/ShellCommand.js +1 -1
  116. package/dist/src/utils/activityManager.js +1 -1
  117. package/dist/src/utils/advisor.js +1 -1
  118. package/dist/src/utils/appleTerminalBackup.js +1 -1
  119. package/dist/src/utils/argumentSubstitution.js +1 -1
  120. package/dist/src/utils/authFileDescriptor.js +1 -1
  121. package/dist/src/utils/autoUpdater.js +1 -1
  122. package/dist/src/utils/background/remote/preconditions.js +1 -1
  123. package/dist/src/utils/background/remote/remoteSession.js +1 -1
  124. package/dist/src/utils/bash/ShellSnapshot.js +1 -1
  125. package/dist/src/utils/bash/ast.js +1 -1
  126. package/dist/src/utils/bash/bashParser.js +1 -1
  127. package/dist/src/utils/bash/bashPipeCommand.js +1 -1
  128. package/dist/src/utils/bash/parser.js +1 -1
  129. package/dist/src/utils/bash/shellQuote.js +1 -1
  130. package/dist/src/utils/bash/shellQuoting.js +1 -1
  131. package/dist/src/utils/billing.js +1 -1
  132. package/dist/src/utils/caCerts.js +1 -1
  133. package/dist/src/utils/claudeInChrome/common.js +1 -1
  134. package/dist/src/utils/claudeInChrome/setupPortable.js +1 -1
  135. package/dist/src/utils/claudemd.js +1 -1
  136. package/dist/src/utils/collapseBackgroundBashNotifications.js +1 -1
  137. package/dist/src/utils/collapseReadSearch.js +1 -1
  138. package/dist/src/utils/completionCache.js +1 -1
  139. package/dist/src/utils/computerUse/common.js +1 -1
  140. package/dist/src/utils/concurrentSessions.js +1 -1
  141. package/dist/src/utils/context.js +1 -1
  142. package/dist/src/utils/cron.js +1 -1
  143. package/dist/src/utils/cronTasks.js +1 -1
  144. package/dist/src/utils/cwd.js +1 -1
  145. package/dist/src/utils/debug.js +1 -1
  146. package/dist/src/utils/debugFilter.js +1 -1
  147. package/dist/src/utils/detectRepository.js +1 -1
  148. package/dist/src/utils/diagLogs.js +1 -1
  149. package/dist/src/utils/diff.js +1 -1
  150. package/dist/src/utils/directMemberMessage.js +1 -1
  151. package/dist/src/utils/doctorDiagnostic.js +1 -1
  152. package/dist/src/utils/dxt/helpers.js +1 -1
  153. package/dist/src/utils/dxt/zip.js +1 -1
  154. package/dist/src/utils/earlyInput.js +1 -1
  155. package/dist/src/utils/editor.js +1 -1
  156. package/dist/src/utils/effort.js +1 -1
  157. package/dist/src/utils/embeddedTools.js +1 -1
  158. package/dist/src/utils/envDynamic.js +1 -1
  159. package/dist/src/utils/envUtils.js +1 -1
  160. package/dist/src/utils/execFileNoThrowPortable.js +1 -1
  161. package/dist/src/utils/execSyncWrapper.js +1 -1
  162. package/dist/src/utils/exportRenderer.js +1 -1
  163. package/dist/src/utils/extraUsage.js +1 -1
  164. package/dist/src/utils/fastMode.js +1 -1
  165. package/dist/src/utils/fileOperationAnalytics.js +1 -1
  166. package/dist/src/utils/fileRead.js +1 -1
  167. package/dist/src/utils/findExecutable.js +1 -1
  168. package/dist/src/utils/format.js +1 -1
  169. package/dist/src/utils/frontmatterParser.js +1 -1
  170. package/dist/src/utils/fsOperations.js +1 -1
  171. package/dist/src/utils/fullscreen.js +1 -1
  172. package/dist/src/utils/genericProcessUtils.js +1 -1
  173. package/dist/src/utils/getWorktreePaths.js +1 -1
  174. package/dist/src/utils/git/gitConfigParser.js +1 -1
  175. package/dist/src/utils/git/gitFilesystem.js +1 -1
  176. package/dist/src/utils/git/gitignore.js +1 -1
  177. package/dist/src/utils/gitDiff.js +1 -1
  178. package/dist/src/utils/gitSettings.js +1 -1
  179. package/dist/src/utils/glob.js +1 -1
  180. package/dist/src/utils/gracefulShutdown.js +1 -1
  181. package/dist/src/utils/groupToolUses.js +1 -1
  182. package/dist/src/utils/handlePromptSubmit.js +1 -1
  183. package/dist/src/utils/hash.js +1 -1
  184. package/dist/src/utils/hooks/fileChangedWatcher.js +1 -1
  185. package/dist/src/utils/hooks/hooksSettings.js +1 -1
  186. package/dist/src/utils/hooks/registerSkillHooks.js +1 -1
  187. package/dist/src/utils/hooks/sessionHooks.js +1 -1
  188. package/dist/src/utils/http.js +1 -1
  189. package/dist/src/utils/hyperlink.js +1 -1
  190. package/dist/src/utils/ide.js +1 -1
  191. package/dist/src/utils/idePathConversion.js +1 -1
  192. package/dist/src/utils/imagePaste.js +1 -1
  193. package/dist/src/utils/imageResizer.js +1 -1
  194. package/dist/src/utils/imageStore.js +1 -1
  195. package/dist/src/utils/inProcessTeammateHelpers.js +1 -1
  196. package/dist/src/utils/ink.js +1 -1
  197. package/dist/src/utils/jetbrains.js +1 -1
  198. package/dist/src/utils/json.js +1 -1
  199. package/dist/src/utils/listSessionsImpl.js +1 -1
  200. package/dist/src/utils/localInstaller.js +1 -1
  201. package/dist/src/utils/lockfile.js +1 -1
  202. package/dist/src/utils/logoV2Utils.js +1 -1
  203. package/dist/src/utils/markdown.js +1 -1
  204. package/dist/src/utils/mcp/dateTimeParser.js +1 -1
  205. package/dist/src/utils/mcpOutputStorage.js +1 -1
  206. package/dist/src/utils/mcpValidation.js +1 -1
  207. package/dist/src/utils/memoize.js +1 -1
  208. package/dist/src/utils/memory/types.js +1 -1
  209. package/dist/src/utils/memoryFileDetection.js +1 -1
  210. package/dist/src/utils/messageQueueManager.js +1 -1
  211. package/dist/src/utils/messages/mappers.js +1 -1
  212. package/dist/src/utils/messages/systemInit.js +1 -1
  213. package/dist/src/utils/model/antModels.js +1 -1
  214. package/dist/src/utils/model/check1mAccess.js +1 -1
  215. package/dist/src/utils/model/contextWindowUpgradeCheck.js +1 -1
  216. package/dist/src/utils/model/model.js +1 -1
  217. package/dist/src/utils/model/modelAllowlist.js +1 -1
  218. package/dist/src/utils/model/modelCapabilities.js +1 -1
  219. package/dist/src/utils/model/modelOptions.js +1 -1
  220. package/dist/src/utils/model/modelStrings.js +1 -1
  221. package/dist/src/utils/model/providerModels.js +1 -1
  222. package/dist/src/utils/model/providerProfiles.js +1 -1
  223. package/dist/src/utils/model/providerProfilesDb.js +1 -1
  224. package/dist/src/utils/model/providerSwitch.js +1 -1
  225. package/dist/src/utils/model/providers.js +1 -1
  226. package/dist/src/utils/modelCost.js +1 -1
  227. package/dist/src/utils/modifiers.js +1 -1
  228. package/dist/src/utils/mtls.js +1 -1
  229. package/dist/src/utils/nativeInstaller/download.js +1 -1
  230. package/dist/src/utils/nativeInstaller/installer.js +1 -1
  231. package/dist/src/utils/nativeInstaller/packageManagers.js +1 -1
  232. package/dist/src/utils/nativeInstaller/pidLock.js +1 -1
  233. package/dist/src/utils/notebook.js +1 -1
  234. package/dist/src/utils/pasteStore.js +1 -1
  235. package/dist/src/utils/path.js +1 -1
  236. package/dist/src/utils/permissions/PermissionMode.js +1 -1
  237. package/dist/src/utils/permissions/PermissionPromptToolResultSchema.js +1 -1
  238. package/dist/src/utils/permissions/PermissionUpdate.js +1 -1
  239. package/dist/src/utils/permissions/PermissionUpdateSchema.js +1 -1
  240. package/dist/src/utils/permissions/autoModeState.js +1 -1
  241. package/dist/src/utils/permissions/bypassPermissionsKillswitch.js +1 -1
  242. package/dist/src/utils/permissions/filesystem.js +1 -1
  243. package/dist/src/utils/permissions/getNextPermissionMode.js +1 -1
  244. package/dist/src/utils/permissions/pathValidation.js +1 -1
  245. package/dist/src/utils/permissions/permissionRuleParser.js +1 -1
  246. package/dist/src/utils/permissions/permissionsDb.js +1 -1
  247. package/dist/src/utils/permissions/permissionsLoader.js +1 -1
  248. package/dist/src/utils/permissions/shellRuleMatching.js +1 -1
  249. package/dist/src/utils/planModeV2.js +1 -1
  250. package/dist/src/utils/plans.js +1 -1
  251. package/dist/src/utils/platform.js +1 -1
  252. package/dist/src/utils/plugins/addDirPluginSettings.js +1 -1
  253. package/dist/src/utils/plugins/cacheUtils.js +1 -1
  254. package/dist/src/utils/plugins/dependencyResolver.js +1 -1
  255. package/dist/src/utils/plugins/fetchTelemetry.js +1 -1
  256. package/dist/src/utils/plugins/gitAvailability.js +1 -1
  257. package/dist/src/utils/plugins/hintRecommendation.js +1 -1
  258. package/dist/src/utils/plugins/installedPluginsManager.js +1 -1
  259. package/dist/src/utils/plugins/loadPluginAgents.js +1 -1
  260. package/dist/src/utils/plugins/loadPluginCommands.js +1 -1
  261. package/dist/src/utils/plugins/loadPluginHooks.js +1 -1
  262. package/dist/src/utils/plugins/loadPluginOutputStyles.js +1 -1
  263. package/dist/src/utils/plugins/lspPluginIntegration.js +1 -1
  264. package/dist/src/utils/plugins/lspRecommendation.js +1 -1
  265. package/dist/src/utils/plugins/managedPlugins.js +1 -1
  266. package/dist/src/utils/plugins/marketplaceHelpers.js +1 -1
  267. package/dist/src/utils/plugins/marketplaceManager.js +1 -1
  268. package/dist/src/utils/plugins/mcpPluginIntegration.js +1 -1
  269. package/dist/src/utils/plugins/mcpbHandler.js +1 -1
  270. package/dist/src/utils/plugins/officialMarketplaceGcs.js +1 -1
  271. package/dist/src/utils/plugins/officialMarketplaceStartupCheck.js +1 -1
  272. package/dist/src/utils/plugins/orphanedPluginFilter.js +1 -1
  273. package/dist/src/utils/plugins/performStartupChecks.js +1 -1
  274. package/dist/src/utils/plugins/pluginAutoupdate.js +1 -1
  275. package/dist/src/utils/plugins/pluginBlocklist.js +1 -1
  276. package/dist/src/utils/plugins/pluginDirectories.js +1 -1
  277. package/dist/src/utils/plugins/pluginFlagging.js +1 -1
  278. package/dist/src/utils/plugins/pluginInstallationHelpers.js +1 -1
  279. package/dist/src/utils/plugins/pluginLoader.js +1 -1
  280. package/dist/src/utils/plugins/pluginOptionsStorage.js +1 -1
  281. package/dist/src/utils/plugins/pluginPolicy.js +1 -1
  282. package/dist/src/utils/plugins/pluginStartupCheck.js +1 -1
  283. package/dist/src/utils/plugins/pluginVersioning.js +1 -1
  284. package/dist/src/utils/plugins/reconciler.js +1 -1
  285. package/dist/src/utils/plugins/refresh.js +1 -1
  286. package/dist/src/utils/plugins/schemas.js +1 -1
  287. package/dist/src/utils/plugins/walkPluginMarkdown.js +1 -1
  288. package/dist/src/utils/plugins/zipCache.js +1 -1
  289. package/dist/src/utils/powershell/parser.js +1 -1
  290. package/dist/src/utils/processUserInput/processBashCommand.js +1 -1
  291. package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
  292. package/dist/src/utils/processUserInput/processTextPrompt.js +1 -1
  293. package/dist/src/utils/processUserInput/processUserInput.js +1 -1
  294. package/dist/src/utils/profilerBase.js +1 -1
  295. package/dist/src/utils/promptCategory.js +1 -1
  296. package/dist/src/utils/promptEditor.js +1 -1
  297. package/dist/src/utils/promptShellExecution.js +1 -1
  298. package/dist/src/utils/proxy.js +1 -1
  299. package/dist/src/utils/queryHelpers.js +1 -1
  300. package/dist/src/utils/queryProfiler.js +1 -1
  301. package/dist/src/utils/queueProcessor.js +1 -1
  302. package/dist/src/utils/readFileInRange.js +1 -1
  303. package/dist/src/utils/releaseNotes.js +1 -1
  304. package/dist/src/utils/renderOptions.js +1 -1
  305. package/dist/src/utils/ripgrep.js +1 -1
  306. package/dist/src/utils/sandbox/sandbox-adapter.js +1 -1
  307. package/dist/src/utils/sdkEventQueue.js +1 -1
  308. package/dist/src/utils/secureStorage/index.js +1 -1
  309. package/dist/src/utils/secureStorage/macOsKeychainHelpers.js +1 -1
  310. package/dist/src/utils/secureStorage/macOsKeychainStorage.js +1 -1
  311. package/dist/src/utils/secureStorage/plainTextStorage.js +1 -1
  312. package/dist/src/utils/secureStorage/sqliteStorage.js +1 -1
  313. package/dist/src/utils/sessionEnvironment.js +1 -1
  314. package/dist/src/utils/sessionIngressAuth.js +1 -1
  315. package/dist/src/utils/sessionRestore.js +1 -1
  316. package/dist/src/utils/sessionStart.js +1 -1
  317. package/dist/src/utils/sessionTitle.js +1 -1
  318. package/dist/src/utils/settings/managedPath.js +1 -1
  319. package/dist/src/utils/settings/mdm/rawRead.js +1 -1
  320. package/dist/src/utils/settings/mdm/settings.js +1 -1
  321. package/dist/src/utils/settings/permissionValidation.js +1 -1
  322. package/dist/src/utils/settings/pluginOnlyPolicy.js +1 -1
  323. package/dist/src/utils/settings/schemaOutput.js +1 -1
  324. package/dist/src/utils/settings/settings.js +1 -1
  325. package/dist/src/utils/settings/types.js +1 -1
  326. package/dist/src/utils/settings/validateEditTool.js +1 -1
  327. package/dist/src/utils/settings/validation.js +1 -1
  328. package/dist/src/utils/shell/bashProvider.js +1 -1
  329. package/dist/src/utils/shell/powershellDetection.js +1 -1
  330. package/dist/src/utils/shell/powershellProvider.js +1 -1
  331. package/dist/src/utils/shell/readOnlyCommandValidation.js +1 -1
  332. package/dist/src/utils/shell/resolveDefaultShell.js +1 -1
  333. package/dist/src/utils/shell/shellToolUtils.js +1 -1
  334. package/dist/src/utils/shell/specPrefix.js +1 -1
  335. package/dist/src/utils/shellConfig.js +1 -1
  336. package/dist/src/utils/sideQuestion.js +1 -1
  337. package/dist/src/utils/skills/skillChangeDetector.js +1 -1
  338. package/dist/src/utils/slashCommandParsing.js +1 -1
  339. package/dist/src/utils/sliceAnsi.js +1 -1
  340. package/dist/src/utils/slowOperations.js +1 -1
  341. package/dist/src/utils/standaloneAgent.js +1 -1
  342. package/dist/src/utils/startupProfiler.js +1 -1
  343. package/dist/src/utils/staticRender.js +1 -1
  344. package/dist/src/utils/status.js +1 -1
  345. package/dist/src/utils/statusNoticeDefinitions.js +1 -1
  346. package/dist/src/utils/suggestions/commandSuggestions.js +1 -1
  347. package/dist/src/utils/suggestions/directoryCompletion.js +1 -1
  348. package/dist/src/utils/suggestions/shellHistoryCompletion.js +1 -1
  349. package/dist/src/utils/suggestions/skillUsageTracking.js +1 -1
  350. package/dist/src/utils/suggestions/slackChannelSuggestions.js +1 -1
  351. package/dist/src/utils/swarm/backends/detection.js +1 -1
  352. package/dist/src/utils/swarm/permissionSync.js +1 -1
  353. package/dist/src/utils/swarm/reconnection.js +1 -1
  354. package/dist/src/utils/swarm/spawnUtils.js +91 -1
  355. package/dist/src/utils/swarm/teammateInit.js +1 -1
  356. package/dist/src/utils/systemDirectories.js +1 -1
  357. package/dist/src/utils/systemPrompt.js +1 -1
  358. package/dist/src/utils/systemTheme.js +1 -1
  359. package/dist/src/utils/task/TaskOutput.js +1 -1
  360. package/dist/src/utils/task/diskOutput.js +1 -1
  361. package/dist/src/utils/tasks.js +1 -1
  362. package/dist/src/utils/teamDiscovery.js +1 -1
  363. package/dist/src/utils/teamMemoryOps.js +1 -1
  364. package/dist/src/utils/teammateMailbox.js +1 -1
  365. package/dist/src/utils/telemetry/betaSessionTracing.js +1 -1
  366. package/dist/src/utils/telemetry/bigqueryExporter.js +1 -1
  367. package/dist/src/utils/telemetry/events.js +1 -1
  368. package/dist/src/utils/telemetry/instrumentation.js +1 -1
  369. package/dist/src/utils/telemetry/logger.js +1 -1
  370. package/dist/src/utils/telemetry/perfettoTracing.js +1 -1
  371. package/dist/src/utils/telemetry/pluginTelemetry.js +1 -1
  372. package/dist/src/utils/telemetry/sessionTracing.js +1 -1
  373. package/dist/src/utils/telemetryAttributes.js +1 -1
  374. package/dist/src/utils/teleport/api.js +1 -1
  375. package/dist/src/utils/teleport/environments.js +1 -1
  376. package/dist/src/utils/teleport/gitBundle.js +1 -1
  377. package/dist/src/utils/teleport.js +1 -1
  378. package/dist/src/utils/tempfile.js +1 -1
  379. package/dist/src/utils/terminal.js +1 -1
  380. package/dist/src/utils/terminalPanel.js +1 -1
  381. package/dist/src/utils/textHighlighting.js +1 -1
  382. package/dist/src/utils/theme.js +1 -1
  383. package/dist/src/utils/themes/bootstrap.js +1 -1
  384. package/dist/src/utils/themes/loader.js +1 -1
  385. package/dist/src/utils/thinking.js +1 -1
  386. package/dist/src/utils/tmuxSocket.js +1 -1
  387. package/dist/src/utils/tokens.js +1 -1
  388. package/dist/src/utils/toolPool.js +1 -1
  389. package/dist/src/utils/toolResultStorage.js +1 -1
  390. package/dist/src/utils/transcriptSearch.js +1 -1
  391. package/dist/src/utils/truncate.js +1 -1
  392. package/dist/src/utils/ultraplan/keyword.js +1 -1
  393. package/dist/src/utils/unaryLogging.js +1 -1
  394. package/dist/src/utils/undercover.js +1 -1
  395. package/dist/src/utils/user.js +1 -1
  396. package/dist/src/utils/userPromptKeywords.js +1 -1
  397. package/dist/src/utils/which.js +1 -1
  398. package/dist/src/utils/windowsPaths.js +1 -1
  399. package/dist/src/utils/worktree.js +1 -1
  400. package/dist/src/utils/zodToJsonSchema.js +1 -1
  401. package/dist/src/vim/operators.js +1 -1
  402. package/dist/src/vim/textObjects.js +1 -1
  403. package/dist/src/vim/transitions.js +1 -1
  404. package/dist/src/voice/voiceModeEnabled.js +1 -1
  405. package/dist/src/webapp/auth.js +1 -1
  406. package/dist/src/webapp/tunnel.js +1 -1
  407. package/dist/src/whatsapp/bridge.js +1 -1
  408. package/dist/src/whatsapp/mirror.js +1 -1
  409. package/package.json +1 -1
@@ -1 +1 @@
1
- import{styledCharsFromTokens as t,tokenize as e}from"@alcalzone/ansi-tokenize";import{logForDebugging as i}from"../utils/debug.js";import{getGraphemeSegmenter as n}from"../utils/intl.js";import o from"../utils/sliceAnsi.js";import{reorderBidi as s}from"./bidi.js";import{unionRect as r}from"./layout/geometry.js";import{blitRegion as h,extractHyperlinkFromStyles as c,filterOutHyperlinkStyles as l,markNoSelectRegion as f,OSC8_PREFIX as a,resetScreen as u,setCellAt as p,shiftRows as y}from"./screen.js";import{stringWidth as d}from"./stringWidth.js";import{widestLine as m}from"./widest-line.js";function intersectClip(t,e){return t?{x1:maxDefined(t.x1,e.x1),x2:minDefined(t.x2,e.x2),y1:maxDefined(t.y1,e.y1),y2:minDefined(t.y2,e.y2)}:e}function maxDefined(t,e){return void 0===t?e:void 0===e?t:Math.max(t,e)}function minDefined(t,e){return void 0===t?e:void 0===e?t:Math.min(t,e)}export default class Output{width;height;stylePool;screen;operations=[];charCache=new Map;constructor(t){const{width:e,height:i,stylePool:n,screen:o}=t;this.width=e,this.height=i,this.stylePool=n,this.screen=o,u(o,e,i)}reset(t,e,i){this.width=t,this.height=e,this.screen=i,this.operations.length=0,u(i,t,e),this.charCache.size>16384&&this.charCache.clear()}blit(t,e,i,n,o){this.operations.push({type:"blit",src:t,x:e,y:i,width:n,height:o})}shift(t,e,i){this.operations.push({type:"shift",top:t,bottom:e,n:i})}clear(t,e){this.operations.push({type:"clear",region:t,fromAbsolute:e})}noSelect(t){this.operations.push({type:"noSelect",region:t})}write(t,e,i,n){i&&this.operations.push({type:"write",x:t,y:e,text:i,softWrap:n})}clip(t){this.operations.push({type:"clip",clip:t})}unclip(){this.operations.push({type:"unclip"})}get(){const t=this.screen,e=this.width,n=this.height;let s=0,c=0;const l=[];for(const i of this.operations){if("clear"!==i.type)continue;const{x:o,y:s,width:h,height:c}=i.region,f=Math.max(0,o),a=Math.max(0,s),u=Math.min(o+h,e),p=Math.min(s+c,n);if(f>=u||a>=p)continue;const y={x:f,y:a,width:u-f,height:p-a};t.damage=t.damage?r(t.damage,y):y,i.fromAbsolute&&l.push(y)}const a=[];for(const i of this.operations)switch(i.type){case"clear":continue;case"clip":a.push(intersectClip(a.at(-1),i.clip));continue;case"unclip":a.pop();continue;case"blit":{const{src:o,x:r,y:c,width:f,height:u}=i,p=a.at(-1),y=Math.max(r,p?.x1??0),d=Math.max(c,p?.y1??0),m=Math.min(c+u,n,o.height,p?.y2??1/0),g=Math.min(r+f,e,o.width,p?.x2??1/0);if(y>=g||d>=m)continue;if(0===l.length){h(t,o,y,d,g,m),s+=(m-d)*(g-y);continue}let x=d;for(let e=d;e<=m;e++){(e<m&&l.some(t=>e>=t.y&&e<t.y+t.height&&y>=t.x&&g<=t.x+t.width)||e===m)&&(e>x&&(h(t,o,y,x,g,e),s+=(e-x)*(g-y)),x=e+1)}continue}case"shift":y(t,i.top,i.bottom,i.n);continue;case"write":{const{text:s,softWrap:r}=i;let{x:h,y:l}=i,f=s.split("\n"),u=0,p=0;const y=a.at(-1);if(y){const t="number"==typeof y?.x1&&"number"==typeof y?.x2,e="number"==typeof y?.y1&&"number"==typeof y?.y2;if(t){const t=m(s);if(h+t<=y.x1||h>=y.x2)continue}if(e){if(l+f.length<=y.y1||l>=y.y2)continue}if(t&&(f=f.map(t=>{const e=h<y.x1?y.x1-h:0,i=d(t),n=h+i>y.x2?y.x2-h:i;let s=o(t,e,n);return d(s)>n-e&&(s=o(t,e,n-1)),s}),h<y.x1&&(h=y.x1)),e){const t=l<y.y1?y.y1-l:0,e=f.length,i=l+e>y.y2?y.y2-l:e;r&&t>0&&!0===r[t]&&(p=h+d(f[t-1])),f=f.slice(t,i),u=t,l<y.y1&&(l=y.y1)}}const g=t.softWrap;let x=0;for(const i of f){const o=l+x;if(o>=n)break;const s=writeLineToScreen(t,i,h,o,e,this.stylePool,this.charCache);if(c+=s-h,r){const t=!0===r[u+x];g[o]=t?p:0,p=s}x++}continue}}for(const e of this.operations)if("noSelect"===e.type){const{x:i,y:n,width:o,height:s}=e.region;f(t,i,n,o,s)}const u=s+c;return u>1e3&&c>s&&i(`High write ratio: blit=${s}, write=${c} (${(c/u*100).toFixed(1)}% writes), screen=${n}x${e}`),t}}function stylesEqual(t,e){if(t===e)return!0;const i=t.length;if(i!==e.length)return!1;if(0===i)return!0;for(let n=0;n<i;n++)if(t[n].code!==e[n].code)return!1;return!0}function flushBuffer(t,e,i,o){const s=c(e)??void 0,r=void 0!==s||e.some(t=>t.code.length>=a.length&&t.code.startsWith(a))?l(e):e,h=i.intern(r);for(const{segment:e}of n().segment(t))o.push({value:e,width:d(e),styleId:h,hyperlink:s})}function writeLineToScreen(i,n,o,r,h,c,l){let f=l.get(n);f||(f=s(function(t,e){const i=t.length;if(0===i)return[];const n=[],o=[];let s=t[0].styles;for(let r=0;r<i;r++){const i=t[r],h=i.styles;o.length>0&&!stylesEqual(h,s)&&(flushBuffer(o.join(""),s,e,n),o.length=0),o.push(i.value),s=h}return o.length>0&&flushBuffer(o.join(""),s,e,n),n}(t(e(n)),c)),l.set(n,f));let a=o;for(let t=0;t<f.length;t++){const e=f[t],n=e.value.codePointAt(0);if(void 0!==n&&n<=31){if(9===n){const t=8,e=t-a%t;for(let t=0;t<e&&a<h;t++)p(i,a,r,{char:" ",styleId:c.none,width:0,hyperlink:void 0}),a++}else if(27===n){const e=f[t+1]?.value,i=e?.codePointAt(0);if("("===e||")"===e||"*"===e||"+"===e)t+=2;else if("["===e)for(t++;t<f.length-1;){t++;const e=f[t]?.value.codePointAt(0);if(void 0!==e&&e>=64&&e<=126)break}else if("]"===e||"P"===e||"_"===e||"^"===e||"X"===e)for(t++;t<f.length-1;){t++;const e=f[t]?.value;if(""===e)break;if(""===e){const e=f[t+1]?.value;if("\\"===e){t++;break}}}else void 0!==i&&i>=48&&i<=126&&t++}continue}const o=e.width;if(0===o)continue;const s=o>=2;s&&a+2>h?(p(i,a,r,{char:" ",styleId:c.none,width:3,hyperlink:void 0}),a++):(p(i,a,r,{char:e.value,styleId:e.styleId,width:s?1:0,hyperlink:e.hyperlink}),a+=s?2:1)}return a}
1
+ import{styledCharsFromTokens as t,tokenize as e}from"@alcalzone/ansi-tokenize";import{logForDebugging as i}from"../utils/debug.js";import{getGraphemeSegmenter as n}from"../utils/intl.js";import o from"../utils/sliceAnsi.js";import{reorderBidi as s}from"./bidi.js";import{unionRect as r}from"./layout/geometry.js";import{blitRegion as h,extractHyperlinkFromStyles as c,filterOutHyperlinkStyles as l,markNoSelectRegion as a,OSC8_PREFIX as f,resetScreen as u,setCellAt as p,shiftRows as y}from"./screen.js";import{stringWidth as d}from"./stringWidth.js";import{widestLine as m}from"./widest-line.js";function intersectClip(t,e){return t?{x1:maxDefined(t.x1,e.x1),x2:minDefined(t.x2,e.x2),y1:maxDefined(t.y1,e.y1),y2:minDefined(t.y2,e.y2)}:e}function maxDefined(t,e){return void 0===t?e:void 0===e?t:Math.max(t,e)}function minDefined(t,e){return void 0===t?e:void 0===e?t:Math.min(t,e)}export default class Output{width;height;stylePool;screen;operations=[];charCache=new Map;constructor(t){const{width:e,height:i,stylePool:n,screen:o}=t;this.width=e,this.height=i,this.stylePool=n,this.screen=o,u(o,e,i)}reset(t,e,i){this.width=t,this.height=e,this.screen=i,this.operations.length=0,u(i,t,e),this.charCache.size>16384&&this.charCache.clear()}blit(t,e,i,n,o){this.operations.push({type:"blit",src:t,x:e,y:i,width:n,height:o})}shift(t,e,i){this.operations.push({type:"shift",top:t,bottom:e,n:i})}clear(t,e){this.operations.push({type:"clear",region:t,fromAbsolute:e})}noSelect(t){this.operations.push({type:"noSelect",region:t})}write(t,e,i,n){i&&this.operations.push({type:"write",x:t,y:e,text:i,softWrap:n})}clip(t){this.operations.push({type:"clip",clip:t})}unclip(){this.operations.push({type:"unclip"})}get(){const t=this.screen,e=this.width,n=this.height;let s=0,c=0;const l=[];for(const i of this.operations){if("clear"!==i.type)continue;const{x:o,y:s,width:h,height:c}=i.region,a=Math.max(0,o),f=Math.max(0,s),u=Math.min(o+h,e),p=Math.min(s+c,n);if(a>=u||f>=p)continue;const y={x:a,y:f,width:u-a,height:p-f};t.damage=t.damage?r(t.damage,y):y,i.fromAbsolute&&l.push(y)}const f=[];for(const i of this.operations)switch(i.type){case"clear":continue;case"clip":f.push(intersectClip(f.at(-1),i.clip));continue;case"unclip":f.pop();continue;case"blit":{const{src:o,x:r,y:c,width:a,height:u}=i,p=f.at(-1),y=Math.max(r,p?.x1??0),d=Math.max(c,p?.y1??0),m=Math.min(c+u,n,o.height,p?.y2??1/0),g=Math.min(r+a,e,o.width,p?.x2??1/0);if(y>=g||d>=m)continue;if(0===l.length){h(t,o,y,d,g,m),s+=(m-d)*(g-y);continue}let x=d;for(let e=d;e<=m;e++)(e<m&&l.some(t=>e>=t.y&&e<t.y+t.height&&y>=t.x&&g<=t.x+t.width)||e===m)&&(e>x&&(h(t,o,y,x,g,e),s+=(e-x)*(g-y)),x=e+1);continue}case"shift":y(t,i.top,i.bottom,i.n);continue;case"write":{const{text:s,softWrap:r}=i;let{x:h,y:l}=i,a=s.split("\n"),u=0,p=0;const y=f.at(-1);if(y){const t="number"==typeof y?.x1&&"number"==typeof y?.x2,e="number"==typeof y?.y1&&"number"==typeof y?.y2;if(t){const t=m(s);if(h+t<=y.x1||h>=y.x2)continue}if(e&&(l+a.length<=y.y1||l>=y.y2))continue;if(t&&(a=a.map(t=>{const e=h<y.x1?y.x1-h:0,i=d(t),n=h+i>y.x2?y.x2-h:i;let s=o(t,e,n);return d(s)>n-e&&(s=o(t,e,n-1)),s}),h<y.x1&&(h=y.x1)),e){const t=l<y.y1?y.y1-l:0,e=a.length,i=l+e>y.y2?y.y2-l:e;r&&t>0&&!0===r[t]&&(p=h+d(a[t-1])),a=a.slice(t,i),u=t,l<y.y1&&(l=y.y1)}}const g=t.softWrap;let x=0;for(const i of a){const o=l+x;if(o>=n)break;const s=writeLineToScreen(t,i,h,o,e,this.stylePool,this.charCache);if(c+=s-h,r){const t=!0===r[u+x];g[o]=t?p:0,p=s}x++}continue}}for(const e of this.operations)if("noSelect"===e.type){const{x:i,y:n,width:o,height:s}=e.region;a(t,i,n,o,s)}const u=s+c;return u>1e3&&c>s&&i(`High write ratio: blit=${s}, write=${c} (${(c/u*100).toFixed(1)}% writes), screen=${n}x${e}`),t}}function stylesEqual(t,e){if(t===e)return!0;const i=t.length;if(i!==e.length)return!1;if(0===i)return!0;for(let n=0;n<i;n++)if(t[n].code!==e[n].code)return!1;return!0}function flushBuffer(t,e,i,o){const s=c(e)??void 0,r=void 0!==s||e.some(t=>t.code.length>=f.length&&t.code.startsWith(f))?l(e):e,h=i.intern(r);for(const{segment:e}of n().segment(t))o.push({value:e,width:d(e),styleId:h,hyperlink:s})}function writeLineToScreen(i,n,o,r,h,c,l){let a=l.get(n);a||(a=s(function(t,e){const i=t.length;if(0===i)return[];const n=[],o=[];let s=t[0].styles;for(let r=0;r<i;r++){const i=t[r],h=i.styles;o.length>0&&!stylesEqual(h,s)&&(flushBuffer(o.join(""),s,e,n),o.length=0),o.push(i.value),s=h}return o.length>0&&flushBuffer(o.join(""),s,e,n),n}(t(e(n)),c)),l.set(n,a));let f=o;for(let t=0;t<a.length;t++){const e=a[t],n=e.value.codePointAt(0);if(void 0!==n&&n<=31){if(9===n){const t=8,e=t-f%t;for(let t=0;t<e&&f<h;t++)p(i,f,r,{char:" ",styleId:c.none,width:0,hyperlink:void 0}),f++}else if(27===n){const e=a[t+1]?.value,i=e?.codePointAt(0);if("("===e||")"===e||"*"===e||"+"===e)t+=2;else if("["===e)for(t++;t<a.length-1;){t++;const e=a[t]?.value.codePointAt(0);if(void 0!==e&&e>=64&&e<=126)break}else if("]"===e||"P"===e||"_"===e||"^"===e||"X"===e)for(t++;t<a.length-1;){t++;const e=a[t]?.value;if(""===e)break;if(""===e){const e=a[t+1]?.value;if("\\"===e){t++;break}}}else void 0!==i&&i>=48&&i<=126&&t++}continue}const o=e.width;if(0===o)continue;const s=o>=2;s&&f+2>h?(p(i,f,r,{char:" ",styleId:c.none,width:3,hyperlink:void 0}),f++):(p(i,f,r,{char:e.value,styleId:e.styleId,width:s?1:0,hyperlink:e.hyperlink}),f+=s?2:1)}return f}
@@ -1 +1 @@
1
- import{Buffer as e}from"buffer";import{PASTE_END as t,PASTE_START as r}from"./termio/csi.js";import{createTokenizer as s}from"./termio/tokenize.js";const n=/^(?:\x1b)([a-zA-Z0-9])$/,a=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,c=/^\x1b\[(\d+)(?:;(\d+))?u/,o=/^\x1b\[27;(\d+);(\d+)~/,u=/^\x1b\[\?(\d+);(\d+)\$y$/,i=/^\x1b\[\?([\d;]*)c$/,f=/^\x1b\[>([\d;]*)c$/,p=/^\x1b\[\?(\d+)u$/,l=/^\x1b\[\?(\d+);(\d+)R$/,d=/^\x1b\](\d+);(.*?)(?:\x07|\x1b\\)$/s,m=/^\x1bP>\|(.*?)(?:\x07|\x1b\\)$/s,h=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/;function createPasteKey(e){return{kind:"key",name:"",fn:!1,ctrl:!1,meta:!1,shift:!1,option:!1,super:!1,sequence:e,raw:e,isPasted:!0}}export const DECRPM_STATUS={NOT_RECOGNIZED:0,SET:1,RESET:2,PERMANENTLY_SET:3,PERMANENTLY_RESET:4};function parseTerminalResponse(e){if(e.startsWith("[")){let t;return(t=u.exec(e))?{type:"decrpm",mode:parseInt(t[1],10),status:parseInt(t[2],10)}:(t=i.exec(e))?{type:"da1",params:splitNumericParams(t[1])}:(t=f.exec(e))?{type:"da2",params:splitNumericParams(t[1])}:(t=p.exec(e))?{type:"kittyKeyboard",flags:parseInt(t[1],10)}:(t=l.exec(e))?{type:"cursorPosition",row:parseInt(t[1],10),col:parseInt(t[2],10)}:null}if(e.startsWith("]")){const t=d.exec(e);if(t)return{type:"osc",code:parseInt(t[1],10),data:t[2]}}if(e.startsWith("P")){const t=m.exec(e);if(t)return{type:"xtversion",name:t[1]}}return null}function splitNumericParams(e){return e?e.split(";").map(e=>parseInt(e,10)):[]}export const INITIAL_STATE={mode:"NORMAL",incomplete:"",pasteBuffer:""};export function parseMultipleKeypresses(n,a=""){const c=null===a,o=c?"":function(t){return e.isBuffer(t)?t[0]>127&&void 0===t[1]?(t[0]-=128,""+String(t)):String(t):void 0!==t&&"string"!=typeof t?String(t):t||""}(a),u=n._tokenizer??s({x10Mouse:!0}),i=c?u.flush():u.feed(o),f=[];let p="IN_PASTE"===n.mode,l=n.pasteBuffer;for(const e of i)if("sequence"===e.type)if(e.value===r)p=!0,l="";else if(e.value===t)f.push(createPasteKey(l)),p=!1,l="";else if(p)l+=e.value;else{const t=parseTerminalResponse(e.value);if(t)f.push({kind:"response",sequence:e.value,response:t});else{const t=parseMouseEvent(e.value);t?f.push(t):f.push(parseKeypress(e.value))}}else if("text"===e.type)if(p)l+=e.value;else if(/^\[<\d+;\d+;\d+[Mm]$/.test(e.value)||/^\[M[\x60-\x7f][\x20-\uffff]{2}$/.test(e.value)){const t=""+e.value,r=parseMouseEvent(t);f.push(r??parseKeypress(t))}else f.push(parseKeypress(e.value));c&&p&&l&&(f.push(createPasteKey(l)),p=!1,l="");return[f,{mode:p?"IN_PASTE":"NORMAL",incomplete:u.buffer(),pasteBuffer:l,_tokenizer:u}]}const O={OP:"f1",OQ:"f2",OR:"f3",OS:"f4",Op:"0",Oq:"1",Or:"2",Os:"3",Ot:"4",Ou:"5",Ov:"6",Ow:"7",Ox:"8",Oy:"9",Oj:"*",Ok:"+",Ol:",",Om:"-",On:".",Oo:"/",OM:"return","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};export const nonAlphanumericKeys=[...Object.values(O).filter(e=>e.length>1),"escape","backspace","wheelup","wheeldown","mouse"];const isShiftKey=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),isCtrlKey=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e);function decodeModifier(e){const t=e-1;return{shift:!!(1&t),meta:!!(2&t),ctrl:!!(4&t),super:!!(8&t)}}function keycodeToName(e){switch(e){case 9:return"tab";case 13:case 57414:return"return";case 27:return"escape";case 32:return"space";case 127:return"backspace";case 57399:return"0";case 57400:return"1";case 57401:return"2";case 57402:return"3";case 57403:return"4";case 57404:return"5";case 57405:return"6";case 57406:return"7";case 57407:return"8";case 57408:return"9";case 57409:return".";case 57410:return"/";case 57411:return"*";case 57412:return"-";case 57413:return"+";case 57415:return"=";default:return e>=32&&e<=126?String.fromCharCode(e).toLowerCase():void 0}}function parseMouseEvent(e){const t=h.exec(e);if(!t)return null;const r=parseInt(t[1],10);return 64&r?null:{kind:"mouse",button:r,action:"M"===t[4]?"press":"release",col:parseInt(t[2],10),row:parseInt(t[3],10),sequence:e}}function parseKeypress(e=""){let t;const r={kind:"key",name:"",fn:!1,ctrl:!1,meta:!1,shift:!1,option:!1,super:!1,sequence:e,raw:e,isPasted:!1};let s;if(r.sequence=r.sequence||e||r.name,s=c.exec(e)){const t=parseInt(s[1],10),r=decodeModifier(s[2]?parseInt(s[2],10):1);return{kind:"key",name:keycodeToName(t),fn:!1,ctrl:r.ctrl,meta:r.meta,shift:r.shift,option:!1,super:r.super,sequence:e,raw:e,isPasted:!1}}if(s=o.exec(e)){const t=decodeModifier(parseInt(s[1],10));return{kind:"key",name:keycodeToName(parseInt(s[2],10)),fn:!1,ctrl:t.ctrl,meta:t.meta,shift:t.shift,option:!1,super:t.super,sequence:e,raw:e,isPasted:!1}}if(s=h.exec(e)){const t=parseInt(s[1],10);return createNavKey(e,64==(67&t)?"wheelup":65==(67&t)?"wheeldown":"mouse",!1)}if(6===e.length&&e.startsWith("")){const t=e.charCodeAt(3)-32;return createNavKey(e,64==(67&t)?"wheelup":65==(67&t)?"wheeldown":"mouse",!1)}if("\r"===e)r.raw=void 0,r.name="return";else if("\n"===e)r.name="enter";else if("\t"===e)r.name="tab";else if("\b"===e||"\b"===e)r.name="backspace",r.meta=""===e.charAt(0);else if(""===e||""===e)r.name="backspace",r.meta=""===e.charAt(0);else if(""===e||""===e)r.name="escape",r.meta=2===e.length;else if(" "===e||" "===e)r.name="space",r.meta=2===e.length;else if(""===e)r.name="_",r.ctrl=!0;else if(e<=""&&1===e.length)r.name=String.fromCharCode(e.charCodeAt(0)+"a".charCodeAt(0)-1),r.ctrl=!0;else if(1===e.length&&e>="0"&&e<="9")r.name="number";else if(1===e.length&&e>="a"&&e<="z")r.name=e;else if(1===e.length&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=n.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=a.exec(e)){const s=[...e];""===s[0]&&""===s[1]&&(r.option=!0);const n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(4&a),r.meta=!!(2&a),r.super=!!(8&a),r.shift=!!(1&a),r.code=n,r.name=O[n],r.shift=isShiftKey(n)||r.shift,r.ctrl=isCtrlKey(n)||r.ctrl}switch("b"===r.raw?(r.meta=!0,r.name="left"):"f"===r.raw&&(r.meta=!0,r.name="right"),e){case"[1~":return createNavKey(e,"home",!1);case"[4~":return createNavKey(e,"end",!1);case"[5~":return createNavKey(e,"pageup",!1);case"[6~":return createNavKey(e,"pagedown",!1);case"":return createNavKey(e,"left",!0);case"":return createNavKey(e,"right",!0)}return r}function createNavKey(e,t,r){return{kind:"key",name:t,ctrl:r,meta:!1,shift:!1,option:!1,super:!1,fn:!1,sequence:e,raw:e,isPasted:!1}}
1
+ import{Buffer as e}from"buffer";import{PASTE_END as t,PASTE_START as r}from"./termio/csi.js";import{createTokenizer as s}from"./termio/tokenize.js";const a=/^(?:\x1b)([a-zA-Z0-9])$/,n=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,c=/^\x1b\[(\d+)(?:;(\d+))?u/,o=/^\x1b\[27;(\d+);(\d+)~/,u=/^\x1b\[\?(\d+);(\d+)\$y$/,i=/^\x1b\[\?([\d;]*)c$/,f=/^\x1b\[>([\d;]*)c$/,p=/^\x1b\[\?(\d+)u$/,l=/^\x1b\[\?(\d+);(\d+)R$/,d=/^\x1b\](\d+);(.*?)(?:\x07|\x1b\\)$/s,m=/^\x1bP>\|(.*?)(?:\x07|\x1b\\)$/s,h=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/;function createPasteKey(e){return{kind:"key",name:"",fn:!1,ctrl:!1,meta:!1,shift:!1,option:!1,super:!1,sequence:e,raw:e,isPasted:!0}}export const DECRPM_STATUS={NOT_RECOGNIZED:0,SET:1,RESET:2,PERMANENTLY_SET:3,PERMANENTLY_RESET:4};function parseTerminalResponse(e){if(e.startsWith("[")){let t;return(t=u.exec(e))?{type:"decrpm",mode:parseInt(t[1],10),status:parseInt(t[2],10)}:(t=i.exec(e))?{type:"da1",params:splitNumericParams(t[1])}:(t=f.exec(e))?{type:"da2",params:splitNumericParams(t[1])}:(t=p.exec(e))?{type:"kittyKeyboard",flags:parseInt(t[1],10)}:(t=l.exec(e))?{type:"cursorPosition",row:parseInt(t[1],10),col:parseInt(t[2],10)}:null}if(e.startsWith("]")){const t=d.exec(e);if(t)return{type:"osc",code:parseInt(t[1],10),data:t[2]}}if(e.startsWith("P")){const t=m.exec(e);if(t)return{type:"xtversion",name:t[1]}}return null}function splitNumericParams(e){return e?e.split(";").map(e=>parseInt(e,10)):[]}export const INITIAL_STATE={mode:"NORMAL",incomplete:"",pasteBuffer:""};export function parseMultipleKeypresses(a,n=""){const c=null===n,o=c?"":function(t){return e.isBuffer(t)?t[0]>127&&void 0===t[1]?(t[0]-=128,""+String(t)):String(t):void 0!==t&&"string"!=typeof t?String(t):t||""}(n),u=a._tokenizer??s({x10Mouse:!0}),i=c?u.flush():u.feed(o),f=[];let p="IN_PASTE"===a.mode,l=a.pasteBuffer;for(const e of i)if("sequence"===e.type)if(e.value===r)p=!0,l="";else if(e.value===t)f.push(createPasteKey(l)),p=!1,l="";else if(p)l+=e.value;else{const t=parseTerminalResponse(e.value);if(t)f.push({kind:"response",sequence:e.value,response:t});else{const t=parseMouseEvent(e.value);t?f.push(t):f.push(parseKeypress(e.value))}}else if("text"===e.type)if(p)l+=e.value;else if(/^\[<\d+;\d+;\d+[Mm]$/.test(e.value)||/^\[M[\x60-\x7f][\x20-\uffff]{2}$/.test(e.value)){const t=""+e.value,r=parseMouseEvent(t);f.push(r??parseKeypress(t))}else f.push(parseKeypress(e.value));return c&&p&&l&&(f.push(createPasteKey(l)),p=!1,l=""),[f,{mode:p?"IN_PASTE":"NORMAL",incomplete:u.buffer(),pasteBuffer:l,_tokenizer:u}]}const O={OP:"f1",OQ:"f2",OR:"f3",OS:"f4",Op:"0",Oq:"1",Or:"2",Os:"3",Ot:"4",Ou:"5",Ov:"6",Ow:"7",Ox:"8",Oy:"9",Oj:"*",Ok:"+",Ol:",",Om:"-",On:".",Oo:"/",OM:"return","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};export const nonAlphanumericKeys=[...Object.values(O).filter(e=>e.length>1),"escape","backspace","wheelup","wheeldown","mouse"];const isShiftKey=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),isCtrlKey=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e);function decodeModifier(e){const t=e-1;return{shift:!!(1&t),meta:!!(2&t),ctrl:!!(4&t),super:!!(8&t)}}function keycodeToName(e){switch(e){case 9:return"tab";case 13:case 57414:return"return";case 27:return"escape";case 32:return"space";case 127:return"backspace";case 57399:return"0";case 57400:return"1";case 57401:return"2";case 57402:return"3";case 57403:return"4";case 57404:return"5";case 57405:return"6";case 57406:return"7";case 57407:return"8";case 57408:return"9";case 57409:return".";case 57410:return"/";case 57411:return"*";case 57412:return"-";case 57413:return"+";case 57415:return"=";default:return e>=32&&e<=126?String.fromCharCode(e).toLowerCase():void 0}}function parseMouseEvent(e){const t=h.exec(e);if(!t)return null;const r=parseInt(t[1],10);return 64&r?null:{kind:"mouse",button:r,action:"M"===t[4]?"press":"release",col:parseInt(t[2],10),row:parseInt(t[3],10),sequence:e}}function parseKeypress(e=""){let t;const r={kind:"key",name:"",fn:!1,ctrl:!1,meta:!1,shift:!1,option:!1,super:!1,sequence:e,raw:e,isPasted:!1};let s;if(r.sequence=r.sequence||e||r.name,s=c.exec(e)){const t=parseInt(s[1],10),r=decodeModifier(s[2]?parseInt(s[2],10):1);return{kind:"key",name:keycodeToName(t),fn:!1,ctrl:r.ctrl,meta:r.meta,shift:r.shift,option:!1,super:r.super,sequence:e,raw:e,isPasted:!1}}if(s=o.exec(e)){const t=decodeModifier(parseInt(s[1],10));return{kind:"key",name:keycodeToName(parseInt(s[2],10)),fn:!1,ctrl:t.ctrl,meta:t.meta,shift:t.shift,option:!1,super:t.super,sequence:e,raw:e,isPasted:!1}}if(s=h.exec(e)){const t=parseInt(s[1],10);return createNavKey(e,64==(67&t)?"wheelup":65==(67&t)?"wheeldown":"mouse",!1)}if(6===e.length&&e.startsWith("")){const t=e.charCodeAt(3)-32;return createNavKey(e,64==(67&t)?"wheelup":65==(67&t)?"wheeldown":"mouse",!1)}if("\r"===e)r.raw=void 0,r.name="return";else if("\n"===e)r.name="enter";else if("\t"===e)r.name="tab";else if("\b"===e||"\b"===e)r.name="backspace",r.meta=""===e.charAt(0);else if(""===e||""===e)r.name="backspace",r.meta=""===e.charAt(0);else if(""===e||""===e)r.name="escape",r.meta=2===e.length;else if(" "===e||" "===e)r.name="space",r.meta=2===e.length;else if(""===e)r.name="_",r.ctrl=!0;else if(e<=""&&1===e.length)r.name=String.fromCharCode(e.charCodeAt(0)+"a".charCodeAt(0)-1),r.ctrl=!0;else if(1===e.length&&e>="0"&&e<="9")r.name="number";else if(1===e.length&&e>="a"&&e<="z")r.name=e;else if(1===e.length&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=a.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=n.exec(e)){const s=[...e];""===s[0]&&""===s[1]&&(r.option=!0);const a=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),n=(t[3]||t[5]||1)-1;r.ctrl=!!(4&n),r.meta=!!(2&n),r.super=!!(8&n),r.shift=!!(1&n),r.code=a,r.name=O[a],r.shift=isShiftKey(a)||r.shift,r.ctrl=isCtrlKey(a)||r.ctrl}switch("b"===r.raw?(r.meta=!0,r.name="left"):"f"===r.raw&&(r.meta=!0,r.name="right"),e){case"[1~":return createNavKey(e,"home",!1);case"[4~":return createNavKey(e,"end",!1);case"[5~":return createNavKey(e,"pageup",!1);case"[6~":return createNavKey(e,"pagedown",!1);case"":return createNavKey(e,"left",!0);case"":return createNavKey(e,"right",!0)}return r}function createNavKey(e,t,r){return{kind:"key",name:t,ctrl:r,meta:!1,shift:!1,option:!1,super:!1,fn:!1,sequence:e,raw:e,isPasted:!1}}
@@ -1 +1 @@
1
- import{appendFileSync as e}from"fs";import t from"react-reconciler";import{getYogaCounters as n}from"../native-ts/yoga-layout/index.js";import{isEnvTruthy as o}from"../utils/envUtils.js";import{appendChildNode as r,clearYogaNodeReferences as s,createNode as i,createTextNode as a,insertBeforeNode as d,markDirty as c,removeChildNode as l,setAttribute as p,setStyle as m,setTextNodeValue as u,setTextStyles as f}from"./dom.js";import{Dispatcher as v}from"./events/dispatcher.js";import{EVENT_HANDLER_PROPS as h}from"./events/event-handlers.js";import{getFocusManager as x,getRootNode as y}from"./focus.js";import{LayoutDisplay as C}from"./layout/node.js";import T from"./styles.js";if("development"===process.env.NODE_ENV)try{import("./devtools.js")}catch(S){if("ERR_MODULE_NOT_FOUND"!==S.code)throw S;console.warn("\nThe environment variable DEV is set to true, so Ink tried to import `react-devtools-core`,\nbut this failed as it was not installed. Debugging with React Devtools requires it.\n\nTo install use this command:\n\n$ npm install --save-dev react-devtools-core\n\t\t\t\t".trim()+"\n")}const diff=(e,t)=>{if(e===t)return;if(!e)return t;const n={};let o=!1;for(const r of Object.keys(e)){(!t||!Object.hasOwn(t,r))&&(n[r]=void 0,o=!0)}if(t)for(const r of Object.keys(t))t[r]!==e[r]&&(n[r]=t[r],o=!0);return o?n:void 0},cleanupYogaNode=e=>{const t=e.yogaNode;t&&(t.unsetMeasureFunc(),s(e),t.freeRecursive())};function setEventHandler(e,t,n){e._eventHandlers||(e._eventHandlers={}),e._eventHandlers[t]=n}function applyProp(e,t,n){if("children"!==t)return"style"===t?(m(e,n),void(e.yogaNode&&T(e.yogaNode,n))):void("textStyles"!==t?h.has(t)?setEventHandler(e,t,n):p(e,t,n):e.textStyles=n)}export function getOwnerChain(e){const t=[],n=new Set;let o=e;for(let e=0;o&&e<50&&!n.has(o);e++){n.add(o);const e=o.elementType,r="function"==typeof e?e.displayName||e.name:"string"==typeof e?void 0:e?.displayName||e?.name;r&&r!==t[t.length-1]&&t.push(r),o=o._debugOwner??o.return}return t}let g;export function isDebugRepaintsEnabled(){return void 0===g&&(g=o(process.env.CONTEXT_CODE_DEBUG_REPAINTS)||o(process.env.CLAUDE_CODE_DEBUG_REPAINTS)),g}export const dispatcher=new v;const E=process.env.CONTEXT_CODE_COMMIT_LOG??process.env.CLAUDE_CODE_COMMIT_LOG;let I=0,N=0,O=0,w=0,_=0,b=0,D=0,F=0,P=0;export function recordYogaMs(e){D=e}export function getLastYogaMs(){return D}export function markCommitStart(){P=performance.now()}export function getLastCommitMs(){return F}export function resetProfileCounters(){D=0,F=0,P=0}const $=t({getRootHostContext:()=>({isInsideText:!1}),prepareForCommit:()=>(E&&(b=performance.now()),null),preparePortalMount:()=>null,clearContainer:()=>!1,resetAfterCommit(t){if(F=P>0?performance.now()-P:0,P=0,E){const t=performance.now();I++;const n=O>0?t-O:0;n>w&&(w=n),O=t;const o=b>0?t-b:0;(n>30||o>20||_>50)&&e(E,`${t.toFixed(1)} gap=${n.toFixed(1)}ms reconcile=${o.toFixed(1)}ms creates=${_}\n`),_=0,t-N>1e3&&(e(E,`${t.toFixed(1)} commits=${I}/s maxGap=${w.toFixed(1)}ms\n`),I=0,w=0,N=t)}const o=E?performance.now():0;if("function"==typeof t.onComputeLayout&&t.onComputeLayout(),E){const t=performance.now()-o;if(t>20){const r=n();e(E,`${o.toFixed(1)} SLOW_YOGA ${t.toFixed(1)}ms visited=${r.visited} measured=${r.measured} hits=${r.cacheHits} live=${r.live}\n`)}}if("test"===process.env.NODE_ENV){if(0===t.childNodes.length&&t.hasRenderedContent)return;return t.childNodes.length>0&&(t.hasRenderedContent=!0),void t.onImmediateRender?.()}const r=E?performance.now():0;if(t.onRender?.(),E){const t=performance.now()-r;t>10&&e(E,`${r.toFixed(1)} SLOW_PAINT ${t.toFixed(1)}ms\n`)}},getChildHostContext(e,t){const n="ink-text"===t||"ink-virtual-text"===t||"ink-link"===t;return e.isInsideText===n?e:{isInsideText:n}},shouldSetTextContent:()=>!1,createInstance(e,t,n,o,r){if(o.isInsideText&&"ink-box"===e)throw new Error("<Box> can't be nested inside <Text> component");const s="ink-text"===e&&o.isInsideText?"ink-virtual-text":e,a=i(s);E&&_++;for(const[e,n]of Object.entries(t))applyProp(a,e,n);return isDebugRepaintsEnabled()&&(a.debugOwnerChain=getOwnerChain(r)),a},createTextInstance(e,t,n){if(!n.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return a(e)},resetTextContent(){},hideTextInstance(e){u(e,"")},unhideTextInstance(e,t){u(e,t)},getPublicInstance:e=>e,hideInstance(e){e.isHidden=!0,e.yogaNode?.setDisplay(C.None),c(e)},unhideInstance(e){e.isHidden=!1,e.yogaNode?.setDisplay(C.Flex),c(e)},appendInitialChild:r,appendChild:r,insertBefore:d,finalizeInitialChildren:(e,t,n)=>!0===n.autoFocus,commitMount(e){x(e).handleAutoFocus(e)},isPrimaryRenderer:!0,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,getCurrentUpdatePriority:()=>dispatcher.currentUpdatePriority,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},getInstanceFromNode:()=>null,prepareScopeUpdate(){},getInstanceFromScope:()=>null,appendChildToContainer:r,insertInContainerBefore:d,removeChildFromContainer(e,t){l(e,t),cleanupYogaNode(t),x(e).handleNodeRemoved(t,e)},commitUpdate(e,t,n,o){const r=diff(n,o),s=diff(n.style,o.style);if(r)for(const[t,n]of Object.entries(r))"style"!==t?"textStyles"!==t?h.has(t)?setEventHandler(e,t,n):p(e,t,n):f(e,n):m(e,n);s&&e.yogaNode&&T(e.yogaNode,s,o.style)},commitTextUpdate(e,t,n){u(e,n)},removeChild(e,t){if(l(e,t),cleanupYogaNode(t),"#text"!==t.nodeName){const n=y(e);n.focusManager.handleNodeRemoved(t,n)}},maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:{$$typeof:Symbol.for("react.context"),_currentValue:null},setCurrentUpdatePriority(e){dispatcher.currentUpdatePriority=e},resolveUpdatePriority:()=>dispatcher.resolveEventPriority(),resetFormInstance(){},requestPostPaintCallback(){},shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent(){},resolveEventType:()=>dispatcher.currentEvent?.type??null,resolveEventTimeStamp:()=>dispatcher.currentEvent?.timeStamp??-1.1});dispatcher.discreteUpdates=$.discreteUpdates.bind($);export default $;
1
+ import{appendFileSync as e}from"fs";import t from"react-reconciler";import{getYogaCounters as n}from"src/native-ts/yoga-layout/index.js";import{isEnvTruthy as o}from"../utils/envUtils.js";import{appendChildNode as r,clearYogaNodeReferences as s,createNode as i,createTextNode as a,insertBeforeNode as d,markDirty as c,removeChildNode as l,setAttribute as p,setStyle as u,setTextNodeValue as m,setTextStyles as f}from"./dom.js";import{Dispatcher as h}from"./events/dispatcher.js";import{EVENT_HANDLER_PROPS as v}from"./events/event-handlers.js";import{getFocusManager as y,getRootNode as x}from"./focus.js";import{LayoutDisplay as C}from"./layout/node.js";import T from"./styles.js";if("development"===process.env.NODE_ENV)try{import("./devtools.js")}catch(R){if("ERR_MODULE_NOT_FOUND"!==R.code)throw R;console.warn("\nThe environment variable DEV is set to true, so Ink tried to import `react-devtools-core`,\nbut this failed as it was not installed. Debugging with React Devtools requires it.\n\nTo install use this command:\n\n$ npm install --save-dev react-devtools-core\n\t\t\t\t".trim()+"\n")}const diff=(e,t)=>{if(e===t)return;if(!e)return t;const n={};let o=!1;for(const r of Object.keys(e))(!t||!Object.hasOwn(t,r))&&(n[r]=void 0,o=!0);if(t)for(const r of Object.keys(t))t[r]!==e[r]&&(n[r]=t[r],o=!0);return o?n:void 0},cleanupYogaNode=e=>{const t=e.yogaNode;t&&(t.unsetMeasureFunc(),s(e),t.freeRecursive())};function setEventHandler(e,t,n){e._eventHandlers||(e._eventHandlers={}),e._eventHandlers[t]=n}function applyProp(e,t,n){if("children"!==t)return"style"===t?(u(e,n),void(e.yogaNode&&T(e.yogaNode,n))):void("textStyles"!==t?v.has(t)?setEventHandler(e,t,n):p(e,t,n):e.textStyles=n)}export function getOwnerChain(e){const t=[],n=new Set;let o=e;for(let e=0;o&&e<50&&!n.has(o);e++){n.add(o);const e=o.elementType,r="function"==typeof e?e.displayName||e.name:"string"==typeof e?void 0:e?.displayName||e?.name;r&&r!==t[t.length-1]&&t.push(r),o=o._debugOwner??o.return}return t}let g;export function isDebugRepaintsEnabled(){return void 0===g&&(g=o(process.env.CONTEXT_CODE_DEBUG_REPAINTS)||o(process.env.CLAUDE_CODE_DEBUG_REPAINTS)),g}export const dispatcher=new h;const N=process.env.CONTEXT_CODE_COMMIT_LOG??process.env.CLAUDE_CODE_COMMIT_LOG;let E=0,I=0,O=0,_=0,w=0,D=0,b=0,F=0,S=0;export function recordYogaMs(e){b=e}export function getLastYogaMs(){return b}export function markCommitStart(){S=performance.now()}export function getLastCommitMs(){return F}export function resetProfileCounters(){b=0,F=0,S=0}const P=t({getRootHostContext:()=>({isInsideText:!1}),prepareForCommit:()=>(N&&(D=performance.now()),null),preparePortalMount:()=>null,clearContainer:()=>!1,resetAfterCommit(t){if(F=S>0?performance.now()-S:0,S=0,N){const t=performance.now();E++;const n=O>0?t-O:0;n>_&&(_=n),O=t;const o=D>0?t-D:0;(n>30||o>20||w>50)&&e(N,`${t.toFixed(1)} gap=${n.toFixed(1)}ms reconcile=${o.toFixed(1)}ms creates=${w}\n`),w=0,t-I>1e3&&(e(N,`${t.toFixed(1)} commits=${E}/s maxGap=${_.toFixed(1)}ms\n`),E=0,_=0,I=t)}const o=N?performance.now():0;if("function"==typeof t.onComputeLayout&&t.onComputeLayout(),N){const t=performance.now()-o;if(t>20){const r=n();e(N,`${o.toFixed(1)} SLOW_YOGA ${t.toFixed(1)}ms visited=${r.visited} measured=${r.measured} hits=${r.cacheHits} live=${r.live}\n`)}}if("test"===process.env.NODE_ENV){if(0===t.childNodes.length&&t.hasRenderedContent)return;return t.childNodes.length>0&&(t.hasRenderedContent=!0),void t.onImmediateRender?.()}const r=N?performance.now():0;if(t.onRender?.(),N){const t=performance.now()-r;t>10&&e(N,`${r.toFixed(1)} SLOW_PAINT ${t.toFixed(1)}ms\n`)}},getChildHostContext(e,t){const n="ink-text"===t||"ink-virtual-text"===t||"ink-link"===t;return e.isInsideText===n?e:{isInsideText:n}},shouldSetTextContent:()=>!1,createInstance(e,t,n,o,r){if(o.isInsideText&&"ink-box"===e)throw new Error("<Box> can't be nested inside <Text> component");const s="ink-text"===e&&o.isInsideText?"ink-virtual-text":e,a=i(s);N&&w++;for(const[e,n]of Object.entries(t))applyProp(a,e,n);return isDebugRepaintsEnabled()&&(a.debugOwnerChain=getOwnerChain(r)),a},createTextInstance(e,t,n){if(!n.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return a(e)},resetTextContent(){},hideTextInstance(e){m(e,"")},unhideTextInstance(e,t){m(e,t)},getPublicInstance:e=>e,hideInstance(e){e.isHidden=!0,e.yogaNode?.setDisplay(C.None),c(e)},unhideInstance(e){e.isHidden=!1,e.yogaNode?.setDisplay(C.Flex),c(e)},appendInitialChild:r,appendChild:r,insertBefore:d,finalizeInitialChildren:(e,t,n)=>!0===n.autoFocus,commitMount(e){y(e).handleAutoFocus(e)},isPrimaryRenderer:!0,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,getCurrentUpdatePriority:()=>dispatcher.currentUpdatePriority,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},getInstanceFromNode:()=>null,prepareScopeUpdate(){},getInstanceFromScope:()=>null,appendChildToContainer:r,insertInContainerBefore:d,removeChildFromContainer(e,t){l(e,t),cleanupYogaNode(t),y(e).handleNodeRemoved(t,e)},commitUpdate(e,t,n,o){const r=diff(n,o),s=diff(n.style,o.style);if(r)for(const[t,n]of Object.entries(r))"style"!==t?"textStyles"!==t?v.has(t)?setEventHandler(e,t,n):p(e,t,n):f(e,n):u(e,n);s&&e.yogaNode&&T(e.yogaNode,s,o.style)},commitTextUpdate(e,t,n){m(e,n)},removeChild(e,t){if(l(e,t),cleanupYogaNode(t),"#text"!==t.nodeName){const n=x(e);n.focusManager.handleNodeRemoved(t,n)}},maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:{$$typeof:Symbol.for("react.context"),_currentValue:null},setCurrentUpdatePriority(e){dispatcher.currentUpdatePriority=e},resolveUpdatePriority:()=>dispatcher.resolveEventPriority(),resetFormInstance(){},requestPostPaintCallback(){},shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent(){},resolveEventType:()=>dispatcher.currentEvent?.type??null,resolveEventTimeStamp:()=>dispatcher.currentEvent?.timeStamp??-1.1});dispatcher.discreteUpdates=P.discreteUpdates.bind(P);export default P;
@@ -1 +1 @@
1
- import e from"chalk";import t from"cli-boxes";import{applyColor as o}from"./colorize.js";import{stringWidth as r}from"./stringWidth.js";export const CUSTOM_BORDER_STYLES={dashed:{top:"╌",left:"╎",right:"╎",bottom:"╌",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}};function embedTextInBorder(e,t,o,l=0,s){const d=r(t),i=e.length;if(d>=i-2)return["",t.substring(0,i),""];let b;b="center"===o?Math.floor((i-d)/2):"start"===o?l+1:i-d-l-1,b=Math.max(1,Math.min(b,i-d-1));return[e.substring(0,1)+s.repeat(b-1),t,s.repeat(i-b-d-1)+e.substring(i-1)]}function styleBorderLine(t,r,l){let s=o(t,r);return l&&(s=e.dim(s)),s}export default(r,l,s,d)=>{if(s.style.borderStyle){const i=Math.floor(s.yogaNode.getComputedWidth()),b=Math.floor(s.yogaNode.getComputedHeight()),y="string"==typeof s.style.borderStyle?CUSTOM_BORDER_STYLES[s.style.borderStyle]??t[s.style.borderStyle]:s.style.borderStyle,n=s.style.borderTopColor??s.style.borderColor,m=s.style.borderBottomColor??s.style.borderColor,f=s.style.borderLeftColor??s.style.borderColor,p=s.style.borderRightColor??s.style.borderColor,a=s.style.borderTopDimColor??s.style.borderDimColor,g=s.style.borderBottomDimColor??s.style.borderDimColor,h=s.style.borderLeftDimColor??s.style.borderDimColor,C=s.style.borderRightDimColor??s.style.borderDimColor,T=!1!==s.style.borderTop,x=!1!==s.style.borderBottom,L=!1!==s.style.borderLeft,c=!1!==s.style.borderRight,B=Math.max(0,i-(L?1:0)-(c?1:0)),u=T?(L?y.topLeft:"")+y.top.repeat(B)+(c?y.topRight:""):"";let R;if(T&&"top"===s.style.borderText?.position){const[e,t,o]=embedTextInBorder(u,s.style.borderText.content,s.style.borderText.align,s.style.borderText.offset,y.top);R=styleBorderLine(e,n,a)+t+styleBorderLine(o,n,a)}else T&&(R=styleBorderLine(u,n,a));let S=b;T&&(S-=1),x&&(S-=1),S=Math.max(0,S);let D=(o(y.left,f)+"\n").repeat(S);h&&(D=e.dim(D));let M=(o(y.right,p)+"\n").repeat(S);C&&(M=e.dim(M));const w=x?(L?y.bottomLeft:"")+y.bottom.repeat(B)+(c?y.bottomRight:""):"";let E;if(x&&"bottom"===s.style.borderText?.position){const[e,t,o]=embedTextInBorder(w,s.style.borderText.content,s.style.borderText.align,s.style.borderText.offset,y.bottom);E=styleBorderLine(e,m,g)+t+styleBorderLine(o,m,g)}else x&&(E=styleBorderLine(w,m,g));const O=T?1:0;R&&d.write(r,l,R),L&&d.write(r,l+O,D),c&&d.write(r+i-1,l+O,M),E&&d.write(r,l+b-1,E)}};
1
+ import t from"chalk";import e from"cli-boxes";import{applyColor as o}from"./colorize.js";import{stringWidth as r}from"./stringWidth.js";export const CUSTOM_BORDER_STYLES={dashed:{top:"╌",left:"╎",right:"╎",bottom:"╌",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}};function embedTextInBorder(t,e,o,l=0,s){const i=r(e),d=t.length;if(i>=d-2)return["",e.substring(0,d),""];let y;return y="center"===o?Math.floor((d-i)/2):"start"===o?l+1:d-i-l-1,y=Math.max(1,Math.min(y,d-i-1)),[t.substring(0,1)+s.repeat(y-1),e,s.repeat(d-y-i-1)+t.substring(d-1)]}function styleBorderLine(e,r,l){let s=o(e,r);return l&&(s=t.dim(s)),s}export default(r,l,s,i)=>{if(s.style.borderStyle){const d=Math.floor(s.yogaNode.getComputedWidth()),y=Math.floor(s.yogaNode.getComputedHeight()),b="string"==typeof s.style.borderStyle?CUSTOM_BORDER_STYLES[s.style.borderStyle]??e[s.style.borderStyle]:s.style.borderStyle,n=s.style.borderTopColor??s.style.borderColor,m=s.style.borderBottomColor??s.style.borderColor,p=s.style.borderLeftColor??s.style.borderColor,f=s.style.borderRightColor??s.style.borderColor,a=s.style.borderTopDimColor??s.style.borderDimColor,g=s.style.borderBottomDimColor??s.style.borderDimColor,h=s.style.borderLeftDimColor??s.style.borderDimColor,C=s.style.borderRightDimColor??s.style.borderDimColor,T=!1!==s.style.borderTop,x=!1!==s.style.borderBottom,L=!1!==s.style.borderLeft,c=!1!==s.style.borderRight,B=Math.max(0,d-(L?1:0)-(c?1:0)),u=T?(L?b.topLeft:"")+b.top.repeat(B)+(c?b.topRight:""):"";let R;if(T&&"top"===s.style.borderText?.position){const[t,e,o]=embedTextInBorder(u,s.style.borderText.content,s.style.borderText.align,s.style.borderText.offset,b.top);R=styleBorderLine(t,n,a)+e+styleBorderLine(o,n,a)}else T&&(R=styleBorderLine(u,n,a));let S=y;T&&(S-=1),x&&(S-=1),S=Math.max(0,S);let D=(o(b.left,p)+"\n").repeat(S);h&&(D=t.dim(D));let M=(o(b.right,f)+"\n").repeat(S);C&&(M=t.dim(M));const w=x?(L?b.bottomLeft:"")+b.bottom.repeat(B)+(c?b.bottomRight:""):"";let E;if(x&&"bottom"===s.style.borderText?.position){const[t,e,o]=embedTextInBorder(w,s.style.borderText.content,s.style.borderText.align,s.style.borderText.offset,b.bottom);E=styleBorderLine(t,m,g)+e+styleBorderLine(o,m,g)}else x&&(E=styleBorderLine(w,m,g));const O=T?1:0;R&&i.write(r,l,R),L&&i.write(r,l+O,D),c&&i.write(r+d-1,l+O,M),E&&i.write(r,l+y-1,E)}};
@@ -1 +1 @@
1
- import t from"indent-string";import{applyTextStyles as o}from"./colorize.js";import e from"./get-max-width.js";import{LayoutDisplay as r,LayoutEdge as l}from"./layout/node.js";import{nodeCache as n,pendingClears as i}from"./node-cache.js";import s from"./render-border.js";import{squashTextNodesToSegments as d}from"./squash-text-nodes.js";import{isXtermJs as c}from"./terminal.js";import{widestLine as h}from"./widest-line.js";import a from"./wrap-text.js";let p=!1;export function resetLayoutShifted(){p=!1}export function didLayoutShift(){return p}let f=null,u=[],g=[];export function resetScrollHint(){f=null,u=g,g=[]}export function getScrollHint(){return f}let y=null;export function resetScrollDrainNode(){y=null}export function getScrollDrainNode(){return y}let m=null;export function consumeFollowScroll(){const t=m;return m=null,t}function wrapWithOsc8Link(t,o){return`]8;;${o}${t}]8;;`}function buildCharToSegmentMap(t){const o=[];for(let e=0;e<t.length;e++){const r=t[e].text.length;for(let t=0;t<r;t++)o.push(e)}return o}function applyStylesToWrappedText(t,e,r,l,n=!1){const i=t.split("\n"),s=[];let d=0;for(let t=0;t<i.length;t++){const c=i[t];if(n&&c.length>0){const t=/\s/.test(c[0]);if(d<l.length&&/\s/.test(l[d])&&!t)for(;d<l.length&&/\s/.test(l[d]);)d++}let h="",a=0,p=r[d]??0;for(let t=0;t<c.length;t++){const l=r[d]??p;if(l!==p){const r=c.slice(a,t),n=e[p];if(n){let t=o(r,n.styles);n.hyperlink&&(t=wrapWithOsc8Link(t,n.hyperlink)),h+=t}else h+=r;a=t,p=l}d++}const f=c.slice(a),u=e[p];if(u){let t=o(f,u.styles);u.hyperlink&&(t=wrapWithOsc8Link(t,u.hyperlink)),h+=t}else h+=f;if(s.push(h),d<l.length&&"\n"===l[d]&&d++,n&&t<i.length-1){const o=i[t+1],e=o.length>0?o[0]:null;for(;d<l.length&&/\s/.test(l[d])&&(null===e||l[d]!==e);)d++}}return s.join("\n")}function wrapWithSoftWrap(t,o,e){if("wrap"!==e&&"wrap-trim"!==e)return{wrapped:a(t,o,e),softWrap:void 0};const r=t.split("\n"),l=[],n=[];for(const t of r){const r=a(t,o,e).split("\n");for(let t=0;t<r.length;t++)l.push(r[t]),n.push(t>0)}return{wrapped:l.join("\n"),softWrap:n}}function renderNodeToOutput(a,M,{offsetX:x=0,offsetY:w=0,prevScreen:C,skipSelfBlit:v=!1,inheritedBackgroundColor:S}){const{yogaNode:T}=a;if(T){if(T.getDisplay()===r.None){if(a.dirty){const t=n.get(a);t&&(M.clear({x:Math.floor(t.x),y:Math.floor(t.y),width:Math.floor(t.width),height:Math.floor(t.height)}),dropSubtreeCache(a),p=!0)}return}const b=x+T.getComputedLeft(),N=T.getComputedTop();let k=w+N;const W=T.getComputedWidth(),B=T.getComputedHeight();k<0&&"absolute"===a.style.position&&(k=0);const D=n.get(a);if(!a.dirty&&!v&&void 0===a.pendingScrollDelta&&D&&D.x===b&&D.y===k&&D.width===W&&D.height===B&&C){const t=Math.floor(b),o=Math.floor(k),e=Math.floor(W),r=Math.floor(B);return M.blit(C,t,o,e,r),"absolute"===a.style.position&&g.push(D),void blitEscapingAbsoluteDescendants(a,M,C,t,o,e,r)}const j=void 0!==D&&(D.x!==b||D.y!==k||D.width!==W||D.height!==B);j&&(p=!0),D&&(a.dirty||j)&&M.clear({x:Math.floor(D.x),y:Math.floor(D.y),width:Math.floor(D.width),height:Math.floor(D.height)},"absolute"===a.style.position);const A=i.get(a),H=void 0!==A;if(H){p=!0;for(const t of A)M.clear({x:Math.floor(t.x),y:Math.floor(t.y),width:Math.floor(t.width),height:Math.floor(t.height)});i.delete(a)}if(0===B&&function(t,o){const e=t.parentNode;if(!e)return!1;const r=o.getComputedTop(),l=e.childNodes,n=l.indexOf(t);for(let t=n+1;t<l.length;t++){const o=l[t].yogaNode;if(o)return o.getComputedTop()===r}for(let t=n-1;t>=0;t--){const o=l[t].yogaNode;if(o)return o.getComputedTop()===r}return!1}(a,T))return n.set(a,{x:b,y:k,width:W,height:B,top:N}),void(a.dirty=!1);if("ink-raw-ansi"===a.nodeName){const t=a.attributes.rawText;t&&M.write(b,k,t)}else if("ink-text"===a.nodeName){const r=d(a,S?{backgroundColor:S}:void 0),l=r.map(t=>t.text).join("");if(l.length>0){const n=Math.min(e(T),M.width-b),i=a.style.textWrap??"wrap",s=h(l)>n;let d,c;if(s&&1===r.length){const t=r[0],e=wrapWithSoftWrap(l,n,i);c=e.softWrap,d=e.wrapped.split("\n").map(e=>{let r=o(e,t.styles);return t.hyperlink&&(r=wrapWithOsc8Link(r,t.hyperlink)),r}).join("\n")}else if(s){const t=wrapWithSoftWrap(l,n,i);c=t.softWrap;const o=buildCharToSegmentMap(r);d=applyStylesToWrappedText(t.wrapped,r,o,l,"wrap-trim"===i)}else d=r.map(t=>{let e=o(t.text,t.styles);return t.hyperlink&&(e=wrapWithOsc8Link(e,t.hyperlink)),e}).join("");d=function(o,e,r){const l=o.childNodes[0]?.yogaNode;if(l){const o=l.getComputedLeft(),n=l.getComputedTop();e="\n".repeat(n)+t(e,o),r&&n>0&&r.unshift(...Array(n).fill(!1))}return e}(a,d,c),M.write(b,k,d,c)}}else if("ink-box"===a.nodeName){const t=a.style.backgroundColor??S;if(a.style.noSelect){const t=Math.floor(b),o="from-left-edge"===a.style.noSelect;M.noSelect({x:o?0:t,y:Math.floor(k),width:o?t+Math.floor(W):Math.floor(W),height:Math.floor(B)})}const e=a.style.overflowX??a.style.overflow,r=a.style.overflowY??a.style.overflow,i="hidden"===e||"scroll"===e,d="hidden"===r||"scroll"===r,h="scroll"===r,g=i||d;let x,w;if(g){const t=i?b+T.getComputedBorder(l.Left):void 0,o=i?b+T.getComputedWidth()-T.getComputedBorder(l.Right):void 0;x=d?k+T.getComputedBorder(l.Top):void 0,w=d?k+T.getComputedHeight()-T.getComputedBorder(l.Bottom):void 0,M.clip({x1:t,x2:o,y1:x,y2:w})}if(h){const o=T.getComputedPadding(l.Top),e=Math.max(0,(w??k+B)-(x??k)-o-T.getComputedPadding(l.Bottom)),r=a.childNodes.find(t=>t.yogaNode),i=r?.yogaNode,s=i?.getComputedHeight()??0,d=a.scrollHeight??s,h=a.scrollViewportHeight??e;a.scrollHeight=s,a.scrollViewportHeight=e,a.scrollViewportTop=(x??k)+o;const g=Math.max(0,s-e);if(a.scrollAnchor){const t=a.scrollAnchor.el.yogaNode?.getComputedTop();null!=t&&(a.scrollTop=t+a.scrollAnchor.offset,a.pendingScrollDelta=void 0),a.scrollAnchor=void 0}const v=a.scrollTop??0,S=a.stickyScroll??Boolean(a.attributes.stickyScroll),N=Math.max(0,d-h);(S||s>=d&&v>=N)&&(a.pendingScrollDelta??0)>=0&&(a.scrollTop=g,a.pendingScrollDelta=void 0,!1===a.stickyScroll&&v>=N&&(a.stickyScroll=!0));const A=(a.scrollTop??0)-v;if(A>0){const t=a.scrollViewportTop??0;m={delta:A,viewportTop:t,viewportBottom:t+e-1}}let L=a.scrollTop??0;const O=a.pendingScrollDelta,X=a.scrollClampMin,Y=a.scrollClampMax,R=void 0!==X&&void 0!==Y;if(void 0!==O&&0!==O){const t=R&&(O<0&&L<X||O>0&&L>Y)?Math.min(4,e>>3):e;L+="vscode"===process.env.TERM_PROGRAM||c()?function(t,o,e){const r=o>0?1:-1;let l=Math.abs(o),n=0;l>30&&(n+=r*(l-30),l=30);const i=l<=5?l:l<12?2:3;n+=r*i;const s=l-i,d=Math.max(1,e-1),c=Math.abs(n);if(c>d){const o=c-d;return t.pendingScrollDelta=r*(s+o),r*d}return t.pendingScrollDelta=s>0?r*s:void 0,n}(a,O,t):function(t,o,e){const r=Math.abs(o),l=Math.max(1,e-1),n=Math.min(l,Math.max(4,3*r>>2));if(r<=n)return t.pendingScrollDelta=void 0,o;const i=o>0?n:-n;return t.pendingScrollDelta=o-i,i}(a,O,t)}else 0===O&&(a.pendingScrollDelta=void 0);let q=Math.max(0,Math.min(L,g));const E=R?Math.max(X,Math.min(q,Y)):q;if(a.scrollTop=q,q!==L&&(a.pendingScrollDelta=void 0),void 0!==a.pendingScrollDelta&&(y=a),q=E,r&&i){const l=b+i.getComputedLeft(),s=k+i.getComputedTop()-q,d=n.get(r);let c=null;if(d&&d.y!==s){const t=d.y-s,o=Math.floor(k+i.getComputedTop()),r=o+e-1;D?.y===k&&D.height===B&&e>0&&Math.abs(t)<e?(c={top:o,bottom:r,delta:t},f=c):p=!0}const h=i.getComputedHeight(),a=h-(d?.height??h),g=!c||0===a||c.delta>0&&a===c.delta;if(g||(f=null),c&&C&&g){const{top:i,bottom:d,delta:h}=c,a=Math.floor(W);M.blit(C,Math.floor(b),i,a,d-i+1),M.shift(i,d,h);const p=h>0?d-h+1:i,f=h>0?d:i-h-1;M.clear({x:Math.floor(b),y:p,width:a,height:f-p+1}),M.clip({x1:void 0,x2:void 0,y1:p,y2:f+1});const g=r.dirty?new Set(r.childNodes.filter(t=>t.dirty)):null;if(renderScrolledChildren(r,M,l,s,H,void 0,p-s,f+1-s,t,!0),M.unclip(),g){const i=p-s,d=f+1-s,c=" ".repeat(a);let u=0;for(const a of r.childNodes){const r=a,p=g.has(a);if(!p&&0===u&&n.has(r))continue;const f=r.yogaNode;if(!f)continue;const y=f.getComputedTop(),m=f.getComputedHeight(),w=y+m;if(p){const t=n.get(r);u+=m-(t?t.height:0)}if(w<=q||y>=q+e)continue;if(y>=i&&w<=d)continue;const C=Math.floor(s+y);if(!p){const t=n.get(r);if(t&&Math.floor(t.y)-h===C)continue}const v=Math.min(Math.floor(s+w),Math.floor((x??k)+o+e));if(C<v){const o=Array(v-C).fill(c).join("\n");M.write(Math.floor(b),C,o),M.clip({x1:void 0,x2:void 0,y1:C,y2:v}),renderNodeToOutput(r,M,{offsetX:l,offsetY:s,prevScreen:void 0,inheritedBackgroundColor:t}),M.unclip()}}}const y=u.length?" ".repeat(a):"";for(const o of u){if(o.y>=d+1||o.y+o.height<=i)continue;const e=Math.max(i,Math.floor(o.y)-h),n=Math.min(d+1,Math.floor(o.y+o.height)-h);if(e>=p&&n<=f+1)continue;if(e>=n)continue;const c=Array(n-e).fill(y).join("\n");M.write(Math.floor(b),e,c),M.clip({x1:void 0,x2:void 0,y1:e,y2:n}),renderScrolledChildren(r,M,l,s,H,void 0,e-s,n-s,t,!0),M.unclip()}}else{const o=d&&d.y!==s;o&&void 0!==x&&void 0!==w&&M.clear({x:Math.floor(b),y:Math.floor(x),width:Math.floor(W),height:Math.floor(w-x)}),renderScrolledChildren(r,M,l,s,H,o||j?void 0:C,q,q+e,t)}n.set(r,{x:l,y:s,width:i.getComputedWidth(),height:i.getComputedHeight()}),r.dirty=!1}}else{const e=a.style.backgroundColor;if(e||a.style.opaque){const t=T.getComputedBorder(l.Left),r=T.getComputedBorder(l.Right),n=T.getComputedBorder(l.Top),i=T.getComputedBorder(l.Bottom),s=Math.floor(W)-t-r,d=Math.floor(B)-n-i;if(s>0&&d>0){const r=" ".repeat(s),l=e?o(r,{backgroundColor:e}):r,i=Array(d).fill(l).join("\n");M.write(b+t,k+n,i)}}renderChildren(a,M,b,k,H,e||a.style.opaque?void 0:C,t)}g&&M.unclip(),s(b,k,a,M)}else"ink-root"===a.nodeName&&renderChildren(a,M,b,k,H,C,S);const L={x:b,y:k,width:W,height:B,top:N};n.set(a,L),"absolute"===a.style.position&&g.push(L),a.dirty=!1}}function renderChildren(t,o,e,r,l,n,i){let s=!1,d=!1;for(const c of t.childNodes){const t=c,h=t.dirty,a="absolute"===t.style.position;renderNodeToOutput(t,o,{offsetX:e,offsetY:r,prevScreen:l||s?void 0:n,skipSelfBlit:d&&a&&!t.style.opaque&&void 0===t.style.backgroundColor,inheritedBackgroundColor:i}),h&&!s&&(!clipsBothAxes(t)||a?s=!0:d=!0)}}function clipsBothAxes(t){const o=t.style.overflowX??t.style.overflow,e=t.style.overflowY??t.style.overflow;return!("hidden"!==o&&"scroll"!==o||"hidden"!==e&&"scroll"!==e)}function blitEscapingAbsoluteDescendants(t,o,e,r,l,i,s){const d=r+i,c=l+s;for(const h of t.childNodes){if("#text"===h.nodeName)continue;const t=h;if("absolute"===t.style.position){const i=n.get(t);if(i){g.push(i);const t=Math.floor(i.x),n=Math.floor(i.y),s=Math.floor(i.width),h=Math.floor(i.height);(t<r||n<l||t+s>d||n+h>c)&&o.blit(e,t,n,s,h)}}blitEscapingAbsoluteDescendants(t,o,e,r,l,i,s)}}function renderScrolledChildren(t,o,e,r,l,i,s,d,c,h=!1){let a=!1,p=0;for(const f of t.childNodes){const t=f,u=t.yogaNode;if(u){const o=n.get(t);let e,r;void 0===o?.top||t.dirty||0!==p?(e=u.getComputedTop(),r=u.getComputedHeight(),t.dirty&&(p+=r-(o?o.height:0)),o&&(o.top=e)):(e=o.top,r=o.height);if(e+r<=s||e>=d){h||dropSubtreeCache(t);continue}}const g=t.dirty;renderNodeToOutput(t,o,{offsetX:e,offsetY:r,prevScreen:l||a?void 0:i,inheritedBackgroundColor:c}),g&&(a=!0)}}function dropSubtreeCache(t){n.delete(t);for(const o of t.childNodes)"#text"!==o.nodeName&&dropSubtreeCache(o)}export{buildCharToSegmentMap,applyStylesToWrappedText};export default renderNodeToOutput;
1
+ import t from"indent-string";import{applyTextStyles as o}from"./colorize.js";import e from"./get-max-width.js";import{LayoutDisplay as r,LayoutEdge as l}from"./layout/node.js";import{nodeCache as n,pendingClears as i}from"./node-cache.js";import s from"./render-border.js";import{squashTextNodesToSegments as d}from"./squash-text-nodes.js";import{isXtermJs as c}from"./terminal.js";import{widestLine as a}from"./widest-line.js";import h from"./wrap-text.js";let p=!1;export function resetLayoutShifted(){p=!1}export function didLayoutShift(){return p}let f=null,u=[],g=[];export function resetScrollHint(){f=null,u=g,g=[]}export function getScrollHint(){return f}let y=null;export function resetScrollDrainNode(){y=null}export function getScrollDrainNode(){return y}let m=null;export function consumeFollowScroll(){const t=m;return m=null,t}function wrapWithOsc8Link(t,o){return`]8;;${o}${t}]8;;`}function buildCharToSegmentMap(t){const o=[];for(let e=0;e<t.length;e++){const r=t[e].text.length;for(let t=0;t<r;t++)o.push(e)}return o}function applyStylesToWrappedText(t,e,r,l,n=!1){const i=t.split("\n"),s=[];let d=0;for(let t=0;t<i.length;t++){const c=i[t];if(n&&c.length>0){const t=/\s/.test(c[0]);if(d<l.length&&/\s/.test(l[d])&&!t)for(;d<l.length&&/\s/.test(l[d]);)d++}let a="",h=0,p=r[d]??0;for(let t=0;t<c.length;t++){const l=r[d]??p;if(l!==p){const r=c.slice(h,t),n=e[p];if(n){let t=o(r,n.styles);n.hyperlink&&(t=wrapWithOsc8Link(t,n.hyperlink)),a+=t}else a+=r;h=t,p=l}d++}const f=c.slice(h),u=e[p];if(u){let t=o(f,u.styles);u.hyperlink&&(t=wrapWithOsc8Link(t,u.hyperlink)),a+=t}else a+=f;if(s.push(a),d<l.length&&"\n"===l[d]&&d++,n&&t<i.length-1){const o=i[t+1],e=o.length>0?o[0]:null;for(;d<l.length&&/\s/.test(l[d])&&(null===e||l[d]!==e);)d++}}return s.join("\n")}function wrapWithSoftWrap(t,o,e){if("wrap"!==e&&"wrap-trim"!==e)return{wrapped:h(t,o,e),softWrap:void 0};const r=t.split("\n"),l=[],n=[];for(const t of r){const r=h(t,o,e).split("\n");for(let t=0;t<r.length;t++)l.push(r[t]),n.push(t>0)}return{wrapped:l.join("\n"),softWrap:n}}function renderNodeToOutput(h,M,{offsetX:x=0,offsetY:C=0,prevScreen:w,skipSelfBlit:v=!1,inheritedBackgroundColor:S}){const{yogaNode:T}=h;if(T){if(T.getDisplay()===r.None){if(h.dirty){const t=n.get(h);t&&(M.clear({x:Math.floor(t.x),y:Math.floor(t.y),width:Math.floor(t.width),height:Math.floor(t.height)}),dropSubtreeCache(h),p=!0)}return}const b=x+T.getComputedLeft(),N=T.getComputedTop();let k=C+N;const W=T.getComputedWidth(),B=T.getComputedHeight();k<0&&"absolute"===h.style.position&&(k=0);const D=n.get(h);if(!h.dirty&&!v&&void 0===h.pendingScrollDelta&&D&&D.x===b&&D.y===k&&D.width===W&&D.height===B&&w){const t=Math.floor(b),o=Math.floor(k),e=Math.floor(W),r=Math.floor(B);return M.blit(w,t,o,e,r),"absolute"===h.style.position&&g.push(D),void blitEscapingAbsoluteDescendants(h,M,w,t,o,e,r)}const j=void 0!==D&&(D.x!==b||D.y!==k||D.width!==W||D.height!==B);j&&(p=!0),D&&(h.dirty||j)&&M.clear({x:Math.floor(D.x),y:Math.floor(D.y),width:Math.floor(D.width),height:Math.floor(D.height)},"absolute"===h.style.position);const L=i.get(h),A=void 0!==L;if(A){p=!0;for(const t of L)M.clear({x:Math.floor(t.x),y:Math.floor(t.y),width:Math.floor(t.width),height:Math.floor(t.height)});i.delete(h)}if(0===B&&function(t,o){const e=t.parentNode;if(!e)return!1;const r=o.getComputedTop(),l=e.childNodes,n=l.indexOf(t);for(let t=n+1;t<l.length;t++){const o=l[t].yogaNode;if(o)return o.getComputedTop()===r}for(let t=n-1;t>=0;t--){const o=l[t].yogaNode;if(o)return o.getComputedTop()===r}return!1}(h,T))return n.set(h,{x:b,y:k,width:W,height:B,top:N}),void(h.dirty=!1);if("ink-raw-ansi"===h.nodeName){const t=h.attributes.rawText;t&&M.write(b,k,t)}else if("ink-text"===h.nodeName){const r=d(h,S?{backgroundColor:S}:void 0),l=r.map(t=>t.text).join("");if(l.length>0){const n=Math.min(e(T),M.width-b),i=h.style.textWrap??"wrap",s=a(l)>n;let d,c;if(s&&1===r.length){const t=r[0],e=wrapWithSoftWrap(l,n,i);c=e.softWrap,d=e.wrapped.split("\n").map(e=>{let r=o(e,t.styles);return t.hyperlink&&(r=wrapWithOsc8Link(r,t.hyperlink)),r}).join("\n")}else if(s){const t=wrapWithSoftWrap(l,n,i);c=t.softWrap;const o=buildCharToSegmentMap(r);d=applyStylesToWrappedText(t.wrapped,r,o,l,"wrap-trim"===i)}else d=r.map(t=>{let e=o(t.text,t.styles);return t.hyperlink&&(e=wrapWithOsc8Link(e,t.hyperlink)),e}).join("");d=function(o,e,r){const l=o.childNodes[0]?.yogaNode;if(l){const o=l.getComputedLeft(),n=l.getComputedTop();e="\n".repeat(n)+t(e,o),r&&n>0&&r.unshift(...Array(n).fill(!1))}return e}(h,d,c),M.write(b,k,d,c)}}else if("ink-box"===h.nodeName){const t=h.style.backgroundColor??S;if(h.style.noSelect){const t=Math.floor(b),o="from-left-edge"===h.style.noSelect;M.noSelect({x:o?0:t,y:Math.floor(k),width:o?t+Math.floor(W):Math.floor(W),height:Math.floor(B)})}const e=h.style.overflowX??h.style.overflow,r=h.style.overflowY??h.style.overflow,i="hidden"===e||"scroll"===e,d="hidden"===r||"scroll"===r,a="scroll"===r,g=i||d;let x,C;if(g){const t=i?b+T.getComputedBorder(l.Left):void 0,o=i?b+T.getComputedWidth()-T.getComputedBorder(l.Right):void 0;x=d?k+T.getComputedBorder(l.Top):void 0,C=d?k+T.getComputedHeight()-T.getComputedBorder(l.Bottom):void 0,M.clip({x1:t,x2:o,y1:x,y2:C})}if(a){const o=T.getComputedPadding(l.Top),e=Math.max(0,(C??k+B)-(x??k)-o-T.getComputedPadding(l.Bottom)),r=h.childNodes.find(t=>t.yogaNode),i=r?.yogaNode,s=i?.getComputedHeight()??0,d=h.scrollHeight??s,a=h.scrollViewportHeight??e;h.scrollHeight=s,h.scrollViewportHeight=e,h.scrollViewportTop=(x??k)+o;const g=Math.max(0,s-e);if(h.scrollAnchor){const t=h.scrollAnchor.el.yogaNode?.getComputedTop();null!=t&&(h.scrollTop=t+h.scrollAnchor.offset,h.pendingScrollDelta=void 0),h.scrollAnchor=void 0}const v=h.scrollTop??0,S=h.stickyScroll??Boolean(h.attributes.stickyScroll),N=Math.max(0,d-a);(S||s>=d&&v>=N)&&(h.pendingScrollDelta??0)>=0&&(h.scrollTop=g,h.pendingScrollDelta=void 0,!1===h.stickyScroll&&v>=N&&(h.stickyScroll=!0));const L=(h.scrollTop??0)-v;if(L>0){const t=h.scrollViewportTop??0;m={delta:L,viewportTop:t,viewportBottom:t+e-1}}let H=h.scrollTop??0;const O=h.pendingScrollDelta,X=h.scrollClampMin,Y=h.scrollClampMax,q=void 0!==X&&void 0!==Y;if(void 0!==O&&0!==O){const t=q&&(O<0&&H<X||O>0&&H>Y)?Math.min(4,e>>3):e;H+="vscode"===process.env.TERM_PROGRAM||c()?function(t,o,e){const r=o>0?1:-1;let l=Math.abs(o),n=0;l>30&&(n+=r*(l-30),l=30);const i=l<=5?l:l<12?2:3;n+=r*i;const s=l-i,d=Math.max(1,e-1),c=Math.abs(n);if(c>d){const o=c-d;return t.pendingScrollDelta=r*(s+o),r*d}return t.pendingScrollDelta=s>0?r*s:void 0,n}(h,O,t):function(t,o,e){const r=Math.abs(o),l=Math.max(1,e-1),n=Math.min(l,Math.max(4,3*r>>2));if(r<=n)return t.pendingScrollDelta=void 0,o;const i=o>0?n:-n;return t.pendingScrollDelta=o-i,i}(h,O,t)}else 0===O&&(h.pendingScrollDelta=void 0);let E=Math.max(0,Math.min(H,g));const R=q?Math.max(X,Math.min(E,Y)):E;if(h.scrollTop=E,E!==H&&(h.pendingScrollDelta=void 0),void 0!==h.pendingScrollDelta&&(y=h),E=R,r&&i){const l=b+i.getComputedLeft(),s=k+i.getComputedTop()-E,d=n.get(r);let c=null;if(d&&d.y!==s){const t=d.y-s,o=Math.floor(k+i.getComputedTop()),r=o+e-1;D?.y===k&&D.height===B&&e>0&&Math.abs(t)<e?(c={top:o,bottom:r,delta:t},f=c):p=!0}const a=i.getComputedHeight(),h=a-(d?.height??a),g=!c||0===h||c.delta>0&&h===c.delta;if(g||(f=null),c&&w&&g){const{top:i,bottom:d,delta:a}=c,h=Math.floor(W);M.blit(w,Math.floor(b),i,h,d-i+1),M.shift(i,d,a);const p=a>0?d-a+1:i,f=a>0?d:i-a-1;M.clear({x:Math.floor(b),y:p,width:h,height:f-p+1}),M.clip({x1:void 0,x2:void 0,y1:p,y2:f+1});const g=r.dirty?new Set(r.childNodes.filter(t=>t.dirty)):null;if(renderScrolledChildren(r,M,l,s,A,void 0,p-s,f+1-s,t,!0),M.unclip(),g){const i=p-s,d=f+1-s,c=" ".repeat(h);let u=0;for(const h of r.childNodes){const r=h,p=g.has(h);if(!p&&0===u&&n.has(r))continue;const f=r.yogaNode;if(!f)continue;const y=f.getComputedTop(),m=f.getComputedHeight(),C=y+m;if(p){const t=n.get(r);u+=m-(t?t.height:0)}if(C<=E||y>=E+e)continue;if(y>=i&&C<=d)continue;const w=Math.floor(s+y);if(!p){const t=n.get(r);if(t&&Math.floor(t.y)-a===w)continue}const v=Math.min(Math.floor(s+C),Math.floor((x??k)+o+e));if(w<v){const o=Array(v-w).fill(c).join("\n");M.write(Math.floor(b),w,o),M.clip({x1:void 0,x2:void 0,y1:w,y2:v}),renderNodeToOutput(r,M,{offsetX:l,offsetY:s,prevScreen:void 0,inheritedBackgroundColor:t}),M.unclip()}}}const y=u.length?" ".repeat(h):"";for(const o of u){if(o.y>=d+1||o.y+o.height<=i)continue;const e=Math.max(i,Math.floor(o.y)-a),n=Math.min(d+1,Math.floor(o.y+o.height)-a);if(e>=p&&n<=f+1)continue;if(e>=n)continue;const c=Array(n-e).fill(y).join("\n");M.write(Math.floor(b),e,c),M.clip({x1:void 0,x2:void 0,y1:e,y2:n}),renderScrolledChildren(r,M,l,s,A,void 0,e-s,n-s,t,!0),M.unclip()}}else{const o=d&&d.y!==s;o&&void 0!==x&&void 0!==C&&M.clear({x:Math.floor(b),y:Math.floor(x),width:Math.floor(W),height:Math.floor(C-x)}),renderScrolledChildren(r,M,l,s,A,o||j?void 0:w,E,E+e,t)}n.set(r,{x:l,y:s,width:i.getComputedWidth(),height:i.getComputedHeight()}),r.dirty=!1}}else{const e=h.style.backgroundColor;if(e||h.style.opaque){const t=T.getComputedBorder(l.Left),r=T.getComputedBorder(l.Right),n=T.getComputedBorder(l.Top),i=T.getComputedBorder(l.Bottom),s=Math.floor(W)-t-r,d=Math.floor(B)-n-i;if(s>0&&d>0){const r=" ".repeat(s),l=e?o(r,{backgroundColor:e}):r,i=Array(d).fill(l).join("\n");M.write(b+t,k+n,i)}}renderChildren(h,M,b,k,A,e||h.style.opaque?void 0:w,t)}g&&M.unclip(),s(b,k,h,M)}else"ink-root"===h.nodeName&&renderChildren(h,M,b,k,A,w,S);const H={x:b,y:k,width:W,height:B,top:N};n.set(h,H),"absolute"===h.style.position&&g.push(H),h.dirty=!1}}function renderChildren(t,o,e,r,l,n,i){let s=!1,d=!1;for(const c of t.childNodes){const t=c,a=t.dirty,h="absolute"===t.style.position;renderNodeToOutput(t,o,{offsetX:e,offsetY:r,prevScreen:l||s?void 0:n,skipSelfBlit:d&&h&&!t.style.opaque&&void 0===t.style.backgroundColor,inheritedBackgroundColor:i}),a&&!s&&(!clipsBothAxes(t)||h?s=!0:d=!0)}}function clipsBothAxes(t){const o=t.style.overflowX??t.style.overflow,e=t.style.overflowY??t.style.overflow;return!("hidden"!==o&&"scroll"!==o||"hidden"!==e&&"scroll"!==e)}function blitEscapingAbsoluteDescendants(t,o,e,r,l,i,s){const d=r+i,c=l+s;for(const a of t.childNodes){if("#text"===a.nodeName)continue;const t=a;if("absolute"===t.style.position){const i=n.get(t);if(i){g.push(i);const t=Math.floor(i.x),n=Math.floor(i.y),s=Math.floor(i.width),a=Math.floor(i.height);(t<r||n<l||t+s>d||n+a>c)&&o.blit(e,t,n,s,a)}}blitEscapingAbsoluteDescendants(t,o,e,r,l,i,s)}}function renderScrolledChildren(t,o,e,r,l,i,s,d,c,a=!1){let h=!1,p=0;for(const f of t.childNodes){const t=f,u=t.yogaNode;if(u){const o=n.get(t);let e,r;if(void 0===o?.top||t.dirty||0!==p?(e=u.getComputedTop(),r=u.getComputedHeight(),t.dirty&&(p+=r-(o?o.height:0)),o&&(o.top=e)):(e=o.top,r=o.height),e+r<=s||e>=d){a||dropSubtreeCache(t);continue}}const g=t.dirty;renderNodeToOutput(t,o,{offsetX:e,offsetY:r,prevScreen:l||h?void 0:i,inheritedBackgroundColor:c}),g&&(h=!0)}}function dropSubtreeCache(t){n.delete(t);for(const o of t.childNodes)"#text"!==o.nodeName&&dropSubtreeCache(o)}export{buildCharToSegmentMap,applyStylesToWrappedText};export default renderNodeToOutput;
@@ -1 +1 @@
1
- import e from"lodash-es/noop.js";import{LegacyRoot as o}from"react-reconciler/constants.js";import{logForDebugging as t}from"../utils/debug.js";import{createNode as n}from"./dom.js";import{FocusManager as r}from"./focus.js";import c from"./output.js";import s from"./reconciler.js";import i,{resetLayoutShifted as l}from"./render-node-to-output.js";import{CharPool as a,cellAtIndex as f,createScreen as p,HyperlinkPool as u,StylePool as h,setCellStyleId as m}from"./screen.js";let d,g,w,y,x,j;const S={reconcile:0,yoga:0,paint:0,scan:0,calls:0};export function renderToScreen(f,m){d||(d=n("ink-root"),d.focusManager=new r(()=>!1),w=new h,y=new a,x=new u,g=s.createContainer(d,o,null,!1,null,"search-render",e,e,e,e));const C=performance.now();s.updateContainerSync(f,g,null,e),s.flushSyncWork();const $=performance.now();d.yogaNode?.setWidth(m),d.yogaNode?.calculateLayout(m);const F=Math.ceil(d.yogaNode?.getComputedHeight()??0),M=performance.now(),k=p(m,Math.max(1,F),w,y,x);j?j.reset(m,F,k):j=new c({width:m,height:F,stylePool:w,screen:k}),l(),i(d,j,{prevScreen:void 0});const v=j.get(),L=performance.now();if(s.updateContainerSync(null,g,null,e),s.flushSyncWork(),S.reconcile+=$-C,S.yoga+=M-$,S.paint+=L-M,++S.calls%20==0){const e=S.reconcile+S.yoga+S.paint+S.scan;t(`renderToScreen: ${S.calls} calls · reconcile=${S.reconcile.toFixed(1)}ms yoga=${S.yoga.toFixed(1)}ms paint=${S.paint.toFixed(1)}ms scan=${S.scan.toFixed(1)}ms · total=${e.toFixed(1)}ms · avg ${(e/S.calls).toFixed(2)}ms/call`)}return{screen:v,height:F}}export function scanPositions(e,o){const t=o.toLowerCase();if(!t)return[];const n=t.length,r=e.width,c=e.height,s=e.noSelect,i=[],l=performance.now();for(let o=0;o<c;o++){const c=o*r;let l="";const a=[],p=[];for(let o=0;o<r;o++){const t=c+o,n=f(e,t);if(2===n.width||3===n.width||1===s[t])continue;const r=n.char.toLowerCase(),i=a.length;for(let e=0;e<r.length;e++)p.push(i);l+=r,a.push(o)}let u=l.indexOf(t);for(;u>=0;){const e=p[u],r=p[u+n-1],c=a[e],s=a[r]+1;i.push({row:o,col:c,len:s-c}),u=l.indexOf(t,u+n)}}return S.scan+=performance.now()-l,i}export function applyPositionedHighlight(e,o,t,n,r){if(r<0||r>=t.length)return!1;const c=t[r],s=c.row+n;if(s<0||s>=e.height)return!1;const transform=e=>o.withCurrentMatch(e),i=s*e.width;for(let o=c.col;o<c.col+c.len;o++){if(o<0||o>=e.width)continue;const t=f(e,i+o);m(e,o,s,transform(t.styleId))}return!0}
1
+ import e from"lodash-es/noop.js";import{LegacyRoot as o}from"react-reconciler/constants.js";import{logForDebugging as t}from"../utils/debug.js";import{createNode as n}from"./dom.js";import{FocusManager as r}from"./focus.js";import c from"./output.js";import s from"./reconciler.js";import a,{resetLayoutShifted as l}from"./render-node-to-output.js";import{CharPool as i,cellAtIndex as u,createScreen as d,HyperlinkPool as f,StylePool as h,setCellStyleId as p}from"./screen.js";let m,g,w,y,x,S;const j={reconcile:0,yoga:0,paint:0,scan:0,calls:0};export function renderToScreen(u,p){m||(m=n("ink-root"),m.focusManager=new r(()=>!1),w=new h,y=new i,x=new f,g=s.createContainer(m,o,null,!1,null,"search-render",e,e,e,e));const C=performance.now();s.updateContainerSync(u,g,null,e),s.flushSyncWork();const F=performance.now();m.yogaNode?.setWidth(p),m.yogaNode?.calculateLayout(p);const $=Math.ceil(m.yogaNode?.getComputedHeight()??0),P=performance.now(),L=d(p,Math.max(1,$),w,y,x);S?S.reset(p,$,L):S=new c({width:p,height:$,stylePool:w,screen:L}),l(),a(m,S,{prevScreen:void 0});const M=S.get(),k=performance.now();if(s.updateContainerSync(null,g,null,e),s.flushSyncWork(),j.reconcile+=F-C,j.yoga+=P-F,j.paint+=k-P,++j.calls%20==0){const e=j.reconcile+j.yoga+j.paint+j.scan;t(`renderToScreen: ${j.calls} calls · reconcile=${j.reconcile.toFixed(1)}ms yoga=${j.yoga.toFixed(1)}ms paint=${j.paint.toFixed(1)}ms scan=${j.scan.toFixed(1)}ms · total=${e.toFixed(1)}ms · avg ${(e/j.calls).toFixed(2)}ms/call`)}return{screen:M,height:$}}export function scanPositions(e,o){const t=o.toLowerCase();if(!t)return[];const n=t.length,r=e.width,c=e.height,s=e.noSelect,a=[],l=performance.now();for(let o=0;o<c;o++){const c=o*r;let l="";const i=[],d=[];for(let o=0;o<r;o++){const t=c+o,n=u(e,t);if(2===n.width||3===n.width||1===s[t])continue;const r=n.char.toLowerCase(),a=i.length;for(let e=0;e<r.length;e++)d.push(a);l+=r,i.push(o)}let f=l.indexOf(t);for(;f>=0;){const e=d[f],r=d[f+n-1],c=i[e],s=i[r]+1;a.push({row:o,col:c,len:s-c}),f=l.indexOf(t,f+n)}}return j.scan+=performance.now()-l,a}export function applyPositionedHighlight(e,o,t,n,r){if(r<0||r>=t.length)return!1;const c=t[r],s=c.row+n;if(s<0||s>=e.height)return!1;const transform=e=>o.withCurrentMatch(e),a=s*e.width;for(let o=c.col;o<c.col+c.len;o++){if(o<0||o>=e.width)continue;const t=u(e,a+o);p(e,o,s,transform(t.styleId))}return!0}
@@ -1 +1 @@
1
- import{logForDebugging as e}from"../utils/debug.js";import{markDirty as t}from"./dom.js";import{consumeAbsoluteRemovedFlag as o}from"./node-cache.js";import r from"./output.js";import i,{getScrollDrainNode as n,getScrollHint as l,resetLayoutShifted as s,resetScrollDrainNode as d,resetScrollHint as a}from"./render-node-to-output.js";import{createScreen as h}from"./screen.js";export default function createRenderer(c,m){let g;return u=>{const{frontFrame:p,backFrame:f,isTTY:v,terminalWidth:w,terminalRows:y}=u,N=p.screen,S=f.screen,$=S.charPool,b=S.hyperlinkPool,j=c.yogaNode?.getComputedHeight(),C=c.yogaNode?.getComputedWidth(),F=void 0===j||!Number.isFinite(j)||j<0,x=void 0===C||!Number.isFinite(C)||C<0;if(!c.yogaNode||F||x)return c.yogaNode&&(F||x)&&e(`Invalid yoga dimensions: width=${C}, height=${j}, childNodes=${c.childNodes.length}, terminalWidth=${w}, terminalRows=${y}`),{screen:h(w,0,m,$,b),viewport:{width:w,height:y},cursor:{x:0,y:0,visible:!0}};const M=Math.floor(c.yogaNode.getComputedWidth()),P=Math.floor(c.yogaNode.getComputedHeight()),R=u.altScreen?y:P;u.altScreen&&P>y&&e(`alt-screen: yoga height ${P} > terminalRows ${y} — something is rendering outside <AlternateScreen>. Overflow clipped.`,{level:"warn"});const W=S??h(M,R,m,$,b);g?g.reset(M,R,W):g=new r({width:M,height:R,stylePool:m,screen:W}),s(),a(),d();const H=o();i(c,g,{prevScreen:H||u.prevFrameContaminated?void 0:N});const k=g.get(),T=n();return T&&t(T),{scrollHint:u.altScreen?l():null,scrollDrainPending:null!==T,screen:k,viewport:{width:w,height:u.altScreen?y+1:y},cursor:{x:0,y:u.altScreen?Math.max(0,Math.min(W.height,y)-1):W.height,visible:!v||0===W.height}}}}
1
+ import{logForDebugging as e}from"src/utils/debug.js";import{markDirty as t}from"./dom.js";import{consumeAbsoluteRemovedFlag as o}from"./node-cache.js";import r from"./output.js";import i,{getScrollDrainNode as n,getScrollHint as s,resetLayoutShifted as a,resetScrollDrainNode as l,resetScrollHint as d}from"./render-node-to-output.js";import{createScreen as c}from"./screen.js";export default function createRenderer(h,g){let m;return u=>{const{frontFrame:p,backFrame:f,isTTY:y,terminalWidth:v,terminalRows:S}=u,w=p.screen,N=f.screen,b=N.charPool,F=N.hyperlinkPool,$=h.yogaNode?.getComputedHeight(),j=h.yogaNode?.getComputedWidth(),C=void 0===$||!Number.isFinite($)||$<0,D=void 0===j||!Number.isFinite(j)||j<0;if(!h.yogaNode||C||D)return h.yogaNode&&(C||D)&&e(`Invalid yoga dimensions: width=${j}, height=${$}, childNodes=${h.childNodes.length}, terminalWidth=${v}, terminalRows=${S}`),{screen:c(v,0,g,b,F),viewport:{width:v,height:S},cursor:{x:0,y:0,visible:!0}};const H=Math.floor(h.yogaNode.getComputedWidth()),R=Math.floor(h.yogaNode.getComputedHeight()),x=u.altScreen?S:R;u.altScreen&&R>S&&e(`alt-screen: yoga height ${R} > terminalRows ${S} — something is rendering outside <AlternateScreen>. Overflow clipped.`,{level:"warn"});const M=N??c(H,x,g,b,F);m?m.reset(H,x,M):m=new r({width:H,height:x,stylePool:g,screen:M}),a(),d(),l();const P=o();i(h,m,{prevScreen:P||u.prevFrameContaminated?void 0:w});const W=m.get(),k=n();return k&&t(k),{scrollHint:u.altScreen?s():null,scrollDrainPending:null!==k,screen:W,viewport:{width:v,height:u.altScreen?S+1:S},cursor:{x:0,y:u.altScreen?Math.max(0,Math.min(M.height,S)-1):M.height,visible:!y||0===M.height}}}}
@@ -1 +1 @@
1
- import{logForDebugging as t}from"../utils/debug.js";import{Stream as e}from"stream";import r from"./ink.js";import s from"./instances.js";export const renderSync=(t,e)=>{const n=getOptions(e),o={stdout:process.stdout,stdin:process.stdin,stderr:process.stderr,exitOnCtrlC:!0,patchConsole:!0,...n},i=getInstance(o.stdout,()=>new r(o));return i.render(t),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>s.delete(o.stdout)}};export default async(e,r)=>{await Promise.resolve();const s=renderSync(e,r);return t(`[render] first ink render: ${Math.round(1e3*process.uptime())}ms since process start`),s};export async function createRoot({stdout:t=process.stdout,stdin:e=process.stdin,stderr:n=process.stderr,exitOnCtrlC:o=!0,patchConsole:i=!0,onFrame:d}={}){await Promise.resolve();const c=new r({stdout:t,stdin:e,stderr:n,exitOnCtrlC:o,patchConsole:i,onFrame:d});return s.set(t,c),{render:t=>c.render(t),unmount:()=>c.unmount(),waitUntilExit:()=>c.waitUntilExit()}}const getOptions=(t={})=>t instanceof e?{stdout:t,stdin:process.stdin}:t,getInstance=(t,e)=>{let r=s.get(t);return r||(r=e(),s.set(t,r)),r};
1
+ import{logForDebugging as t}from"src/utils/debug.js";import{Stream as e}from"stream";import r from"./ink.js";import s from"./instances.js";export const renderSync=(t,e)=>{const n=getOptions(e),o={stdout:process.stdout,stdin:process.stdin,stderr:process.stderr,exitOnCtrlC:!0,patchConsole:!0,...n},i=getInstance(o.stdout,()=>new r(o));return i.render(t),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>s.delete(o.stdout)}};export default async(e,r)=>{await Promise.resolve();const s=renderSync(e,r);return t(`[render] first ink render: ${Math.round(1e3*process.uptime())}ms since process start`),s};export async function createRoot({stdout:t=process.stdout,stdin:e=process.stdin,stderr:n=process.stderr,exitOnCtrlC:o=!0,patchConsole:i=!0,onFrame:d}={}){await Promise.resolve();const c=new r({stdout:t,stdin:e,stderr:n,exitOnCtrlC:o,patchConsole:i,onFrame:d});return s.set(t,c),{render:t=>c.render(t),unmount:()=>c.unmount(),waitUntilExit:()=>c.waitUntilExit()}}const getOptions=(t={})=>t instanceof e?{stdout:t,stdin:process.stdin}:t,getInstance=(t,e)=>{let r=s.get(t);return r||(r=e(),s.set(t,r)),r};
@@ -1 +1 @@
1
- import{ansiCodesToString as t,diffAnsiCodes as e}from"@alcalzone/ansi-tokenize";import{unionRect as i}from"./layout/geometry.js";import{BEL as n,ESC as r,SEP as o}from"./termio/ansi.js";import*as h from"./warn.js";export class CharPool{strings=[" ",""];stringMap=new Map([[" ",0],["",1]]);ascii=function(){const t=new Int32Array(128);return t.fill(-1),t[32]=f,t}();intern(t){if(1===t.length){const e=t.charCodeAt(0);if(e<128){const i=this.ascii[e];if(-1!==i)return i;const n=this.strings.length;return this.strings.push(t),this.ascii[e]=n,n}}const e=this.stringMap.get(t);if(void 0!==e)return e;const i=this.strings.length;return this.strings.push(t),this.stringMap.set(t,i),i}get(t){return this.strings[t]??" "}}export class HyperlinkPool{strings=[""];stringMap=new Map;intern(t){if(!t)return 0;let e=this.stringMap.get(t);return void 0===e&&(e=this.strings.length,this.strings.push(t),this.stringMap.set(t,e)),e}get(t){return 0===t?void 0:this.strings[t]}}const s={type:"ansi",code:"",endCode:""},l={type:"ansi",code:"",endCode:""},c={type:"ansi",code:"",endCode:""},a={type:"ansi",code:"",endCode:""};export class StylePool{ids=new Map;styles=[];transitionCache=new Map;none;constructor(){this.none=this.intern([])}intern(t){const e=0===t.length?"":t.map(t=>t.code).join("\0");let i=this.ids.get(e);if(void 0===i){const n=this.styles.length;this.styles.push(0===t.length?[]:t),i=n<<1|(t.length>0&&function(t){for(const e of t)if(d.has(e.endCode))return!0;return!1}(t)?1:0),this.ids.set(e,i)}return i}get(t){return this.styles[t>>>1]??[]}transition(i,n){if(i===n)return"";const r=1048576*i+n;let o=this.transitionCache.get(r);return void 0===o&&(o=t(e(this.get(i),this.get(n))),this.transitionCache.set(r,o)),o}inverseCache=new Map;withInverse(t){let e=this.inverseCache.get(t);if(void 0===e){const i=this.get(t);e=i.some(t=>""===t.endCode)?t:this.intern([...i,s]),this.inverseCache.set(t,e)}return e}currentMatchCache=new Map;withCurrentMatch(t){let e=this.currentMatchCache.get(t);if(void 0===e){const i=this.get(t),n=i.filter(t=>""!==t.endCode&&""!==t.endCode);n.push(a),i.some(t=>""===t.endCode)||n.push(s),i.some(t=>""===t.endCode)||n.push(l),i.some(t=>""===t.endCode)||n.push(c),e=this.intern(n),this.currentMatchCache.set(t,e)}return e}selectionBgCode=null;selectionBgCache=new Map;setSelectionBg(t){this.selectionBgCode?.code!==t?.code&&(this.selectionBgCode=t,this.selectionBgCache.clear())}withSelectionBg(t){const e=this.selectionBgCode;if(null===e)return this.withInverse(t);let i=this.selectionBgCache.get(t);if(void 0===i){const n=this.get(t).filter(t=>""!==t.endCode&&""!==t.endCode);n.push(e),i=this.intern(n),this.selectionBgCache.set(t,i)}return i}}const d=new Set(["","","","",""]);const f=0;const g=17,u=32767;function packWord1(t,e,i){return t<<g|e<<2|i}export function isEmptyCellAt(t,e,i){return e<0||i<0||e>=t.width||i>=t.height||function(t,e){const i=e<<1;return 0===t.cells[i]&&0===t.cells[1|i]}(t,i*t.width+e)}export function isCellEmpty(t,e){return" "===e.char&&e.styleId===t.emptyStyleId&&0===e.width&&!e.hyperlink}export function createScreen(t,e,i,n,r){h.ifNotInteger(t,"createScreen width"),h.ifNotInteger(e,"createScreen height"),(!Number.isInteger(t)||t<0)&&(t=Math.max(0,Math.floor(t)||0)),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0));const o=t*e,s=new ArrayBuffer(o<<3);return{width:t,height:e,cells:new Int32Array(s),cells64:new BigInt64Array(s),charPool:n,hyperlinkPool:r,emptyStyleId:i.none,damage:void 0,noSelect:new Uint8Array(o),softWrap:new Int32Array(e)}}export function resetScreen(t,e,i){h.ifNotInteger(e,"resetScreen width"),h.ifNotInteger(i,"resetScreen height"),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0)),(!Number.isInteger(i)||i<0)&&(i=Math.max(0,Math.floor(i)||0));const n=e*i;if(t.cells64.length<n){const e=new ArrayBuffer(n<<3);t.cells=new Int32Array(e),t.cells64=new BigInt64Array(e),t.noSelect=new Uint8Array(n)}t.softWrap.length<i&&(t.softWrap=new Int32Array(i)),t.cells64.fill(0n,0,n),t.noSelect.fill(0,0,n),t.softWrap.fill(0,0,i),t.width=e,t.height=i,t.damage=void 0}export function migrateScreenPools(t,e,i){const n=t.charPool,r=t.hyperlinkPool;if(n===e&&r===i)return;const o=t.width*t.height,h=t.cells;for(let t=0;t<o<<1;t+=2){const o=h[t];h[t]=e.intern(n.get(o));const s=h[t+1],l=s>>>2&u;if(0!==l){const e=r.get(l),n=i.intern(e),o=s>>>g,c=3&s;h[t+1]=packWord1(o,n,c)}}t.charPool=e,t.hyperlinkPool=i}export function cellAt(t,e,i){if(!(e<0||i<0||e>=t.width||i>=t.height))return cellAtIndex(t,i*t.width+e)}export function cellAtIndex(t,e){const i=e<<1,n=t.cells[i+1],r=n>>>2&u;return{char:t.charPool.get(t.cells[i]),styleId:n>>>g,width:3&n,hyperlink:0===r?void 0:t.hyperlinkPool.get(r)}}export function visibleCellAtIndex(t,e,i,n,r){const o=n<<1,h=t[o];if(1===h)return;const s=t[o+1];if(0===h&&!(262140&s)){const t=s>>>g;if(0===t||t===r)return}const l=s>>>2&u;return{char:e.get(h),styleId:s>>>g,width:3&s,hyperlink:0===l?void 0:i.get(l)}}function cellAtCI(t,e,i){const n=1|e,r=t.cells[n];i.char=t.charPool.get(t.cells[e]),i.styleId=r>>>g,i.width=3&r;const o=r>>>2&u;i.hyperlink=0===o?void 0:t.hyperlinkPool.get(o)}export function charInCellAt(t,e,i){if(e<0||i<0||e>=t.width||i>=t.height)return;const n=i*t.width+e<<1;return t.charPool.get(t.cells[n])}export function setCellAt(t,e,i,n){if(e<0||i<0||e>=t.width||i>=t.height)return;const r=i*t.width+e<<1,o=t.cells,h=3&o[r+1];if(1===h&&1!==n.width){if(e+1<t.width){const e=r+2;2==(3&o[e+1])&&(o[e]=f,o[e+1]=packWord1(t.emptyStyleId,0,0))}}let s=-1;if(2===h&&2!==n.width&&e>0){const i=r-2;1==(3&o[i+1])&&(o[i]=f,o[i+1]=packWord1(t.emptyStyleId,0,0),s=e-1)}o[r]=function(t,e){return t.charPool.intern(e)}(t,n.char),o[r+1]=packWord1(n.styleId,function(t,e){return t.hyperlinkPool.intern(e)}(t,n.hyperlink),n.width);const l=s>=0?Math.min(e,s):e,c=t.damage;if(c){const t=c.x+c.width,n=c.y+c.height;l<c.x?(c.width+=c.x-l,c.x=l):e>=t&&(c.width=e-c.x+1),i<c.y?(c.height+=c.y-i,c.y=i):i>=n&&(c.height=i-c.y+1)}else t.damage={x:l,y:i,width:e-l+1,height:1};if(1===n.width){const i=e+1;if(i<t.width){const e=r+2;if(1==(3&o[e+1])){const n=e+2;i+1<t.width&&2==(3&o[n+1])&&(o[n]=f,o[n+1]=packWord1(t.emptyStyleId,0,0))}o[e]=1,o[e+1]=packWord1(t.emptyStyleId,0,2);const n=t.damage;n&&i>=n.x+n.width&&(n.width=i-n.x+1)}}}export function setCellStyleId(t,e,n,r){if(e<0||n<0||e>=t.width||n>=t.height)return;const o=n*t.width+e<<1,h=t.cells,s=h[o+1],l=3&s;if(2===l||3===l)return;const c=s>>>2&u;h[o+1]=packWord1(r,c,l);const a=t.damage;t.damage=a?i(a,{x:e,y:n,width:1,height:1}):{x:e,y:n,width:1,height:1}}export function blitRegion(t,e,n,r,o,h){if(n=Math.max(0,n),r=Math.max(0,r),n>=o||r>=h)return;const s=o-n,l=e.width<<1,c=t.width<<1,a=s<<1,d=e.cells,f=t.cells,g=e.noSelect,u=t.noSelect;if(t.softWrap.set(e.softWrap.subarray(r,h),r),0===n&&o===e.width&&e.width===t.width){const t=r*l,i=(h-r)*l;f.set(d.subarray(t,t+i),t);const n=r*e.width,o=(h-r)*e.width;u.set(g.subarray(n,n+o),n)}else{let i=r*l+(n<<1),o=r*c+(n<<1),p=r*e.width+n,m=r*t.width+n;for(let n=r;n<h;n++)f.set(d.subarray(i,i+a),o),u.set(g.subarray(p,p+s),m),i+=l,o+=c,p+=e.width,m+=t.width}const p={x:n,y:r,width:s,height:h-r};if(t.damage?t.damage=i(t.damage,p):t.damage=p,o<t.width){let i=r*e.width+(o-1)<<1,n=r*t.width+o<<1,s=!1;for(let e=r;e<h;e++)1==(3&d[i+1])&&(f[n]=1,f[n+1]=packWord1(t.emptyStyleId,0,2),s=!0),i+=l,n+=c;if(s&&t.damage){t.damage.x+t.damage.width===o&&(t.damage={...t.damage,width:t.damage.width+1})}}}export function clearRegion(t,e,n,r,o){const h=Math.max(0,e),s=Math.max(0,n),l=Math.min(e+r,t.width),c=Math.min(n+o,t.height);if(h>=l||s>=c)return;const a=t.cells,d=t.cells64,g=t.width,u=s*g;let p=h,m=l;if(0===h&&l===g)d.fill(0n,u,u+(c-s)*g);else{const e=g<<1,i=l-h,n=h>0,r=l<g;let o=u+h<<1,w=u+l-1<<1,y=u+h;for(let u=s;u<c;u++){if(n&&2==(3&a[o+1])){const e=o-1;1==(3&a[e])&&(a[e-1]=f,a[e]=packWord1(t.emptyStyleId,0,0),p=h-1)}if(r&&1==(3&a[w+1])){const e=w+3;2==(3&a[e])&&(a[e-1]=f,a[e]=packWord1(t.emptyStyleId,0,0),m=l+1)}d.fill(0n,y,y+i),o+=e,w+=e,y+=g}}const w={x:p,y:s,width:m-p,height:c-s};t.damage?t.damage=i(t.damage,w):t.damage=w}export function shiftRows(t,e,i,n){if(0===n||e<0||i>=t.height||e>i)return;const r=t.width,o=t.cells64,h=t.noSelect,s=t.softWrap;if(Math.abs(n)>i-e)return o.fill(0n,e*r,(i+1)*r),h.fill(0,e*r,(i+1)*r),void s.fill(0,e,i+1);n>0?(o.copyWithin(e*r,(e+n)*r,(i+1)*r),h.copyWithin(e*r,(e+n)*r,(i+1)*r),s.copyWithin(e,e+n,i+1),o.fill(0n,(i-n+1)*r,(i+1)*r),h.fill(0,(i-n+1)*r,(i+1)*r),s.fill(0,i-n+1,i+1)):(o.copyWithin((e-n)*r,e*r,(i+n+1)*r),h.copyWithin((e-n)*r,e*r,(i+n+1)*r),s.copyWithin(e-n,e,i+n+1),o.fill(0n,e*r,(e-n)*r),h.fill(0,e*r,(e-n)*r),s.fill(0,e,e-n))}const p=new RegExp(`^${r}\\]8${o}${o}([^${n}]*)${n}$`);export const OSC8_PREFIX=`${r}]8${o}`;export function extractHyperlinkFromStyles(t){for(const e of t){const t=e.code;if(t.length<5||!t.startsWith(OSC8_PREFIX))continue;const i=t.match(p);if(i)return i[1]||null}return null}export function filterOutHyperlinkStyles(t){return t.filter(t=>!t.code.startsWith(OSC8_PREFIX)||!p.test(t.code))}export function diff(t,e){const i=[];return diffEach(t,e,(t,e,n,r)=>{i.push([{x:t,y:e},n?{...n}:void 0,r?{...r}:void 0])}),i}export function diffEach(t,e,n){const r=t.width,o=e.width,h=t.height,s=e.height;let l;0===r&&0===h?l={x:0,y:0,width:o,height:s}:e.damage?(l=e.damage,t.damage&&(l=i(l,t.damage))):l=t.damage?t.damage:{x:0,y:0,width:0,height:0},h>s&&(l=i(l,{x:0,y:s,width:r,height:h-s})),r>o&&(l=i(l,{x:o,y:0,width:r-o,height:h}));const c=Math.max(h,s),a=Math.max(r,o),d=Math.min(l.y+l.height,c),f=Math.min(l.x+l.width,a);return r===o?function(t,e,i,n,r,o,h){const s=t.cells,l=e.cells,c=t.width,a=t.height,d=e.height,f=c<<1,g={char:" ",styleId:0,width:0,hyperlink:void 0},u={char:" ",styleId:0,width:0,hyperlink:void 0},p=Math.min(n,c);let m=r*c+i<<1;for(let n=r;n<o;n++){const r=n<a,o=n<d;if(r&&o){if(diffRowBoth(s,l,t,e,m,n,i,p,g,u,h))return!0}else if(r){if(diffRowRemoved(t,m,n,i,p,g,h))return!0}else if(o&&diffRowAdded(l,e,m,n,i,p,u,h))return!0;m+=f}return!1}(t,e,l.x,f,l.y,d,n):function(t,e,i,n,r,o,h){const s=t.width,l=e.width,c=t.cells,a=e.cells,d={char:" ",styleId:0,width:0,hyperlink:void 0},f={char:" ",styleId:0,width:0,hyperlink:void 0},g=s<<1,u=l<<1;let p=r*s+i<<1,m=r*l+i<<1;for(let w=r;w<o;w++){const r=w<t.height,o=w<e.height,y=r?Math.min(n,s):i,x=o?Math.min(n,l):i,I=Math.min(y,x);let C=p,M=m;for(let n=i;n<I;n++)if(c[C]!==a[M]||c[C+1]!==a[M+1]){if(cellAtCI(t,C,d),cellAtCI(e,M,f),C+=2,M+=2,h(n,w,d,f))return!0}else C+=2,M+=2;if(y>I){C=p+(I-i<<1);for(let e=I;e<y;e++)if(cellAtCI(t,C,d),C+=2,h(e,w,d,void 0))return!0}if(x>I){M=m+(I-i<<1);for(let t=I;t<x;t++)if(0!==a[M]||0!==a[1|M]){if(cellAtCI(e,M,f),M+=2,h(t,w,void 0,f))return!0}else M+=2}p+=g,m+=u}return!1}(t,e,l.x,f,l.y,d,n)}function findNextDiff(t,e,i,n){for(let r=0;r<n;r++,i+=2){const n=1|i;if(t[i]!==e[i]||t[n]!==e[n])return r}return n}function diffRowBoth(t,e,i,n,r,o,h,s,l,c,a){let d=h;for(;d<s;){const h=findNextDiff(t,e,r,s-d);if(d+=h,r+=h<<1,d>=s)break;if(cellAtCI(i,r,l),cellAtCI(n,r,c),a(d,o,l,c))return!0;d++,r+=2}return!1}function diffRowRemoved(t,e,i,n,r,o,h){for(let s=n;s<r;s++,e+=2)if(cellAtCI(t,e,o),h(s,i,o,void 0))return!0;return!1}function diffRowAdded(t,e,i,n,r,o,h,s){for(let l=r;l<o;l++,i+=2)if((0!==t[i]||0!==t[1|i])&&(cellAtCI(e,i,h),s(l,n,void 0,h)))return!0;return!1}export function markNoSelectRegion(t,e,i,n,r){const o=Math.min(e+n,t.width),h=Math.min(i+r,t.height),s=t.noSelect,l=t.width;for(let t=Math.max(0,i);t<h;t++){const i=t*l;s.fill(1,i+Math.max(0,e),i+o)}}
1
+ import{ansiCodesToString as t,diffAnsiCodes as e}from"@alcalzone/ansi-tokenize";import{unionRect as i}from"./layout/geometry.js";import{BEL as n,ESC as r,SEP as o}from"./termio/ansi.js";import*as s from"./warn.js";export class CharPool{strings=[" ",""];stringMap=new Map([[" ",0],["",1]]);ascii=function(){const t=new Int32Array(128);return t.fill(-1),t[32]=f,t}();intern(t){if(1===t.length){const e=t.charCodeAt(0);if(e<128){const i=this.ascii[e];if(-1!==i)return i;const n=this.strings.length;return this.strings.push(t),this.ascii[e]=n,n}}const e=this.stringMap.get(t);if(void 0!==e)return e;const i=this.strings.length;return this.strings.push(t),this.stringMap.set(t,i),i}get(t){return this.strings[t]??" "}}export class HyperlinkPool{strings=[""];stringMap=new Map;intern(t){if(!t)return 0;let e=this.stringMap.get(t);return void 0===e&&(e=this.strings.length,this.strings.push(t),this.stringMap.set(t,e)),e}get(t){return 0===t?void 0:this.strings[t]}}const h={type:"ansi",code:"",endCode:""},l={type:"ansi",code:"",endCode:""},c={type:"ansi",code:"",endCode:""},a={type:"ansi",code:"",endCode:""};export class StylePool{ids=new Map;styles=[];transitionCache=new Map;none;constructor(){this.none=this.intern([])}intern(t){const e=0===t.length?"":t.map(t=>t.code).join("\0");let i=this.ids.get(e);if(void 0===i){const n=this.styles.length;this.styles.push(0===t.length?[]:t),i=n<<1|(t.length>0&&function(t){for(const e of t)if(d.has(e.endCode))return!0;return!1}(t)?1:0),this.ids.set(e,i)}return i}get(t){return this.styles[t>>>1]??[]}transition(i,n){if(i===n)return"";const r=1048576*i+n;let o=this.transitionCache.get(r);return void 0===o&&(o=t(e(this.get(i),this.get(n))),this.transitionCache.set(r,o)),o}inverseCache=new Map;withInverse(t){let e=this.inverseCache.get(t);if(void 0===e){const i=this.get(t);e=i.some(t=>""===t.endCode)?t:this.intern([...i,h]),this.inverseCache.set(t,e)}return e}currentMatchCache=new Map;withCurrentMatch(t){let e=this.currentMatchCache.get(t);if(void 0===e){const i=this.get(t),n=i.filter(t=>""!==t.endCode&&""!==t.endCode);n.push(a),i.some(t=>""===t.endCode)||n.push(h),i.some(t=>""===t.endCode)||n.push(l),i.some(t=>""===t.endCode)||n.push(c),e=this.intern(n),this.currentMatchCache.set(t,e)}return e}selectionBgCode=null;selectionBgCache=new Map;setSelectionBg(t){this.selectionBgCode?.code!==t?.code&&(this.selectionBgCode=t,this.selectionBgCache.clear())}withSelectionBg(t){const e=this.selectionBgCode;if(null===e)return this.withInverse(t);let i=this.selectionBgCache.get(t);if(void 0===i){const n=this.get(t).filter(t=>""!==t.endCode&&""!==t.endCode);n.push(e),i=this.intern(n),this.selectionBgCache.set(t,i)}return i}}const d=new Set(["","","","",""]),f=0,g=17,u=32767;function packWord1(t,e,i){return t<<g|e<<2|i}export function isEmptyCellAt(t,e,i){return e<0||i<0||e>=t.width||i>=t.height||function(t,e){const i=e<<1;return 0===t.cells[i]&&0===t.cells[1|i]}(t,i*t.width+e)}export function isCellEmpty(t,e){return" "===e.char&&e.styleId===t.emptyStyleId&&0===e.width&&!e.hyperlink}export function createScreen(t,e,i,n,r){s.ifNotInteger(t,"createScreen width"),s.ifNotInteger(e,"createScreen height"),(!Number.isInteger(t)||t<0)&&(t=Math.max(0,Math.floor(t)||0)),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0));const o=t*e,h=new ArrayBuffer(o<<3);return{width:t,height:e,cells:new Int32Array(h),cells64:new BigInt64Array(h),charPool:n,hyperlinkPool:r,emptyStyleId:i.none,damage:void 0,noSelect:new Uint8Array(o),softWrap:new Int32Array(e)}}export function resetScreen(t,e,i){s.ifNotInteger(e,"resetScreen width"),s.ifNotInteger(i,"resetScreen height"),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0)),(!Number.isInteger(i)||i<0)&&(i=Math.max(0,Math.floor(i)||0));const n=e*i;if(t.cells64.length<n){const e=new ArrayBuffer(n<<3);t.cells=new Int32Array(e),t.cells64=new BigInt64Array(e),t.noSelect=new Uint8Array(n)}t.softWrap.length<i&&(t.softWrap=new Int32Array(i)),t.cells64.fill(0n,0,n),t.noSelect.fill(0,0,n),t.softWrap.fill(0,0,i),t.width=e,t.height=i,t.damage=void 0}export function migrateScreenPools(t,e,i){const n=t.charPool,r=t.hyperlinkPool;if(n===e&&r===i)return;const o=t.width*t.height,s=t.cells;for(let t=0;t<o<<1;t+=2){const o=s[t];s[t]=e.intern(n.get(o));const h=s[t+1],l=h>>>2&u;if(0!==l){const e=r.get(l),n=i.intern(e),o=h>>>g,c=3&h;s[t+1]=packWord1(o,n,c)}}t.charPool=e,t.hyperlinkPool=i}export function cellAt(t,e,i){if(!(e<0||i<0||e>=t.width||i>=t.height))return cellAtIndex(t,i*t.width+e)}export function cellAtIndex(t,e){const i=e<<1,n=t.cells[i+1],r=n>>>2&u;return{char:t.charPool.get(t.cells[i]),styleId:n>>>g,width:3&n,hyperlink:0===r?void 0:t.hyperlinkPool.get(r)}}export function visibleCellAtIndex(t,e,i,n,r){const o=n<<1,s=t[o];if(1===s)return;const h=t[o+1];if(0===s&&!(262140&h)){const t=h>>>g;if(0===t||t===r)return}const l=h>>>2&u;return{char:e.get(s),styleId:h>>>g,width:3&h,hyperlink:0===l?void 0:i.get(l)}}function cellAtCI(t,e,i){const n=1|e,r=t.cells[n];i.char=t.charPool.get(t.cells[e]),i.styleId=r>>>g,i.width=3&r;const o=r>>>2&u;i.hyperlink=0===o?void 0:t.hyperlinkPool.get(o)}export function charInCellAt(t,e,i){if(e<0||i<0||e>=t.width||i>=t.height)return;const n=i*t.width+e<<1;return t.charPool.get(t.cells[n])}export function setCellAt(t,e,i,n){if(e<0||i<0||e>=t.width||i>=t.height)return;const r=i*t.width+e<<1,o=t.cells,s=3&o[r+1];if(1===s&&1!==n.width&&e+1<t.width){const e=r+2;2==(3&o[e+1])&&(o[e]=f,o[e+1]=packWord1(t.emptyStyleId,0,0))}let h=-1;if(2===s&&2!==n.width&&e>0){const i=r-2;1==(3&o[i+1])&&(o[i]=f,o[i+1]=packWord1(t.emptyStyleId,0,0),h=e-1)}o[r]=function(t,e){return t.charPool.intern(e)}(t,n.char),o[r+1]=packWord1(n.styleId,function(t,e){return t.hyperlinkPool.intern(e)}(t,n.hyperlink),n.width);const l=h>=0?Math.min(e,h):e,c=t.damage;if(c){const t=c.x+c.width,n=c.y+c.height;l<c.x?(c.width+=c.x-l,c.x=l):e>=t&&(c.width=e-c.x+1),i<c.y?(c.height+=c.y-i,c.y=i):i>=n&&(c.height=i-c.y+1)}else t.damage={x:l,y:i,width:e-l+1,height:1};if(1===n.width){const i=e+1;if(i<t.width){const e=r+2;if(1==(3&o[e+1])){const n=e+2;i+1<t.width&&2==(3&o[n+1])&&(o[n]=f,o[n+1]=packWord1(t.emptyStyleId,0,0))}o[e]=1,o[e+1]=packWord1(t.emptyStyleId,0,2);const n=t.damage;n&&i>=n.x+n.width&&(n.width=i-n.x+1)}}}export function setCellStyleId(t,e,n,r){if(e<0||n<0||e>=t.width||n>=t.height)return;const o=n*t.width+e<<1,s=t.cells,h=s[o+1],l=3&h;if(2===l||3===l)return;const c=h>>>2&u;s[o+1]=packWord1(r,c,l);const a=t.damage;t.damage=a?i(a,{x:e,y:n,width:1,height:1}):{x:e,y:n,width:1,height:1}}export function blitRegion(t,e,n,r,o,s){if(n=Math.max(0,n),r=Math.max(0,r),n>=o||r>=s)return;const h=o-n,l=e.width<<1,c=t.width<<1,a=h<<1,d=e.cells,f=t.cells,g=e.noSelect,u=t.noSelect;if(t.softWrap.set(e.softWrap.subarray(r,s),r),0===n&&o===e.width&&e.width===t.width){const t=r*l,i=(s-r)*l;f.set(d.subarray(t,t+i),t);const n=r*e.width,o=(s-r)*e.width;u.set(g.subarray(n,n+o),n)}else{let i=r*l+(n<<1),o=r*c+(n<<1),p=r*e.width+n,m=r*t.width+n;for(let n=r;n<s;n++)f.set(d.subarray(i,i+a),o),u.set(g.subarray(p,p+h),m),i+=l,o+=c,p+=e.width,m+=t.width}const p={x:n,y:r,width:h,height:s-r};if(t.damage?t.damage=i(t.damage,p):t.damage=p,o<t.width){let i=r*e.width+(o-1)<<1,n=r*t.width+o<<1,h=!1;for(let e=r;e<s;e++)1==(3&d[i+1])&&(f[n]=1,f[n+1]=packWord1(t.emptyStyleId,0,2),h=!0),i+=l,n+=c;h&&t.damage&&t.damage.x+t.damage.width===o&&(t.damage={...t.damage,width:t.damage.width+1})}}export function clearRegion(t,e,n,r,o){const s=Math.max(0,e),h=Math.max(0,n),l=Math.min(e+r,t.width),c=Math.min(n+o,t.height);if(s>=l||h>=c)return;const a=t.cells,d=t.cells64,g=t.width,u=h*g;let p=s,m=l;if(0===s&&l===g)d.fill(0n,u,u+(c-h)*g);else{const e=g<<1,i=l-s,n=s>0,r=l<g;let o=u+s<<1,w=u+l-1<<1,y=u+s;for(let u=h;u<c;u++){if(n&&2==(3&a[o+1])){const e=o-1;1==(3&a[e])&&(a[e-1]=f,a[e]=packWord1(t.emptyStyleId,0,0),p=s-1)}if(r&&1==(3&a[w+1])){const e=w+3;2==(3&a[e])&&(a[e-1]=f,a[e]=packWord1(t.emptyStyleId,0,0),m=l+1)}d.fill(0n,y,y+i),o+=e,w+=e,y+=g}}const w={x:p,y:h,width:m-p,height:c-h};t.damage?t.damage=i(t.damage,w):t.damage=w}export function shiftRows(t,e,i,n){if(0===n||e<0||i>=t.height||e>i)return;const r=t.width,o=t.cells64,s=t.noSelect,h=t.softWrap;if(Math.abs(n)>i-e)return o.fill(0n,e*r,(i+1)*r),s.fill(0,e*r,(i+1)*r),void h.fill(0,e,i+1);n>0?(o.copyWithin(e*r,(e+n)*r,(i+1)*r),s.copyWithin(e*r,(e+n)*r,(i+1)*r),h.copyWithin(e,e+n,i+1),o.fill(0n,(i-n+1)*r,(i+1)*r),s.fill(0,(i-n+1)*r,(i+1)*r),h.fill(0,i-n+1,i+1)):(o.copyWithin((e-n)*r,e*r,(i+n+1)*r),s.copyWithin((e-n)*r,e*r,(i+n+1)*r),h.copyWithin(e-n,e,i+n+1),o.fill(0n,e*r,(e-n)*r),s.fill(0,e*r,(e-n)*r),h.fill(0,e,e-n))}const p=new RegExp(`^${r}\\]8${o}${o}([^${n}]*)${n}$`);export const OSC8_PREFIX=`${r}]8${o}`;export function extractHyperlinkFromStyles(t){for(const e of t){const t=e.code;if(t.length<5||!t.startsWith(OSC8_PREFIX))continue;const i=t.match(p);if(i)return i[1]||null}return null}export function filterOutHyperlinkStyles(t){return t.filter(t=>!t.code.startsWith(OSC8_PREFIX)||!p.test(t.code))}export function diff(t,e){const i=[];return diffEach(t,e,(t,e,n,r)=>{i.push([{x:t,y:e},n?{...n}:void 0,r?{...r}:void 0])}),i}export function diffEach(t,e,n){const r=t.width,o=e.width,s=t.height,h=e.height;let l;0===r&&0===s?l={x:0,y:0,width:o,height:h}:e.damage?(l=e.damage,t.damage&&(l=i(l,t.damage))):l=t.damage?t.damage:{x:0,y:0,width:0,height:0},s>h&&(l=i(l,{x:0,y:h,width:r,height:s-h})),r>o&&(l=i(l,{x:o,y:0,width:r-o,height:s}));const c=Math.max(s,h),a=Math.max(r,o),d=Math.min(l.y+l.height,c),f=Math.min(l.x+l.width,a);return r===o?function(t,e,i,n,r,o,s){const h=t.cells,l=e.cells,c=t.width,a=t.height,d=e.height,f=c<<1,g={char:" ",styleId:0,width:0,hyperlink:void 0},u={char:" ",styleId:0,width:0,hyperlink:void 0},p=Math.min(n,c);let m=r*c+i<<1;for(let n=r;n<o;n++){const r=n<a,o=n<d;if(r&&o){if(diffRowBoth(h,l,t,e,m,n,i,p,g,u,s))return!0}else if(r){if(diffRowRemoved(t,m,n,i,p,g,s))return!0}else if(o&&diffRowAdded(l,e,m,n,i,p,u,s))return!0;m+=f}return!1}(t,e,l.x,f,l.y,d,n):function(t,e,i,n,r,o,s){const h=t.width,l=e.width,c=t.cells,a=e.cells,d={char:" ",styleId:0,width:0,hyperlink:void 0},f={char:" ",styleId:0,width:0,hyperlink:void 0},g=h<<1,u=l<<1;let p=r*h+i<<1,m=r*l+i<<1;for(let w=r;w<o;w++){const r=w<t.height,o=w<e.height,y=r?Math.min(n,h):i,x=o?Math.min(n,l):i,C=Math.min(y,x);let I=p,M=m;for(let n=i;n<C;n++)if(c[I]!==a[M]||c[I+1]!==a[M+1]){if(cellAtCI(t,I,d),cellAtCI(e,M,f),I+=2,M+=2,s(n,w,d,f))return!0}else I+=2,M+=2;if(y>C){I=p+(C-i<<1);for(let e=C;e<y;e++)if(cellAtCI(t,I,d),I+=2,s(e,w,d,void 0))return!0}if(x>C){M=m+(C-i<<1);for(let t=C;t<x;t++)if(0!==a[M]||0!==a[1|M]){if(cellAtCI(e,M,f),M+=2,s(t,w,void 0,f))return!0}else M+=2}p+=g,m+=u}return!1}(t,e,l.x,f,l.y,d,n)}function findNextDiff(t,e,i,n){for(let r=0;r<n;r++,i+=2){const n=1|i;if(t[i]!==e[i]||t[n]!==e[n])return r}return n}function diffRowBoth(t,e,i,n,r,o,s,h,l,c,a){let d=s;for(;d<h;){const s=findNextDiff(t,e,r,h-d);if(d+=s,r+=s<<1,d>=h)break;if(cellAtCI(i,r,l),cellAtCI(n,r,c),a(d,o,l,c))return!0;d++,r+=2}return!1}function diffRowRemoved(t,e,i,n,r,o,s){for(let h=n;h<r;h++,e+=2)if(cellAtCI(t,e,o),s(h,i,o,void 0))return!0;return!1}function diffRowAdded(t,e,i,n,r,o,s,h){for(let l=r;l<o;l++,i+=2)if((0!==t[i]||0!==t[1|i])&&(cellAtCI(e,i,s),h(l,n,void 0,s)))return!0;return!1}export function markNoSelectRegion(t,e,i,n,r){const o=Math.min(e+n,t.width),s=Math.min(i+r,t.height),h=t.noSelect,l=t.width;for(let t=Math.max(0,i);t<s;t++){const i=t*l;h.fill(1,i+Math.max(0,e),i+o)}}
@@ -1 +1 @@
1
- import{cellAtIndex as t,setCellStyleId as e}from"./screen.js";export function applySearchHighlight(o,n,r){if(!n)return!1;const h=n.toLowerCase(),s=h.length,i=o.width,l=o.noSelect,c=o.height;let f=!1;for(let n=0;n<c;n++){const c=n*i;let d="";const g=[],p=[];for(let e=0;e<i;e++){const n=c+e,r=t(o,n);if(2===r.width||3===r.width||1===l[n])continue;const h=r.char.toLowerCase(),s=g.length;for(let t=0;t<h.length;t++)p.push(s);d+=h,g.push(e)}let u=d.indexOf(h);for(;u>=0;){f=!0;const i=p[u],l=p[u+s-1];for(let h=i;h<=l;h++){const s=g[h],i=t(o,c+s);e(o,s,n,r.withInverse(i.styleId))}u=d.indexOf(h,u+s)}}return f}
1
+ import{cellAtIndex as t,setCellStyleId as e}from"./screen.js";export function applySearchHighlight(n,o,l){if(!o)return!1;const r=o.toLowerCase(),s=r.length,h=n.width,c=n.noSelect,i=n.height;let f=!1;for(let o=0;o<i;o++){const i=o*h;let d="";const a=[],g=[];for(let e=0;e<h;e++){const o=i+e,l=t(n,o);if(2===l.width||3===l.width||1===c[o])continue;const r=l.char.toLowerCase(),s=a.length;for(let t=0;t<r.length;t++)g.push(s);d+=r,a.push(e)}let p=d.indexOf(r);for(;p>=0;){f=!0;const h=g[p],c=g[p+s-1];for(let r=h;r<=c;r++){const s=a[r],h=t(n,i+s);e(n,s,o,l.withInverse(h.styleId))}p=d.indexOf(r,p+s)}}return f}
@@ -1 +1 @@
1
- import{clamp as o}from"./layout/geometry.js";import{cellAt as r,cellAtIndex as n,setCellStyleId as c}from"./screen.js";export function createSelectionState(){return{anchor:null,focus:null,isDragging:!1,anchorSpan:null,scrolledOffAbove:[],scrolledOffBelow:[],scrolledOffAboveSW:[],scrolledOffBelowSW:[],lastPressHadAlt:!1}}export function startSelection(o,r,n){o.anchor={col:r,row:n},o.focus=null,o.isDragging=!0,o.anchorSpan=null,o.scrolledOffAbove=[],o.scrolledOffBelow=[],o.scrolledOffAboveSW=[],o.scrolledOffBelowSW=[],o.virtualAnchorRow=void 0,o.virtualFocusRow=void 0,o.lastPressHadAlt=!1}export function updateSelection(o,r,n){o.isDragging&&(!o.focus&&o.anchor&&o.anchor.col===r&&o.anchor.row===n||(o.focus={col:r,row:n}))}export function finishSelection(o){o.isDragging=!1}export function clearSelection(o){o.anchor=null,o.focus=null,o.isDragging=!1,o.anchorSpan=null,o.scrolledOffAbove=[],o.scrolledOffBelow=[],o.scrolledOffAboveSW=[],o.scrolledOffBelowSW=[],o.virtualAnchorRow=void 0,o.virtualFocusRow=void 0,o.lastPressHadAlt=!1}const t=/[\p{L}\p{N}_/.\-+~\\]/u;function charClass(o){return" "===o||""===o?0:t.test(o)?1:2}function wordBoundsAt(o,n,c){if(c<0||c>=o.height)return null;const t=o.width,l=o.noSelect,e=c*t;let i=n;if(i>0){const n=r(o,i,c);n&&2===n.width&&(i-=1)}if(i<0||i>=t||1===l[e+i])return null;const a=r(o,i,c);if(!a)return null;const s=charClass(a.char);let f=i;for(;f>0;){const n=f-1;if(1===l[e+n])break;const t=r(o,n,c);if(!t)break;if(2===t.width){if(0===n||1===l[e+n-1])break;const t=r(o,n-1,c);if(!t||charClass(t.char)!==s)break;f=n-1;continue}if(charClass(t.char)!==s)break;f=n}let h=i;for(;h<t-1;){const n=h+1;if(1===l[e+n])break;const t=r(o,n,c);if(!t)break;if(2!==t.width){if(charClass(t.char)!==s)break;h=n}else h=n}return{lo:f,hi:h}}function comparePoints(o,r){return o.row!==r.row?o.row<r.row?-1:1:o.col!==r.col?o.col<r.col?-1:1:0}export function selectWordAt(o,r,n,c){const t=wordBoundsAt(r,n,c);if(!t)return;const l={col:t.lo,row:c},e={col:t.hi,row:c};o.anchor=l,o.focus=e,o.isDragging=!0,o.anchorSpan={lo:l,hi:e,kind:"word"}}const l=new Set([..."<>\"'` "]);function isUrlChar(o){if(1!==o.length)return!1;const r=o.charCodeAt(0);return r>=33&&r<=126&&!l.has(o)}export function findPlainTextUrlAt(o,n,c){if(c<0||c>=o.height)return;const t=o.width,l=o.noSelect,e=c*t;let i=n;if(i>0){const n=r(o,i,c);n&&2===n.width&&(i-=1)}if(i<0||i>=t||1===l[e+i])return;const a=r(o,i,c);if(!a||!isUrlChar(a.char))return;let s=i;for(;s>0;){const n=s-1;if(1===l[e+n])break;const t=r(o,n,c);if(!t||0!==t.width||!isUrlChar(t.char))break;s=n}let f=i;for(;f<t-1;){const n=f+1;if(1===l[e+n])break;const t=r(o,n,c);if(!t||0!==t.width||!isUrlChar(t.char))break;f=n}let h="";for(let n=s;n<=f;n++)h+=r(o,n,c).char;const u=i-s,w=/(?:https?|file):\/\//g;let d=-1,p=h.length;for(let o;o=w.exec(h);){if(o.index>u){p=o.index;break}d=o.index}if(d<0)return;let S=h.slice(d,p);const v={")":"(","]":"[","}":"{"};for(;S.length>0;){const o=S.at(-1);if(".,;:!?".includes(o)){S=S.slice(0,-1);continue}const r=v[o];if(!r)break;let n=0,c=0;for(let t=0;t<S.length;t++){const l=S.charAt(t);l===r?n++:l===o&&c++}if(!(c>n))break;S=S.slice(0,-1)}return u>=d+S.length?void 0:S}export function selectLineAt(o,r,n){if(n<0||n>=r.height)return;const c={col:0,row:n},t={col:r.width-1,row:n};o.anchor=c,o.focus=t,o.isDragging=!0,o.anchorSpan={lo:c,hi:t,kind:"line"}}export function extendSelection(r,n,c,t){if(!r.isDragging||!r.anchorSpan)return;const l=r.anchorSpan;let e,i;if("word"===l.kind){const o=wordBoundsAt(n,c,t);e={col:o?o.lo:c,row:t},i={col:o?o.hi:c,row:t}}else{const r=o(t,0,n.height-1);e={col:0,row:r},i={col:n.width-1,row:r}}comparePoints(i,l.lo)<0?(r.anchor=l.hi,r.focus=e):comparePoints(e,l.hi)>0?(r.anchor=l.lo,r.focus=i):(r.anchor=l.lo,r.focus=l.hi)}export function moveFocus(o,r,n){o.focus&&(o.anchorSpan=null,o.focus={col:r,row:n},o.virtualFocusRow=void 0)}export function shiftSelection(o,r,n,c,t){if(!o.anchor||!o.focus)return;const l=(o.virtualAnchorRow??o.anchor.row)+r,e=(o.virtualFocusRow??o.focus.row)+r;if(l<n&&e<n||l>c&&e>c)return void clearSelection(o);const i=Math.min(o.virtualAnchorRow??o.anchor.row,o.virtualFocusRow??o.focus.row),a=Math.max(o.virtualAnchorRow??o.anchor.row,o.virtualFocusRow??o.focus.row),s=Math.max(0,n-i),f=Math.max(0,a-c),h=Math.max(0,n-Math.min(l,e)),u=Math.max(0,Math.max(l,e)-c);if(h<s){const r=s-h;o.scrolledOffAbove.length-=r,o.scrolledOffAboveSW.length=o.scrolledOffAbove.length}if(u<f){const r=f-u;o.scrolledOffBelow.splice(0,r),o.scrolledOffBelowSW.splice(0,r)}o.scrolledOffAbove.length>h&&(o.scrolledOffAbove=h>0?o.scrolledOffAbove.slice(-h):[],o.scrolledOffAboveSW=h>0?o.scrolledOffAboveSW.slice(-h):[]),o.scrolledOffBelow.length>u&&(o.scrolledOffBelow=o.scrolledOffBelow.slice(0,u),o.scrolledOffBelowSW=o.scrolledOffBelowSW.slice(0,u));const shift=(o,r)=>r<n?{col:0,row:n}:r>c?{col:t-1,row:c}:{col:o.col,row:r};if(o.anchor=shift(o.anchor,l),o.focus=shift(o.focus,e),o.virtualAnchorRow=l<n||l>c?l:void 0,o.virtualFocusRow=e<n||e>c?e:void 0,o.anchorSpan){const sp=o=>{const l=o.row+r;return l<n?{col:0,row:n}:l>c?{col:t-1,row:c}:{col:o.col,row:l}};o.anchorSpan={lo:sp(o.anchorSpan.lo),hi:sp(o.anchorSpan.hi),kind:o.anchorSpan.kind}}}export function shiftAnchor(r,n,c,t){if(!r.anchor)return;const l=(r.virtualAnchorRow??r.anchor.row)+n;if(r.anchor={col:r.anchor.col,row:o(l,c,t)},r.virtualAnchorRow=l<c||l>t?l:void 0,r.anchorSpan){const shift=r=>({col:r.col,row:o(r.row+n,c,t)});r.anchorSpan={lo:shift(r.anchorSpan.lo),hi:shift(r.anchorSpan.hi),kind:r.anchorSpan.kind}}}export function shiftSelectionForFollow(r,n,c,t){if(!r.anchor)return!1;const l=(r.virtualAnchorRow??r.anchor.row)+n,e=r.focus?(r.virtualFocusRow??r.focus.row)+n:void 0;if(l<c&&void 0!==e&&e<c)return clearSelection(r),!0;if(r.anchor={col:r.anchor.col,row:o(l,c,t)},r.focus&&void 0!==e&&(r.focus={col:r.focus.col,row:o(e,c,t)}),r.virtualAnchorRow=l<c||l>t?l:void 0,r.virtualFocusRow=void 0!==e&&(e<c||e>t)?e:void 0,r.anchorSpan){const shift=r=>({col:r.col,row:o(r.row+n,c,t)});r.anchorSpan={lo:shift(r.anchorSpan.lo),hi:shift(r.anchorSpan.hi),kind:r.anchorSpan.kind}}return!1}export function hasSelection(o){return null!==o.anchor&&null!==o.focus}export function selectionBounds(o){return o.anchor&&o.focus?comparePoints(o.anchor,o.focus)<=0?{start:o.anchor,end:o.focus}:{start:o.focus,end:o.anchor}:null}export function isCellSelected(o,r,n){const c=selectionBounds(o);if(!c)return!1;const{start:t,end:l}=c;return!(n<t.row||n>l.row)&&(!(n===t.row&&r<t.col)&&!(n===l.row&&r>l.col))}function extractRowText(o,n,c,t){const l=o.noSelect,e=n*o.width,i=n+1<o.height?o.softWrap[n+1]:0,a=i>0?Math.min(t,i-1):t;let s="";for(let t=c;t<=a;t++){if(1===l[e+t])continue;const c=r(o,t,n);c&&(2!==c.width&&3!==c.width&&(s+=c.char))}return i>0?s:s.replace(/\s+$/,"")}function joinRows(o,r,n){n&&o.length>0?o[o.length-1]+=r:o.push(r)}export function getSelectedText(o,r){const n=selectionBounds(o);if(!n)return"";const{start:c,end:t}=n,l=r.softWrap,e=[];for(let r=0;r<o.scrolledOffAbove.length;r++)joinRows(e,o.scrolledOffAbove[r],o.scrolledOffAboveSW[r]);for(let o=c.row;o<=t.row;o++){joinRows(e,extractRowText(r,o,o===c.row?c.col:0,o===t.row?t.col:r.width-1),l[o]>0)}for(let r=0;r<o.scrolledOffBelow.length;r++)joinRows(e,o.scrolledOffBelow[r],o.scrolledOffBelowSW[r]);return e.join("\n")}export function captureScrolledRows(o,r,n,c,t){const l=selectionBounds(o);if(!l||n>c)return;const{start:e,end:i}=l,a=Math.max(n,e.row),s=Math.min(c,i.row);if(a>s)return;const f=r.width,h=r.softWrap,u=[],w=[];for(let o=a;o<=s;o++){const n=o===e.row?e.col:0,c=o===i.row?i.col:f-1;u.push(extractRowText(r,o,n,c)),w.push(h[o]>0)}"above"===t?(o.scrolledOffAbove.push(...u),o.scrolledOffAboveSW.push(...w),o.anchor&&o.anchor.row===e.row&&a===e.row&&(o.anchor={col:0,row:o.anchor.row},o.anchorSpan&&(o.anchorSpan={kind:o.anchorSpan.kind,lo:{col:0,row:o.anchorSpan.lo.row},hi:{col:f-1,row:o.anchorSpan.hi.row}}))):(o.scrolledOffBelow.unshift(...u),o.scrolledOffBelowSW.unshift(...w),o.anchor&&o.anchor.row===i.row&&s===i.row&&(o.anchor={col:f-1,row:o.anchor.row},o.anchorSpan&&(o.anchorSpan={kind:o.anchorSpan.kind,lo:{col:0,row:o.anchorSpan.lo.row},hi:{col:f-1,row:o.anchorSpan.hi.row}})))}export function applySelectionOverlay(o,r,t){const l=selectionBounds(r);if(!l)return;const{start:e,end:i}=l,a=o.width,s=o.noSelect;for(let r=e.row;r<=i.row&&r<o.height;r++){const l=r===e.row?e.col:0,f=r===i.row?Math.min(i.col,a-1):a-1,h=r*a;for(let e=l;e<=f;e++){const l=h+e;if(1===s[l])continue;const i=n(o,l);c(o,e,r,t.withSelectionBg(i.styleId))}}}
1
+ import{clamp as o}from"./layout/geometry.js";import{cellAt as r,cellAtIndex as n,setCellStyleId as c}from"./screen.js";export function createSelectionState(){return{anchor:null,focus:null,isDragging:!1,anchorSpan:null,scrolledOffAbove:[],scrolledOffBelow:[],scrolledOffAboveSW:[],scrolledOffBelowSW:[],lastPressHadAlt:!1}}export function startSelection(o,r,n){o.anchor={col:r,row:n},o.focus=null,o.isDragging=!0,o.anchorSpan=null,o.scrolledOffAbove=[],o.scrolledOffBelow=[],o.scrolledOffAboveSW=[],o.scrolledOffBelowSW=[],o.virtualAnchorRow=void 0,o.virtualFocusRow=void 0,o.lastPressHadAlt=!1}export function updateSelection(o,r,n){o.isDragging&&(!o.focus&&o.anchor&&o.anchor.col===r&&o.anchor.row===n||(o.focus={col:r,row:n}))}export function finishSelection(o){o.isDragging=!1}export function clearSelection(o){o.anchor=null,o.focus=null,o.isDragging=!1,o.anchorSpan=null,o.scrolledOffAbove=[],o.scrolledOffBelow=[],o.scrolledOffAboveSW=[],o.scrolledOffBelowSW=[],o.virtualAnchorRow=void 0,o.virtualFocusRow=void 0,o.lastPressHadAlt=!1}const t=/[\p{L}\p{N}_/.\-+~\\]/u;function charClass(o){return" "===o||""===o?0:t.test(o)?1:2}function wordBoundsAt(o,n,c){if(c<0||c>=o.height)return null;const t=o.width,l=o.noSelect,e=c*t;let i=n;if(i>0){const n=r(o,i,c);n&&2===n.width&&(i-=1)}if(i<0||i>=t||1===l[e+i])return null;const a=r(o,i,c);if(!a)return null;const s=charClass(a.char);let f=i;for(;f>0;){const n=f-1;if(1===l[e+n])break;const t=r(o,n,c);if(!t)break;if(2===t.width){if(0===n||1===l[e+n-1])break;const t=r(o,n-1,c);if(!t||charClass(t.char)!==s)break;f=n-1;continue}if(charClass(t.char)!==s)break;f=n}let h=i;for(;h<t-1;){const n=h+1;if(1===l[e+n])break;const t=r(o,n,c);if(!t)break;if(2!==t.width){if(charClass(t.char)!==s)break;h=n}else h=n}return{lo:f,hi:h}}function comparePoints(o,r){return o.row!==r.row?o.row<r.row?-1:1:o.col!==r.col?o.col<r.col?-1:1:0}export function selectWordAt(o,r,n,c){const t=wordBoundsAt(r,n,c);if(!t)return;const l={col:t.lo,row:c},e={col:t.hi,row:c};o.anchor=l,o.focus=e,o.isDragging=!0,o.anchorSpan={lo:l,hi:e,kind:"word"}}const l=new Set([..."<>\"'` "]);function isUrlChar(o){if(1!==o.length)return!1;const r=o.charCodeAt(0);return r>=33&&r<=126&&!l.has(o)}export function findPlainTextUrlAt(o,n,c){if(c<0||c>=o.height)return;const t=o.width,l=o.noSelect,e=c*t;let i=n;if(i>0){const n=r(o,i,c);n&&2===n.width&&(i-=1)}if(i<0||i>=t||1===l[e+i])return;const a=r(o,i,c);if(!a||!isUrlChar(a.char))return;let s=i;for(;s>0;){const n=s-1;if(1===l[e+n])break;const t=r(o,n,c);if(!t||0!==t.width||!isUrlChar(t.char))break;s=n}let f=i;for(;f<t-1;){const n=f+1;if(1===l[e+n])break;const t=r(o,n,c);if(!t||0!==t.width||!isUrlChar(t.char))break;f=n}let h="";for(let n=s;n<=f;n++)h+=r(o,n,c).char;const u=i-s,w=/(?:https?|file):\/\//g;let d=-1,p=h.length;for(let o;o=w.exec(h);){if(o.index>u){p=o.index;break}d=o.index}if(d<0)return;let S=h.slice(d,p);const v={")":"(","]":"[","}":"{"};for(;S.length>0;){const o=S.at(-1);if(".,;:!?".includes(o)){S=S.slice(0,-1);continue}const r=v[o];if(!r)break;let n=0,c=0;for(let t=0;t<S.length;t++){const l=S.charAt(t);l===r?n++:l===o&&c++}if(!(c>n))break;S=S.slice(0,-1)}return u>=d+S.length?void 0:S}export function selectLineAt(o,r,n){if(n<0||n>=r.height)return;const c={col:0,row:n},t={col:r.width-1,row:n};o.anchor=c,o.focus=t,o.isDragging=!0,o.anchorSpan={lo:c,hi:t,kind:"line"}}export function extendSelection(r,n,c,t){if(!r.isDragging||!r.anchorSpan)return;const l=r.anchorSpan;let e,i;if("word"===l.kind){const o=wordBoundsAt(n,c,t);e={col:o?o.lo:c,row:t},i={col:o?o.hi:c,row:t}}else{const r=o(t,0,n.height-1);e={col:0,row:r},i={col:n.width-1,row:r}}comparePoints(i,l.lo)<0?(r.anchor=l.hi,r.focus=e):comparePoints(e,l.hi)>0?(r.anchor=l.lo,r.focus=i):(r.anchor=l.lo,r.focus=l.hi)}export function moveFocus(o,r,n){o.focus&&(o.anchorSpan=null,o.focus={col:r,row:n},o.virtualFocusRow=void 0)}export function shiftSelection(o,r,n,c,t){if(!o.anchor||!o.focus)return;const l=(o.virtualAnchorRow??o.anchor.row)+r,e=(o.virtualFocusRow??o.focus.row)+r;if(l<n&&e<n||l>c&&e>c)return void clearSelection(o);const i=Math.min(o.virtualAnchorRow??o.anchor.row,o.virtualFocusRow??o.focus.row),a=Math.max(o.virtualAnchorRow??o.anchor.row,o.virtualFocusRow??o.focus.row),s=Math.max(0,n-i),f=Math.max(0,a-c),h=Math.max(0,n-Math.min(l,e)),u=Math.max(0,Math.max(l,e)-c);if(h<s){const r=s-h;o.scrolledOffAbove.length-=r,o.scrolledOffAboveSW.length=o.scrolledOffAbove.length}if(u<f){const r=f-u;o.scrolledOffBelow.splice(0,r),o.scrolledOffBelowSW.splice(0,r)}o.scrolledOffAbove.length>h&&(o.scrolledOffAbove=h>0?o.scrolledOffAbove.slice(-h):[],o.scrolledOffAboveSW=h>0?o.scrolledOffAboveSW.slice(-h):[]),o.scrolledOffBelow.length>u&&(o.scrolledOffBelow=o.scrolledOffBelow.slice(0,u),o.scrolledOffBelowSW=o.scrolledOffBelowSW.slice(0,u));const shift=(o,r)=>r<n?{col:0,row:n}:r>c?{col:t-1,row:c}:{col:o.col,row:r};if(o.anchor=shift(o.anchor,l),o.focus=shift(o.focus,e),o.virtualAnchorRow=l<n||l>c?l:void 0,o.virtualFocusRow=e<n||e>c?e:void 0,o.anchorSpan){const sp=o=>{const l=o.row+r;return l<n?{col:0,row:n}:l>c?{col:t-1,row:c}:{col:o.col,row:l}};o.anchorSpan={lo:sp(o.anchorSpan.lo),hi:sp(o.anchorSpan.hi),kind:o.anchorSpan.kind}}}export function shiftAnchor(r,n,c,t){if(!r.anchor)return;const l=(r.virtualAnchorRow??r.anchor.row)+n;if(r.anchor={col:r.anchor.col,row:o(l,c,t)},r.virtualAnchorRow=l<c||l>t?l:void 0,r.anchorSpan){const shift=r=>({col:r.col,row:o(r.row+n,c,t)});r.anchorSpan={lo:shift(r.anchorSpan.lo),hi:shift(r.anchorSpan.hi),kind:r.anchorSpan.kind}}}export function shiftSelectionForFollow(r,n,c,t){if(!r.anchor)return!1;const l=(r.virtualAnchorRow??r.anchor.row)+n,e=r.focus?(r.virtualFocusRow??r.focus.row)+n:void 0;if(l<c&&void 0!==e&&e<c)return clearSelection(r),!0;if(r.anchor={col:r.anchor.col,row:o(l,c,t)},r.focus&&void 0!==e&&(r.focus={col:r.focus.col,row:o(e,c,t)}),r.virtualAnchorRow=l<c||l>t?l:void 0,r.virtualFocusRow=void 0!==e&&(e<c||e>t)?e:void 0,r.anchorSpan){const shift=r=>({col:r.col,row:o(r.row+n,c,t)});r.anchorSpan={lo:shift(r.anchorSpan.lo),hi:shift(r.anchorSpan.hi),kind:r.anchorSpan.kind}}return!1}export function hasSelection(o){return null!==o.anchor&&null!==o.focus}export function selectionBounds(o){return o.anchor&&o.focus?comparePoints(o.anchor,o.focus)<=0?{start:o.anchor,end:o.focus}:{start:o.focus,end:o.anchor}:null}export function isCellSelected(o,r,n){const c=selectionBounds(o);if(!c)return!1;const{start:t,end:l}=c;return!(n<t.row||n>l.row||n===t.row&&r<t.col||n===l.row&&r>l.col)}function extractRowText(o,n,c,t){const l=o.noSelect,e=n*o.width,i=n+1<o.height?o.softWrap[n+1]:0,a=i>0?Math.min(t,i-1):t;let s="";for(let t=c;t<=a;t++){if(1===l[e+t])continue;const c=r(o,t,n);c&&2!==c.width&&3!==c.width&&(s+=c.char)}return i>0?s:s.replace(/\s+$/,"")}function joinRows(o,r,n){n&&o.length>0?o[o.length-1]+=r:o.push(r)}export function getSelectedText(o,r){const n=selectionBounds(o);if(!n)return"";const{start:c,end:t}=n,l=r.softWrap,e=[];for(let r=0;r<o.scrolledOffAbove.length;r++)joinRows(e,o.scrolledOffAbove[r],o.scrolledOffAboveSW[r]);for(let o=c.row;o<=t.row;o++)joinRows(e,extractRowText(r,o,o===c.row?c.col:0,o===t.row?t.col:r.width-1),l[o]>0);for(let r=0;r<o.scrolledOffBelow.length;r++)joinRows(e,o.scrolledOffBelow[r],o.scrolledOffBelowSW[r]);return e.join("\n")}export function captureScrolledRows(o,r,n,c,t){const l=selectionBounds(o);if(!l||n>c)return;const{start:e,end:i}=l,a=Math.max(n,e.row),s=Math.min(c,i.row);if(a>s)return;const f=r.width,h=r.softWrap,u=[],w=[];for(let o=a;o<=s;o++){const n=o===e.row?e.col:0,c=o===i.row?i.col:f-1;u.push(extractRowText(r,o,n,c)),w.push(h[o]>0)}"above"===t?(o.scrolledOffAbove.push(...u),o.scrolledOffAboveSW.push(...w),o.anchor&&o.anchor.row===e.row&&a===e.row&&(o.anchor={col:0,row:o.anchor.row},o.anchorSpan&&(o.anchorSpan={kind:o.anchorSpan.kind,lo:{col:0,row:o.anchorSpan.lo.row},hi:{col:f-1,row:o.anchorSpan.hi.row}}))):(o.scrolledOffBelow.unshift(...u),o.scrolledOffBelowSW.unshift(...w),o.anchor&&o.anchor.row===i.row&&s===i.row&&(o.anchor={col:f-1,row:o.anchor.row},o.anchorSpan&&(o.anchorSpan={kind:o.anchorSpan.kind,lo:{col:0,row:o.anchorSpan.lo.row},hi:{col:f-1,row:o.anchorSpan.hi.row}})))}export function applySelectionOverlay(o,r,t){const l=selectionBounds(r);if(!l)return;const{start:e,end:i}=l,a=o.width,s=o.noSelect;for(let r=e.row;r<=i.row&&r<o.height;r++){const l=r===e.row?e.col:0,f=r===i.row?Math.min(i.col,a-1):a-1,h=r*a;for(let e=l;e<=f;e++){const l=h+e;if(1===s[l])continue;const i=n(o,l);c(o,e,r,t.withSelectionBg(i.styleId))}}}
@@ -1 +1 @@
1
- export function squashTextNodesToSegments(e,t={},o,s=[]){const n=e.textStyles?{...t,...e.textStyles}:t;for(const t of e.childNodes)if(void 0!==t)if("#text"===t.nodeName)t.nodeValue.length>0&&s.push({text:t.nodeValue,styles:n,hyperlink:o});else if("ink-text"===t.nodeName||"ink-virtual-text"===t.nodeName)squashTextNodesToSegments(t,n,o,s);else if("ink-link"===t.nodeName){squashTextNodesToSegments(t,n,t.attributes.href||o,s)}return s}function squashTextNodes(e){let t="";for(const o of e.childNodes)void 0!==o&&("#text"===o.nodeName?t+=o.nodeValue:("ink-text"===o.nodeName||"ink-virtual-text"===o.nodeName||"ink-link"===o.nodeName)&&(t+=squashTextNodes(o)));return t}export default squashTextNodes;
1
+ export function squashTextNodesToSegments(e,t={},o,n=[]){const s=e.textStyles?{...t,...e.textStyles}:t;for(const t of e.childNodes)void 0!==t&&("#text"===t.nodeName?t.nodeValue.length>0&&n.push({text:t.nodeValue,styles:s,hyperlink:o}):"ink-text"===t.nodeName||"ink-virtual-text"===t.nodeName?squashTextNodesToSegments(t,s,o,n):"ink-link"===t.nodeName&&squashTextNodesToSegments(t,s,t.attributes.href||o,n));return n}function squashTextNodes(e){let t="";for(const o of e.childNodes)void 0!==o&&("#text"===o.nodeName?t+=o.nodeValue:("ink-text"===o.nodeName||"ink-virtual-text"===o.nodeName||"ink-link"===o.nodeName)&&(t+=squashTextNodes(o)));return t}export default squashTextNodes;
@@ -1 +1 @@
1
- import t from"emoji-regex";import{eastAsianWidth as r}from"get-east-asian-width";import n from"strip-ansi";import{getGraphemeSegmenter as e}from"../utils/intl.js";const i=t();function getEmojiWidth(t){const r=t.codePointAt(0);if(r>=127462&&r<=127487){let r=0;for(const n of t)r++;return 1===r?1:2}if(2===t.length){if(65039===t.codePointAt(1)&&(r>=48&&r<=57||35===r||42===r))return 1}return 2}function isZeroWidth(t){if(t>=32&&t<127)return!1;if(t>=160&&t<768)return 173===t;if(t<=31||t>=127&&t<=159)return!0;if(t>=8203&&t<=8205||65279===t||t>=8288&&t<=8292)return!0;if(t>=65024&&t<=65039||t>=917760&&t<=917999)return!0;if(t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071)return!0;if(t>=2304&&t<=3407){const r=127&t;if(r<=3)return!0;if(r>=58&&r<=79)return!0;if(r>=81&&r<=87)return!0;if(r>=98&&r<=99)return!0}return 3633===t||t>=3636&&t<=3642||t>=3655&&t<=3662||3761===t||t>=3764&&t<=3772||t>=3784&&t<=3789||(t>=1536&&t<=1541||1757===t||1807===t||2274===t||(t>=55296&&t<=57343||t>=917504&&t<=917631))}const o="undefined"!=typeof Bun&&"function"==typeof Bun.stringWidth?Bun.stringWidth:null,f={ambiguousIsNarrow:!0};export const stringWidth=o?t=>o(t,f):function(t){if("string"!=typeof t||0===t.length)return 0;let o=!0;for(let r=0;r<t.length;r++){const n=t.charCodeAt(r);if(n>=127||27===n){o=!1;break}}if(o){let r=0;for(let n=0;n<t.length;n++){t.charCodeAt(n)>31&&r++}return r}if(t.includes("")&&0===(t=n(t)).length)return 0;if(!function(t){for(const r of t){const t=r.codePointAt(0);if(t>=127744&&t<=129791)return!0;if(t>=9728&&t<=10175)return!0;if(t>=127462&&t<=127487)return!0;if(t>=65024&&t<=65039)return!0;if(8205===t)return!0}return!1}(t)){let n=0;for(const e of t){const t=e.codePointAt(0);isZeroWidth(t)||(n+=r(t,{ambiguousAsWide:!1}))}return n}let f=0;for(const{segment:n}of e().segment(t))if(i.lastIndex=0,i.test(n))f+=getEmojiWidth(n);else for(const t of n){const n=t.codePointAt(0);if(!isZeroWidth(n)){f+=r(n,{ambiguousAsWide:!1});break}}return f};
1
+ import t from"emoji-regex";import{eastAsianWidth as r}from"get-east-asian-width";import e from"strip-ansi";import{getGraphemeSegmenter as n}from"../utils/intl.js";const i=t();function getEmojiWidth(t){const r=t.codePointAt(0);if(r>=127462&&r<=127487){let r=0;for(const e of t)r++;return 1===r?1:2}return 2===t.length&&65039===t.codePointAt(1)&&(r>=48&&r<=57||35===r||42===r)?1:2}function isZeroWidth(t){if(t>=32&&t<127)return!1;if(t>=160&&t<768)return 173===t;if(t<=31||t>=127&&t<=159)return!0;if(t>=8203&&t<=8205||65279===t||t>=8288&&t<=8292)return!0;if(t>=65024&&t<=65039||t>=917760&&t<=917999)return!0;if(t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071)return!0;if(t>=2304&&t<=3407){const r=127&t;if(r<=3)return!0;if(r>=58&&r<=79)return!0;if(r>=81&&r<=87)return!0;if(r>=98&&r<=99)return!0}return 3633===t||t>=3636&&t<=3642||t>=3655&&t<=3662||3761===t||t>=3764&&t<=3772||t>=3784&&t<=3789||t>=1536&&t<=1541||1757===t||1807===t||2274===t||t>=55296&&t<=57343||t>=917504&&t<=917631}const o="undefined"!=typeof Bun&&"function"==typeof Bun.stringWidth?Bun.stringWidth:null,f={ambiguousIsNarrow:!0};export const stringWidth=o?t=>o(t,f):function(t){if("string"!=typeof t||0===t.length)return 0;let o=!0;for(let r=0;r<t.length;r++){const e=t.charCodeAt(r);if(e>=127||27===e){o=!1;break}}if(o){let r=0;for(let e=0;e<t.length;e++)t.charCodeAt(e)>31&&r++;return r}if(t.includes("")&&0===(t=e(t)).length)return 0;if(!function(t){for(const r of t){const t=r.codePointAt(0);if(t>=127744&&t<=129791)return!0;if(t>=9728&&t<=10175)return!0;if(t>=127462&&t<=127487)return!0;if(t>=65024&&t<=65039)return!0;if(8205===t)return!0}return!1}(t)){let e=0;for(const n of t){const t=n.codePointAt(0);isZeroWidth(t)||(e+=r(t,{ambiguousAsWide:!1}))}return e}let f=0;for(const{segment:e}of n().segment(t))if(i.lastIndex=0,i.test(e))f+=getEmojiWidth(e);else for(const t of e){const e=t.codePointAt(0);if(!isZeroWidth(e)){f+=r(e,{ambiguousAsWide:!1});break}}return f};
@@ -1 +1 @@
1
- import{stringWidth as e}from"./stringWidth.js";import{createTokenizer as t}from"./termio/tokenize.js";export function expandTabs(o,n=8){if(!o.includes("\t"))return o;const s=t(),r=s.feed(o);r.push(...s.flush());let f="",i=0;for(const t of r)if("sequence"===t.type)f+=t.value;else{const o=t.value.split(/(\t|\n)/);for(const t of o)if("\t"===t){const e=n-i%n;f+=" ".repeat(e),i+=e}else"\n"===t?(f+=t,i=0):(f+=t,i+=e(t))}return f}
1
+ import{stringWidth as e}from"./stringWidth.js";import{createTokenizer as t}from"./termio/tokenize.js";export function expandTabs(s,n=8){if(!s.includes("\t"))return s;const o=t(),r=o.feed(s);r.push(...o.flush());let i="",f=0;for(const t of r)if("sequence"===t.type)i+=t.value;else{const s=t.value.split(/(\t|\n)/);for(const t of s)if("\t"===t){const e=n-f%n;i+=" ".repeat(e),f+=e}else"\n"===t?(i+=t,f=0):(i+=t,f+=e(t))}return i}
@@ -1 +1 @@
1
- import{coerce as r}from"semver";import{env as e}from"../utils/env.js";import{gte as t}from"../utils/semver.js";import{getClearTerminalSequence as s}from"./clearTerminal.js";import{cursorMove as o,cursorTo as n,eraseLines as i}from"./termio/csi.js";import{BSU as c,ESU as p,HIDE_CURSOR as u,SHOW_CURSOR as a}from"./termio/dec.js";import{link as m}from"./termio/osc.js";export function isProgressReportingAvailable(){if(!process.stdout.isTTY)return!1;if(process.env.WT_SESSION)return!1;if(process.env.ConEmuANSI||process.env.ConEmuPID||process.env.ConEmuTask)return!0;const e=r(process.env.TERM_PROGRAM_VERSION);return!!e&&("ghostty"===process.env.TERM_PROGRAM?t(e.version,"1.2.0"):"iTerm.app"===process.env.TERM_PROGRAM&&t(e.version,"3.6.6"))}export function isSynchronizedOutputSupported(){if(process.env.TMUX)return!1;const r=process.env.TERM_PROGRAM,e=process.env.TERM;if("iTerm.app"===r||"WezTerm"===r||"WarpTerminal"===r||"ghostty"===r||"contour"===r||"vscode"===r||"alacritty"===r)return!0;if(e?.includes("kitty")||process.env.KITTY_WINDOW_ID)return!0;if("xterm-ghostty"===e)return!0;if(e?.startsWith("foot"))return!0;if(e?.includes("alacritty"))return!0;if(process.env.ZED_TERM)return!0;if(process.env.WT_SESSION)return!0;const t=process.env.VTE_VERSION;if(t){if(parseInt(t,10)>=6800)return!0}return!1}let f;export function setXtversionName(r){void 0===f&&(f=r)}export function isXtermJs(){return"vscode"===process.env.TERM_PROGRAM||(f?.startsWith("xterm.js")??!1)}const T=["iTerm.app","kitty","WezTerm","ghostty","tmux","windows-terminal"];export function supportsExtendedKeys(){return T.includes(e.terminal??"")}export function hasCursorUpViewportYankBug(){return"win32"===process.platform||!!process.env.WT_SESSION}export const SYNC_OUTPUT_SUPPORTED=isSynchronizedOutputSupported();export function writeDiffToTerminal(r,e,t=!1){if(0===e.length)return;const f=!t;let T=f?c:"";for(const r of e)switch(r.type){case"stdout":T+=r.content;break;case"clear":r.count>0&&(T+=i(r.count));break;case"clearTerminal":T+=s();break;case"cursorHide":T+=u;break;case"cursorShow":T+=a;break;case"cursorMove":T+=o(r.x,r.y);break;case"cursorTo":T+=n(r.col);break;case"carriageReturn":T+="\r";break;case"hyperlink":T+=m(r.uri);break;case"styleStr":T+=r.str}f&&(T+=p),r.stdout.write(T)}
1
+ import{coerce as e}from"semver";import{env as r}from"../utils/env.js";import{gte as s}from"../utils/semver.js";import{getClearTerminalSequence as t}from"./clearTerminal.js";import{cursorMove as o,cursorTo as n,eraseLines as i}from"./termio/csi.js";import{BSU as c,ESU as a,HIDE_CURSOR as u,SHOW_CURSOR as p}from"./termio/dec.js";import{link as m}from"./termio/osc.js";export function isProgressReportingAvailable(){if(!process.stdout.isTTY)return!1;if(process.env.WT_SESSION)return!1;if(process.env.ConEmuANSI||process.env.ConEmuPID||process.env.ConEmuTask)return!0;const r=e(process.env.TERM_PROGRAM_VERSION);return!!r&&("ghostty"===process.env.TERM_PROGRAM?s(r.version,"1.2.0"):"iTerm.app"===process.env.TERM_PROGRAM&&s(r.version,"3.6.6"))}export function isSynchronizedOutputSupported(){if(process.env.TMUX)return!1;const e=process.env.TERM_PROGRAM,r=process.env.TERM;if("iTerm.app"===e||"WezTerm"===e||"WarpTerminal"===e||"ghostty"===e||"contour"===e||"vscode"===e||"alacritty"===e)return!0;if(r?.includes("kitty")||process.env.KITTY_WINDOW_ID)return!0;if("xterm-ghostty"===r)return!0;if(r?.startsWith("foot"))return!0;if(r?.includes("alacritty"))return!0;if(process.env.ZED_TERM)return!0;if(process.env.WT_SESSION)return!0;const s=process.env.VTE_VERSION;return!!(s&&parseInt(s,10)>=6800)}let T;export function setXtversionName(e){void 0===T&&(T=e)}export function isXtermJs(){return"vscode"===process.env.TERM_PROGRAM||(T?.startsWith("xterm.js")??!1)}const f=["iTerm.app","kitty","WezTerm","ghostty","tmux","windows-terminal"];export function supportsExtendedKeys(){return f.includes(r.terminal??"")}export function hasCursorUpViewportYankBug(){return"win32"===process.platform||!!process.env.WT_SESSION}export const SYNC_OUTPUT_SUPPORTED=isSynchronizedOutputSupported();export function writeDiffToTerminal(e,r,s=!1){if(0===r.length)return;const T=!s;let f=T?c:"";for(const e of r)switch(e.type){case"stdout":f+=e.content;break;case"clear":e.count>0&&(f+=i(e.count));break;case"clearTerminal":f+=t();break;case"cursorHide":f+=u;break;case"cursorShow":f+=p;break;case"cursorMove":f+=o(e.x,e.y);break;case"cursorTo":f+=n(e.col);break;case"carriageReturn":f+="\r";break;case"hyperlink":f+=m(e.uri);break;case"styleStr":f+=e.str}T&&(f+=a),e.stdout.write(f)}
@@ -1 +1 @@
1
- import{Buffer as t}from"buffer";import{env as e}from"../../utils/env.js";import{execFileNoThrow as o}from"../../utils/execFileNoThrow.js";import{BEL as r,ESC as n,ESC_TYPE as s,SEP as i}from"./ansi.js";export const OSC_PREFIX=n+String.fromCharCode(s.OSC);export const ST=n+"\\";export function osc(...t){const o="kitty"===e.terminal?ST:r;return`${OSC_PREFIX}${t.join(i)}${o}`}export function wrapForMultiplexer(t){if(process.env.TMUX){return`Ptmux;${t.replaceAll("","")}\\`}return process.env.STY?`P${t}\\`:t}export function getClipboardPath(){return"darwin"===process.platform&&!process.env.SSH_CONNECTION?"native":process.env.TMUX?"tmux-buffer":"osc52"}export async function tmuxLoadBuffer(t){if(!process.env.TMUX)return!1;const e="iTerm2"===process.env.LC_TERMINAL?["load-buffer","-"]:["load-buffer","-w","-"],{code:r}=await o("tmux",e,{input:t,useCwd:!1,timeout:2e3});return 0===r}export async function setClipboard(e){const s=t.from(e,"utf8").toString("base64"),i=osc(OSC.CLIPBOARD,"c",s);process.env.SSH_CONNECTION||function(t){const e={input:t,useCwd:!1,timeout:2e3};switch(process.platform){case"darwin":return void o("pbcopy",[],e);case"linux":if(null===c)return;return"wl-copy"===c?void o("wl-copy",[],e):"xclip"===c?void o("xclip",["-selection","clipboard"],e):"xsel"===c?void o("xsel",["--clipboard","--input"],e):void o("wl-copy",[],e).then(t=>{0!==t.code?o("xclip",["-selection","clipboard"],e).then(t=>{0!==t.code?o("xsel",["--clipboard","--input"],e).then(t=>{c=0===t.code?"xsel":null}):c="xclip"}):c="wl-copy"});case"win32":o("clip",[],e)}}(e);return await tmuxLoadBuffer(e)?`${n}Ptmux;${`${n}]52;c;${s}${r}`.replaceAll(n,n+n)}${ST}`:i}let c;export function _resetLinuxCopyCache(){c=void 0}export const OSC={SET_TITLE_AND_ICON:0,SET_ICON:1,SET_TITLE:2,SET_COLOR:4,SET_CWD:7,HYPERLINK:8,ITERM2:9,SET_FG_COLOR:10,SET_BG_COLOR:11,SET_CURSOR_COLOR:12,CLIPBOARD:52,KITTY:99,RESET_COLOR:104,RESET_FG_COLOR:110,RESET_BG_COLOR:111,RESET_CURSOR_COLOR:112,SEMANTIC_PROMPT:133,GHOSTTY:777,TAB_STATUS:21337};export function parseOSC(t){const e=t.indexOf(";"),o=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"",n=parseInt(o,10);if(n===OSC.SET_TITLE_AND_ICON)return{type:"title",action:{type:"both",title:r}};if(n===OSC.SET_ICON)return{type:"title",action:{type:"iconName",name:r}};if(n===OSC.SET_TITLE)return{type:"title",action:{type:"windowTitle",title:r}};if(n===OSC.HYPERLINK){const t=r.split(";"),e=t[0]??"",o=t.slice(1).join(";");if(""===o)return{type:"link",action:{type:"end"}};const n={};if(e)for(const t of e.split(":")){const e=t.indexOf("=");e>=0&&(n[t.slice(0,e)]=t.slice(e+1))}return{type:"link",action:{type:"start",url:o,params:Object.keys(n).length>0?n:void 0}}}return n===OSC.TAB_STATUS?{type:"tabStatus",action:parseTabStatus(r)}:{type:"unknown",sequence:`]${t}`}}export function parseOscColor(t){const e=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(e)return{type:"rgb",r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};const o=t.match(/^rgb:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})$/i);if(o){const scale=t=>Math.round(parseInt(t,16)/(16**t.length-1)*255);return{type:"rgb",r:scale(o[1]),g:scale(o[2]),b:scale(o[3])}}return null}function parseTabStatus(t){const e={};for(const[o,r]of function*(t){let e="",o="",r=!1,n=!1;for(const s of t)n?(r?o+=s:e+=s,n=!1):"\\"===s?n=!0:";"===s?(yield[e,o],e="",o="",r=!1):"="!==s||r?r?o+=s:e+=s:r=!0;(e||r)&&(yield[e,o])}(t))switch(o){case"indicator":e.indicator=""===r?null:parseOscColor(r);break;case"status":e.status=""===r?null:r;break;case"status-color":e.statusColor=""===r?null:parseOscColor(r)}return e}export function link(t,e){if(!t)return LINK_END;const o={id:osc8Id(t),...e},r=Object.entries(o).map(([t,e])=>`${t}=${e}`).join(":");return osc(OSC.HYPERLINK,r,t)}function osc8Id(t){let e=0;for(let o=0;o<t.length;o++)e=(e<<5)-e+t.charCodeAt(o)|0;return(e>>>0).toString(36)}export const LINK_END=osc(OSC.HYPERLINK,"","");export const ITERM2={NOTIFY:0,BADGE:2,PROGRESS:4};export const PROGRESS={CLEAR:0,SET:1,ERROR:2,INDETERMINATE:3};export const CLEAR_ITERM2_PROGRESS=`${OSC_PREFIX}${OSC.ITERM2};${ITERM2.PROGRESS};${PROGRESS.CLEAR};${r}`;export const CLEAR_TERMINAL_TITLE=`${OSC_PREFIX}${OSC.SET_TITLE_AND_ICON};${r}`;export const CLEAR_TAB_STATUS=osc(OSC.TAB_STATUS,"indicator=;status=;status-color=");export function supportsTabStatus(){return"ant"===process.env.USER_TYPE}export function tabStatus(t){const e=[],rgb=t=>"rgb"===t.type?`#${[t.r,t.g,t.b].map(t=>t.toString(16).padStart(2,"0")).join("")}`:"";return"indicator"in t&&e.push(`indicator=${t.indicator?rgb(t.indicator):""}`),"status"in t&&e.push(`status=${t.status?.replaceAll("\\","\\\\").replaceAll(";","\\;")??""}`),"statusColor"in t&&e.push(`status-color=${t.statusColor?rgb(t.statusColor):""}`),osc(OSC.TAB_STATUS,e.join(";"))}
1
+ import{Buffer as t}from"buffer";import{env as e}from"../../utils/env.js";import{execFileNoThrow as o}from"../../utils/execFileNoThrow.js";import{BEL as r,ESC as n,ESC_TYPE as s,SEP as i}from"./ansi.js";export const OSC_PREFIX=n+String.fromCharCode(s.OSC);export const ST=n+"\\";export function osc(...t){const o="kitty"===e.terminal?ST:r;return`${OSC_PREFIX}${t.join(i)}${o}`}export function wrapForMultiplexer(t){return process.env.TMUX?`Ptmux;${t.replaceAll("","")}\\`:process.env.STY?`P${t}\\`:t}export function getClipboardPath(){return"darwin"!==process.platform||process.env.SSH_CONNECTION?process.env.TMUX?"tmux-buffer":"osc52":"native"}export async function tmuxLoadBuffer(t){if(!process.env.TMUX)return!1;const e="iTerm2"===process.env.LC_TERMINAL?["load-buffer","-"]:["load-buffer","-w","-"],{code:r}=await o("tmux",e,{input:t,useCwd:!1,timeout:2e3});return 0===r}export async function setClipboard(e){const s=t.from(e,"utf8").toString("base64"),i=osc(OSC.CLIPBOARD,"c",s);return process.env.SSH_CONNECTION||function(t){const e={input:t,useCwd:!1,timeout:2e3};switch(process.platform){case"darwin":return void o("pbcopy",[],e);case"linux":if(null===c)return;return"wl-copy"===c?void o("wl-copy",[],e):"xclip"===c?void o("xclip",["-selection","clipboard"],e):"xsel"===c?void o("xsel",["--clipboard","--input"],e):void o("wl-copy",[],e).then(t=>{0!==t.code?o("xclip",["-selection","clipboard"],e).then(t=>{0!==t.code?o("xsel",["--clipboard","--input"],e).then(t=>{c=0===t.code?"xsel":null}):c="xclip"}):c="wl-copy"});case"win32":o("clip",[],e)}}(e),await tmuxLoadBuffer(e)?`${n}Ptmux;${`${n}]52;c;${s}${r}`.replaceAll(n,n+n)}${ST}`:i}let c;export function _resetLinuxCopyCache(){c=void 0}export const OSC={SET_TITLE_AND_ICON:0,SET_ICON:1,SET_TITLE:2,SET_COLOR:4,SET_CWD:7,HYPERLINK:8,ITERM2:9,SET_FG_COLOR:10,SET_BG_COLOR:11,SET_CURSOR_COLOR:12,CLIPBOARD:52,KITTY:99,RESET_COLOR:104,RESET_FG_COLOR:110,RESET_BG_COLOR:111,RESET_CURSOR_COLOR:112,SEMANTIC_PROMPT:133,GHOSTTY:777,TAB_STATUS:21337};export function parseOSC(t){const e=t.indexOf(";"),o=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"",n=parseInt(o,10);if(n===OSC.SET_TITLE_AND_ICON)return{type:"title",action:{type:"both",title:r}};if(n===OSC.SET_ICON)return{type:"title",action:{type:"iconName",name:r}};if(n===OSC.SET_TITLE)return{type:"title",action:{type:"windowTitle",title:r}};if(n===OSC.HYPERLINK){const t=r.split(";"),e=t[0]??"",o=t.slice(1).join(";");if(""===o)return{type:"link",action:{type:"end"}};const n={};if(e)for(const t of e.split(":")){const e=t.indexOf("=");e>=0&&(n[t.slice(0,e)]=t.slice(e+1))}return{type:"link",action:{type:"start",url:o,params:Object.keys(n).length>0?n:void 0}}}return n===OSC.TAB_STATUS?{type:"tabStatus",action:parseTabStatus(r)}:{type:"unknown",sequence:`]${t}`}}export function parseOscColor(t){const e=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(e)return{type:"rgb",r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};const o=t.match(/^rgb:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})$/i);if(o){const scale=t=>Math.round(parseInt(t,16)/(16**t.length-1)*255);return{type:"rgb",r:scale(o[1]),g:scale(o[2]),b:scale(o[3])}}return null}function parseTabStatus(t){const e={};for(const[o,r]of function*(t){let e="",o="",r=!1,n=!1;for(const s of t)n?(r?o+=s:e+=s,n=!1):"\\"===s?n=!0:";"===s?(yield[e,o],e="",o="",r=!1):"="!==s||r?r?o+=s:e+=s:r=!0;(e||r)&&(yield[e,o])}(t))switch(o){case"indicator":e.indicator=""===r?null:parseOscColor(r);break;case"status":e.status=""===r?null:r;break;case"status-color":e.statusColor=""===r?null:parseOscColor(r)}return e}export function link(t,e){if(!t)return LINK_END;const o={id:osc8Id(t),...e},r=Object.entries(o).map(([t,e])=>`${t}=${e}`).join(":");return osc(OSC.HYPERLINK,r,t)}function osc8Id(t){let e=0;for(let o=0;o<t.length;o++)e=(e<<5)-e+t.charCodeAt(o)|0;return(e>>>0).toString(36)}export const LINK_END=osc(OSC.HYPERLINK,"","");export const ITERM2={NOTIFY:0,BADGE:2,PROGRESS:4};export const PROGRESS={CLEAR:0,SET:1,ERROR:2,INDETERMINATE:3};export const CLEAR_ITERM2_PROGRESS=`${OSC_PREFIX}${OSC.ITERM2};${ITERM2.PROGRESS};${PROGRESS.CLEAR};${r}`;export const CLEAR_TERMINAL_TITLE=`${OSC_PREFIX}${OSC.SET_TITLE_AND_ICON};${r}`;export const CLEAR_TAB_STATUS=osc(OSC.TAB_STATUS,"indicator=;status=;status-color=");export function supportsTabStatus(){return"ant"===process.env.USER_TYPE}export function tabStatus(t){const e=[],rgb=t=>"rgb"===t.type?`#${[t.r,t.g,t.b].map(t=>t.toString(16).padStart(2,"0")).join("")}`:"";return"indicator"in t&&e.push(`indicator=${t.indicator?rgb(t.indicator):""}`),"status"in t&&e.push(`status=${t.status?.replaceAll("\\","\\\\").replaceAll(";","\\;")??""}`),"statusColor"in t&&e.push(`status-color=${t.statusColor?rgb(t.statusColor):""}`),osc(OSC.TAB_STATUS,e.join(";"))}
@@ -1 +1 @@
1
- import{getGraphemeSegmenter as e}from"../../utils/intl.js";import{C0 as t}from"./ansi.js";import{CSI as r,CURSOR_STYLES as n,ERASE_DISPLAY as o,ERASE_LINE_REGION as s}from"./csi.js";import{DEC as i}from"./dec.js";import{parseEsc as c}from"./esc.js";import{parseOSC as u}from"./osc.js";import{applySGR as p}from"./sgr.js";import{createTokenizer as a}from"./tokenize.js";import{defaultStyle as y}from"./types.js";function graphemeWidth(e){if(function(e){let t=0;for(const r of e)if(t++,t>1)return!0;return!1}(e))return 2;const t=e.codePointAt(0);return void 0===t?1:function(e){return e>=9728&&e<=9983||e>=9984&&e<=10175||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=127456&&e<=127487}(t)||function(e){return e>=4352&&e<=4447||e>=11904&&e<=40959||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65055||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141}(t)?2:1}function*segmentGraphemes(t){for(const{segment:r}of e().segment(t))yield{value:r,width:graphemeWidth(r)}}function parseCSI(e){const t=e.slice(2);if(0===t.length)return null;const c=t.charCodeAt(t.length-1),u=t.slice(0,-1);let p="",a=u,y="";u.length>0&&"?>=".includes(u[0])&&(p=u[0],a=u.slice(1));const f=a.match(/([^0-9;:]+)$/);f&&(y=f[1],a=a.slice(0,-y.length));const l=function(e){return""===e?[]:e.split(/[;:]/).map(e=>""===e?0:parseInt(e,10))}(a),m=l[0]??1,h=l[1]??1;if(c===r.SGR&&""===p)return{type:"sgr",params:a};if(c===r.CUU)return{type:"cursor",action:{type:"move",direction:"up",count:m}};if(c===r.CUD)return{type:"cursor",action:{type:"move",direction:"down",count:m}};if(c===r.CUF)return{type:"cursor",action:{type:"move",direction:"forward",count:m}};if(c===r.CUB)return{type:"cursor",action:{type:"move",direction:"back",count:m}};if(c===r.CNL)return{type:"cursor",action:{type:"nextLine",count:m}};if(c===r.CPL)return{type:"cursor",action:{type:"prevLine",count:m}};if(c===r.CHA)return{type:"cursor",action:{type:"column",col:m}};if(c===r.CUP||c===r.HVP)return{type:"cursor",action:{type:"position",row:m,col:h}};if(c===r.VPA)return{type:"cursor",action:{type:"row",row:m}};if(c===r.ED){return{type:"erase",action:{type:"display",region:o[l[0]??0]??"toEnd"}}}if(c===r.EL){return{type:"erase",action:{type:"line",region:s[l[0]??0]??"toEnd"}}}if(c===r.ECH)return{type:"erase",action:{type:"chars",count:m}};if(c===r.SU)return{type:"scroll",action:{type:"up",count:m}};if(c===r.SD)return{type:"scroll",action:{type:"down",count:m}};if(c===r.DECSTBM)return{type:"scroll",action:{type:"setRegion",top:m,bottom:h}};if(c===r.SCOSC)return{type:"cursor",action:{type:"save"}};if(c===r.SCORC)return{type:"cursor",action:{type:"restore"}};if(c===r.DECSCUSR&&" "===y){return{type:"cursor",action:{type:"style",...n[m]??n[0]}}}if("?"===p&&(c===r.SM||c===r.RM)){const e=c===r.SM;if(m===i.CURSOR_VISIBLE)return{type:"cursor",action:e?{type:"show"}:{type:"hide"}};if(m===i.ALT_SCREEN_CLEAR||m===i.ALT_SCREEN)return{type:"mode",action:{type:"alternateScreen",enabled:e}};if(m===i.BRACKETED_PASTE)return{type:"mode",action:{type:"bracketedPaste",enabled:e}};if(m===i.MOUSE_NORMAL)return{type:"mode",action:{type:"mouseTracking",mode:e?"normal":"off"}};if(m===i.MOUSE_BUTTON)return{type:"mode",action:{type:"mouseTracking",mode:e?"button":"off"}};if(m===i.MOUSE_ANY)return{type:"mode",action:{type:"mouseTracking",mode:e?"any":"off"}};if(m===i.FOCUS_EVENTS)return{type:"mode",action:{type:"focusEvents",enabled:e}}}return{type:"unknown",sequence:e}}export class Parser{tokenizer=a();style=y();inLink=!1;linkUrl;reset(){this.tokenizer.reset(),this.style=y(),this.inLink=!1,this.linkUrl=void 0}feed(e){const t=this.tokenizer.feed(e),r=[];for(const e of t){const t=this.processToken(e);r.push(...t)}return r}processToken(e){switch(e.type){case"text":return this.processText(e.value);case"sequence":return this.processSequence(e.value)}}processText(e){const r=[];let n="";for(const o of e)if(o.charCodeAt(0)===t.BEL){if(n){const e=[...segmentGraphemes(n)];e.length>0&&r.push({type:"text",graphemes:e,style:{...this.style}}),n=""}r.push({type:"bell"})}else n+=o;if(n){const e=[...segmentGraphemes(n)];e.length>0&&r.push({type:"text",graphemes:e,style:{...this.style}})}return r}processSequence(e){const r=function(e){if(e.length<2)return"unknown";if(e.charCodeAt(0)!==t.ESC)return"unknown";const r=e.charCodeAt(1);return 91===r?"csi":93===r?"osc":79===r?"ss3":"esc"}(e);switch(r){case"csi":{const t=parseCSI(e);return t?"sgr"===t.type?(this.style=p(t.params,this.style),[]):[t]:[]}case"osc":{let t=e.slice(2);t.endsWith("")?t=t.slice(0,-1):t.endsWith("\\")&&(t=t.slice(0,-2));const r=u(t);return r?("link"===r.type&&("start"===r.action.type?(this.inLink=!0,this.linkUrl=r.action.url):(this.inLink=!1,this.linkUrl=void 0)),[r]):[]}case"esc":{const t=e.slice(1),r=c(t);return r?[r]:[]}default:return[{type:"unknown",sequence:e}]}}}
1
+ import{getGraphemeSegmenter as e}from"../../utils/intl.js";import{C0 as t}from"./ansi.js";import{CSI as r,CURSOR_STYLES as n,ERASE_DISPLAY as o,ERASE_LINE_REGION as s}from"./csi.js";import{DEC as i}from"./dec.js";import{parseEsc as c}from"./esc.js";import{parseOSC as p}from"./osc.js";import{applySGR as u}from"./sgr.js";import{createTokenizer as a}from"./tokenize.js";import{defaultStyle as y}from"./types.js";function graphemeWidth(e){if(function(e){let t=0;for(const r of e)if(t++,t>1)return!0;return!1}(e))return 2;const t=e.codePointAt(0);return void 0===t?1:function(e){return e>=9728&&e<=9983||e>=9984&&e<=10175||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=127456&&e<=127487}(t)||function(e){return e>=4352&&e<=4447||e>=11904&&e<=40959||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65055||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141}(t)?2:1}function*segmentGraphemes(t){for(const{segment:r}of e().segment(t))yield{value:r,width:graphemeWidth(r)}}function parseCSI(e){const t=e.slice(2);if(0===t.length)return null;const c=t.charCodeAt(t.length-1),p=t.slice(0,-1);let u="",a=p,y="";p.length>0&&"?>=".includes(p[0])&&(u=p[0],a=p.slice(1));const f=a.match(/([^0-9;:]+)$/);f&&(y=f[1],a=a.slice(0,-y.length));const l=function(e){return""===e?[]:e.split(/[;:]/).map(e=>""===e?0:parseInt(e,10))}(a),m=l[0]??1,h=l[1]??1;if(c===r.SGR&&""===u)return{type:"sgr",params:a};if(c===r.CUU)return{type:"cursor",action:{type:"move",direction:"up",count:m}};if(c===r.CUD)return{type:"cursor",action:{type:"move",direction:"down",count:m}};if(c===r.CUF)return{type:"cursor",action:{type:"move",direction:"forward",count:m}};if(c===r.CUB)return{type:"cursor",action:{type:"move",direction:"back",count:m}};if(c===r.CNL)return{type:"cursor",action:{type:"nextLine",count:m}};if(c===r.CPL)return{type:"cursor",action:{type:"prevLine",count:m}};if(c===r.CHA)return{type:"cursor",action:{type:"column",col:m}};if(c===r.CUP||c===r.HVP)return{type:"cursor",action:{type:"position",row:m,col:h}};if(c===r.VPA)return{type:"cursor",action:{type:"row",row:m}};if(c===r.ED)return{type:"erase",action:{type:"display",region:o[l[0]??0]??"toEnd"}};if(c===r.EL)return{type:"erase",action:{type:"line",region:s[l[0]??0]??"toEnd"}};if(c===r.ECH)return{type:"erase",action:{type:"chars",count:m}};if(c===r.SU)return{type:"scroll",action:{type:"up",count:m}};if(c===r.SD)return{type:"scroll",action:{type:"down",count:m}};if(c===r.DECSTBM)return{type:"scroll",action:{type:"setRegion",top:m,bottom:h}};if(c===r.SCOSC)return{type:"cursor",action:{type:"save"}};if(c===r.SCORC)return{type:"cursor",action:{type:"restore"}};if(c===r.DECSCUSR&&" "===y)return{type:"cursor",action:{type:"style",...n[m]??n[0]}};if("?"===u&&(c===r.SM||c===r.RM)){const e=c===r.SM;if(m===i.CURSOR_VISIBLE)return{type:"cursor",action:e?{type:"show"}:{type:"hide"}};if(m===i.ALT_SCREEN_CLEAR||m===i.ALT_SCREEN)return{type:"mode",action:{type:"alternateScreen",enabled:e}};if(m===i.BRACKETED_PASTE)return{type:"mode",action:{type:"bracketedPaste",enabled:e}};if(m===i.MOUSE_NORMAL)return{type:"mode",action:{type:"mouseTracking",mode:e?"normal":"off"}};if(m===i.MOUSE_BUTTON)return{type:"mode",action:{type:"mouseTracking",mode:e?"button":"off"}};if(m===i.MOUSE_ANY)return{type:"mode",action:{type:"mouseTracking",mode:e?"any":"off"}};if(m===i.FOCUS_EVENTS)return{type:"mode",action:{type:"focusEvents",enabled:e}}}return{type:"unknown",sequence:e}}export class Parser{tokenizer=a();style=y();inLink=!1;linkUrl;reset(){this.tokenizer.reset(),this.style=y(),this.inLink=!1,this.linkUrl=void 0}feed(e){const t=this.tokenizer.feed(e),r=[];for(const e of t){const t=this.processToken(e);r.push(...t)}return r}processToken(e){switch(e.type){case"text":return this.processText(e.value);case"sequence":return this.processSequence(e.value)}}processText(e){const r=[];let n="";for(const o of e)if(o.charCodeAt(0)===t.BEL){if(n){const e=[...segmentGraphemes(n)];e.length>0&&r.push({type:"text",graphemes:e,style:{...this.style}}),n=""}r.push({type:"bell"})}else n+=o;if(n){const e=[...segmentGraphemes(n)];e.length>0&&r.push({type:"text",graphemes:e,style:{...this.style}})}return r}processSequence(e){const r=function(e){if(e.length<2)return"unknown";if(e.charCodeAt(0)!==t.ESC)return"unknown";const r=e.charCodeAt(1);return 91===r?"csi":93===r?"osc":79===r?"ss3":"esc"}(e);switch(r){case"csi":{const t=parseCSI(e);return t?"sgr"===t.type?(this.style=u(t.params,this.style),[]):[t]:[]}case"osc":{let t=e.slice(2);t.endsWith("")?t=t.slice(0,-1):t.endsWith("\\")&&(t=t.slice(0,-2));const r=p(t);return r?("link"===r.type&&("start"===r.action.type?(this.inLink=!0,this.linkUrl=r.action.url):(this.inLink=!1,this.linkUrl=void 0)),[r]):[]}case"esc":{const t=e.slice(1),r=c(t);return r?[r]:[]}default:return[{type:"unknown",sequence:e}]}}}
@@ -1 +1 @@
1
- import{C0 as e,ESC_TYPE as t,isEscFinal as s}from"./ansi.js";import{isCSIFinal as a,isCSIIntermediate as c,isCSIParam as n}from"./csi.js";export function createTokenizer(e){let t="ground",s="";const a=e?.x10Mouse??!1;return{feed(e){const c=tokenize(e,t,s,!1,a);return t=c.state.state,s=c.state.buffer,c.tokens},flush(){const e=tokenize("",t,s,!0,a);return t=e.state.state,s=e.state.buffer,e.tokens},reset(){t="ground",s=""},buffer:()=>s}}function tokenize(r,o,u,i,l){const f=[],d={state:o,buffer:""},g=u+r;let h=0,p=0,k=0;const flushText=()=>{if(h>p){const e=g.slice(p,h);e&&f.push({type:"text",value:e})}p=h},emitSequence=e=>{e&&f.push({type:"sequence",value:e}),d.state="ground",p=h};for(;h<g.length;){const r=g.charCodeAt(h);switch(d.state){case"ground":r===e.ESC?(flushText(),k=h,d.state="escape",h++):h++;break;case"escape":r===t.CSI?(d.state="csi",h++):r===t.OSC?(d.state="osc",h++):r===t.DCS?(d.state="dcs",h++):r===t.APC?(d.state="apc",h++):79===r?(d.state="ss3",h++):c(r)?(d.state="escapeIntermediate",h++):s(r)?(h++,emitSequence(g.slice(k,h))):r===e.ESC?(emitSequence(g.slice(k,h)),k=h,d.state="escape",h++):(d.state="ground",p=k);break;case"escapeIntermediate":c(r)?h++:s(r)?(h++,emitSequence(g.slice(k,h))):(d.state="ground",p=k);break;case"csi":if(l&&77===r&&h-k===2&&(h+1>=g.length||g.charCodeAt(h+1)>=32)&&(h+2>=g.length||g.charCodeAt(h+2)>=32)&&(h+3>=g.length||g.charCodeAt(h+3)>=32)){h+4<=g.length?(h+=4,emitSequence(g.slice(k,h))):h=g.length;break}a(r)?(h++,emitSequence(g.slice(k,h))):n(r)||c(r)?h++:(d.state="ground",p=k);break;case"ss3":r>=64&&r<=126?(h++,emitSequence(g.slice(k,h))):(d.state="ground",p=k);break;case"osc":case"dcs":case"apc":r===e.BEL?(h++,emitSequence(g.slice(k,h))):r===e.ESC&&h+1<g.length&&g.charCodeAt(h+1)===t.ST?(h+=2,emitSequence(g.slice(k,h))):h++}}if("ground"===d.state)flushText();else if(i){const e=g.slice(k);e&&f.push({type:"sequence",value:e}),d.state="ground"}else d.buffer=g.slice(k);return{tokens:f,state:d}}
1
+ import{C0 as e,ESC_TYPE as t,isEscFinal as s}from"./ansi.js";import{isCSIFinal as a,isCSIIntermediate as c,isCSIParam as n}from"./csi.js";export function createTokenizer(e){let t="ground",s="";const a=e?.x10Mouse??!1;return{feed(e){const c=tokenize(e,t,s,!1,a);return t=c.state.state,s=c.state.buffer,c.tokens},flush(){const e=tokenize("",t,s,!0,a);return t=e.state.state,s=e.state.buffer,e.tokens},reset(){t="ground",s=""},buffer:()=>s}}function tokenize(r,o,i,u,l){const d=[],f={state:o,buffer:""},g=i+r;let h=0,C=0,p=0;const flushText=()=>{if(h>C){const e=g.slice(C,h);e&&d.push({type:"text",value:e})}C=h},emitSequence=e=>{e&&d.push({type:"sequence",value:e}),f.state="ground",C=h};for(;h<g.length;){const r=g.charCodeAt(h);switch(f.state){case"ground":r===e.ESC?(flushText(),p=h,f.state="escape",h++):h++;break;case"escape":r===t.CSI?(f.state="csi",h++):r===t.OSC?(f.state="osc",h++):r===t.DCS?(f.state="dcs",h++):r===t.APC?(f.state="apc",h++):79===r?(f.state="ss3",h++):c(r)?(f.state="escapeIntermediate",h++):s(r)?(h++,emitSequence(g.slice(p,h))):r===e.ESC?(emitSequence(g.slice(p,h)),p=h,f.state="escape",h++):(f.state="ground",C=p);break;case"escapeIntermediate":c(r)?h++:s(r)?(h++,emitSequence(g.slice(p,h))):(f.state="ground",C=p);break;case"csi":if(l&&77===r&&h-p===2&&(h+1>=g.length||g.charCodeAt(h+1)>=32)&&(h+2>=g.length||g.charCodeAt(h+2)>=32)&&(h+3>=g.length||g.charCodeAt(h+3)>=32)){h+4<=g.length?(h+=4,emitSequence(g.slice(p,h))):h=g.length;break}a(r)?(h++,emitSequence(g.slice(p,h))):n(r)||c(r)?h++:(f.state="ground",C=p);break;case"ss3":r>=64&&r<=126?(h++,emitSequence(g.slice(p,h))):(f.state="ground",C=p);break;case"osc":case"dcs":case"apc":r===e.BEL?(h++,emitSequence(g.slice(p,h))):r===e.ESC&&h+1<g.length&&g.charCodeAt(h+1)===t.ST?(h+=2,emitSequence(g.slice(p,h))):h++}}if("ground"===f.state)flushText();else if(u){const e=g.slice(p);e&&d.push({type:"sequence",value:e}),f.state="ground"}else f.buffer=g.slice(p);return{tokens:d,state:f}}
@@ -1 +1 @@
1
- import{createContext as t,useCallback as e,useContext as i,useMemo as r}from"react";import{isProgressReportingAvailable as o}from"./terminal.js";import{BEL as n}from"./termio/ansi.js";import{ITERM2 as s,OSC as a,osc as m,PROGRESS as T,wrapForMultiplexer as R}from"./termio/osc.js";export const TerminalWriteContext=t(null);export const TerminalWriteProvider=TerminalWriteContext.Provider;export function useTerminalNotification(){const t=i(TerminalWriteContext);if(!t)throw new Error("useTerminalNotification must be used within TerminalWriteProvider");const E=e(({message:e,title:i})=>{const r=i?`${i}:\n${e}`:e;t(R(m(a.ITERM2,`\n\n${r}`)))},[t]),c=e(({message:e,title:i,id:r})=>{t(R(m(a.KITTY,`i=${r}:d=0:p=title`,i))),t(R(m(a.KITTY,`i=${r}:p=body`,e))),t(R(m(a.KITTY,`i=${r}:d=1:a=focus`,"")))},[t]),l=e(({message:e,title:i})=>{t(R(m(a.GHOSTTY,"notify",i,e)))},[t]),f=e(()=>{t(n)},[t]),d=e((e,i)=>{if(!o())return;if(!e)return void t(R(m(a.ITERM2,s.PROGRESS,T.CLEAR,"")));const r=Math.max(0,Math.min(100,Math.round(i??0)));switch(e){case"completed":t(R(m(a.ITERM2,s.PROGRESS,T.CLEAR,"")));break;case"error":t(R(m(a.ITERM2,s.PROGRESS,T.ERROR,r)));break;case"indeterminate":t(R(m(a.ITERM2,s.PROGRESS,T.INDETERMINATE,"")));break;case"running":t(R(m(a.ITERM2,s.PROGRESS,T.SET,r)))}},[t]);return r(()=>({notifyITerm2:E,notifyKitty:c,notifyGhostty:l,notifyBell:f,progress:d}),[E,c,l,f,d])}
1
+ import{createContext as e,useCallback as t,useContext as r,useMemo as i}from"react";import{isProgressReportingAvailable as o}from"./terminal.js";import{BEL as s}from"./termio/ansi.js";import{ITERM2 as n,OSC as a,osc as m,PROGRESS as R,wrapForMultiplexer as T}from"./termio/osc.js";export const TerminalWriteContext=e(null);export const TerminalWriteProvider=TerminalWriteContext.Provider;export function useTerminalNotification(){const e=r(TerminalWriteContext);if(!e)throw new Error("useTerminalNotification must be used within TerminalWriteProvider");const l=t(({message:t,title:r})=>{const i=r?`${r}:\n${t}`:t;e(T(m(a.ITERM2,`\n\n${i}`)))},[e]),E=t(({message:t,title:r,id:i})=>{e(T(m(a.KITTY,`i=${i}:d=0:p=title`,r))),e(T(m(a.KITTY,`i=${i}:p=body`,t))),e(T(m(a.KITTY,`i=${i}:d=1:a=focus`,"")))},[e]),c=t(({message:t,title:r})=>{e(T(m(a.GHOSTTY,"notify",r,t)))},[e]),f=t(()=>{e(s)},[e]),u=t((t,r)=>{if(!o())return;if(!t)return void e(T(m(a.ITERM2,n.PROGRESS,R.CLEAR,"")));const i=Math.max(0,Math.min(100,Math.round(r??0)));switch(t){case"completed":e(T(m(a.ITERM2,n.PROGRESS,R.CLEAR,"")));break;case"error":e(T(m(a.ITERM2,n.PROGRESS,R.ERROR,i)));break;case"indeterminate":e(T(m(a.ITERM2,n.PROGRESS,R.INDETERMINATE,"")));break;case"running":e(T(m(a.ITERM2,n.PROGRESS,R.SET,i)))}},[e]);return i(()=>({notifyITerm2:l,notifyKitty:E,notifyGhostty:c,notifyBell:f,progress:u}),[l,E,c,f,u])}
@@ -1 +1 @@
1
- import{logForDebugging as e}from"../utils/debug.js";export function ifNotInteger(t,o){void 0!==t&&(Number.isInteger(t)||e(`${o} should be an integer, got ${t}`,{level:"warn"}))}
1
+ import{logForDebugging as e}from"../utils/debug.js";export function ifNotInteger(o,g){void 0!==o&&(Number.isInteger(o)||e(`${g} should be an integer, got ${o}`,{level:"warn"}))}
@@ -1 +1 @@
1
- import{lineWidth as t}from"./line-width-cache.js";export function widestLine(n){let e=0,i=0;for(;i<=n.length;){const r=n.indexOf("\n",i),s=-1===r?n.substring(i):n.substring(i,r);if(e=Math.max(e,t(s)),-1===r)break;i=r+1}return e}
1
+ import{lineWidth as t}from"./line-width-cache.js";export function widestLine(i){let n=0,e=0;for(;e<=i.length;){const r=i.indexOf("\n",e),s=-1===r?i.substring(e):i.substring(e,r);if(n=Math.max(n,t(s)),-1===r)break;e=r+1}return n}
@@ -1 +1 @@
1
- import t from"../utils/sliceAnsi.js";import{stringWidth as r}from"./stringWidth.js";import{wrapAnsi as i}from"./wrapAnsi.js";const e="…";function sliceFit(i,e,n){const s=t(i,e,n);return r(s)>n-e?t(i,e,n-1):s}export default function wrapText(t,n,s){if("wrap"===s)return i(t,n,{trim:!1,hard:!0});if("wrap-trim"===s)return i(t,n,{trim:!0,hard:!0});if(s.startsWith("truncate")){let i="end";return"truncate-middle"===s&&(i="middle"),"truncate-start"===s&&(i="start"),function(t,i,n){if(i<1)return"";if(1===i)return e;const s=r(t);if(s<=i)return t;if("start"===n)return e+sliceFit(t,s-i+1,s);if("middle"===n){const r=Math.floor(i/2);return sliceFit(t,0,r)+e+sliceFit(t,s-(i-r)+1,s)}return sliceFit(t,0,i-1)+e}(t,n,i)}return t}
1
+ import t from"../utils/sliceAnsi.js";import{stringWidth as r}from"./stringWidth.js";import{wrapAnsi as i}from"./wrapAnsi.js";const n="…";function sliceFit(i,n,e){const s=t(i,n,e);return r(s)>e-n?t(i,n,e-1):s}export default function wrapText(t,e,s){if("wrap"===s)return i(t,e,{trim:!1,hard:!0});if("wrap-trim"===s)return i(t,e,{trim:!0,hard:!0});if(s.startsWith("truncate")){let i="end";return"truncate-middle"===s&&(i="middle"),"truncate-start"===s&&(i="start"),function(t,i,e){if(i<1)return"";if(1===i)return n;const s=r(t);if(s<=i)return t;if("start"===e)return n+sliceFit(t,s-i+1,s);if("middle"===e){const r=Math.floor(i/2);return sliceFit(t,0,r)+n+sliceFit(t,s-(i-r)+1,s)}return sliceFit(t,0,i-1)+n}(t,e,i)}return t}
@@ -1 +1 @@
1
- import n from"wrap-ansi";const o=("undefined"!=typeof Bun&&"function"==typeof Bun.wrapAnsi?Bun.wrapAnsi:null)??n;export{o as wrapAnsi};
1
+ import n from"wrap-ansi";const p=("undefined"!=typeof Bun&&"function"==typeof Bun.wrapAnsi?Bun.wrapAnsi:null)??n;export{p as wrapAnsi};