@iaforged/context-code 2.1.6 → 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.
- package/dist/src/Task.js +1 -1
- package/dist/src/commands/add-dir/add-dir.js +1 -1
- package/dist/src/commands/add-dir/validation.js +1 -1
- package/dist/src/constants/oauth.js +1 -1
- package/dist/src/context/mailbox.js +1 -1
- package/dist/src/context/voice.js +1 -1
- package/dist/src/hooks/useTerminalSize.js +1 -1
- package/dist/src/ink/Ansi.js +1 -1
- package/dist/src/ink/clearTerminal.js +1 -1
- package/dist/src/ink/colorize.js +1 -1
- package/dist/src/ink/components/App.js +1 -1
- package/dist/src/ink/components/Button.js +1 -1
- package/dist/src/ink/components/ClockContext.js +1 -1
- package/dist/src/ink/components/CursorDeclarationContext.js +1 -1
- package/dist/src/ink/components/Link.js +1 -1
- package/dist/src/ink/components/StdinContext.js +1 -1
- package/dist/src/ink/components/TerminalFocusContext.js +1 -1
- package/dist/src/ink/dom.js +1 -1
- package/dist/src/ink/events/keyboard-event.js +1 -1
- package/dist/src/ink/hit-test.js +1 -1
- package/dist/src/ink/hooks/use-animation-frame.js +1 -1
- package/dist/src/ink/hooks/use-app.js +1 -1
- package/dist/src/ink/hooks/use-input.js +1 -1
- package/dist/src/ink/hooks/use-interval.js +1 -1
- package/dist/src/ink/hooks/use-selection.js +1 -1
- package/dist/src/ink/hooks/use-tab-status.js +1 -1
- package/dist/src/ink/hooks/use-terminal-focus.js +1 -1
- package/dist/src/ink/hooks/use-terminal-title.js +1 -1
- package/dist/src/ink/hooks/use-terminal-viewport.js +1 -1
- package/dist/src/ink/ink.js +1 -1
- package/dist/src/ink/layout/yoga.js +1 -1
- package/dist/src/ink/line-width-cache.js +1 -1
- package/dist/src/ink/log-update.js +1 -1
- package/dist/src/ink/measure-text.js +1 -1
- package/dist/src/ink/output.js +1 -1
- package/dist/src/ink/parse-keypress.js +1 -1
- package/dist/src/ink/reconciler.js +1 -1
- package/dist/src/ink/render-border.js +1 -1
- package/dist/src/ink/render-node-to-output.js +1 -1
- package/dist/src/ink/render-to-screen.js +1 -1
- package/dist/src/ink/renderer.js +1 -1
- package/dist/src/ink/root.js +1 -1
- package/dist/src/ink/screen.js +1 -1
- package/dist/src/ink/searchHighlight.js +1 -1
- package/dist/src/ink/selection.js +1 -1
- package/dist/src/ink/squash-text-nodes.js +1 -1
- package/dist/src/ink/stringWidth.js +1 -1
- package/dist/src/ink/tabstops.js +1 -1
- package/dist/src/ink/terminal.js +1 -1
- package/dist/src/ink/termio/osc.js +1 -1
- package/dist/src/ink/termio/parser.js +1 -1
- package/dist/src/ink/termio/tokenize.js +1 -1
- package/dist/src/ink/useTerminalNotification.js +1 -1
- package/dist/src/ink/warn.js +1 -1
- package/dist/src/ink/widest-line.js +1 -1
- package/dist/src/ink/wrap-text.js +1 -1
- package/dist/src/ink/wrapAnsi.js +1 -1
- package/dist/src/native-ts/yoga-layout/index.js +1 -1
- package/dist/src/schemas/hooks.js +1 -1
- package/dist/src/services/SessionMemory/sessionMemoryUtils.js +1 -1
- package/dist/src/services/api/client.js +1 -1
- package/dist/src/services/api/dumpPrompts.js +1 -1
- package/dist/src/services/api/errorUtils.js +1 -1
- package/dist/src/services/api/promptCacheBreakDetection.js +1 -1
- package/dist/src/services/api/withRetry.js +1 -1
- package/dist/src/services/autoDream/consolidationLock.js +1 -1
- package/dist/src/services/mcp/elicitationHandler.js +1 -1
- package/dist/src/services/mcp/mcpStringUtils.js +1 -1
- package/dist/src/services/mcp/oauthPort.js +1 -1
- package/dist/src/services/mcp/vscodeSdkMcp.js +1 -1
- package/dist/src/services/oauth/client.js +1 -1
- package/dist/src/services/oauth/getOauthProfile.js +1 -1
- package/dist/src/services/objetivo/types.js +1 -1
- package/dist/src/services/rateLimitMocking.js +1 -1
- package/dist/src/services/remoteManagedSettings/syncCacheState.js +1 -1
- package/dist/src/skills/bundledSkills.js +1 -1
- package/dist/src/tasks/DreamTask/DreamTask.js +1 -1
- package/dist/src/tools/AgentTool/agentMemory.js +1 -1
- package/dist/src/tools/AgentTool/forkSubagent.js +1 -1
- package/dist/src/tools/BashTool/BashToolResultMessage.js +1 -1
- package/dist/src/tools/BashTool/UI.js +1 -1
- package/dist/src/tools/BashTool/sedEditParser.js +1 -1
- package/dist/src/tools/BashTool/utils.js +1 -1
- package/dist/src/tools/FileReadTool/imageProcessor.js +1 -1
- package/dist/src/tools/FileReadTool/prompt.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/UI.js +1 -1
- package/dist/src/tools/MCPTool/MCPTool.js +1 -1
- package/dist/src/tools/MCPTool/UI.js +1 -1
- package/dist/src/tools/McpAuthTool/McpAuthTool.js +1 -1
- package/dist/src/tools/NotebookEditTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/PowerShellTool.js +1 -1
- package/dist/src/tools/PowerShellTool/UI.js +1 -1
- package/dist/src/tools/PowerShellTool/gitSafety.js +1 -1
- package/dist/src/tools/PowerShellTool/modeValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/pathValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellPermissions.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellSecurity.js +1 -1
- package/dist/src/tools/PowerShellTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/readOnlyValidation.js +1 -1
- package/dist/src/tools/REPLTool/constants.js +1 -1
- package/dist/src/tools/REPLTool/primitiveTools.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/UI.js +1 -1
- package/dist/src/tools/ScheduleCronTool/prompt.js +1 -1
- package/dist/src/tools/SkillTool/prompt.js +1 -1
- package/dist/src/tools/TodoWriteTool/TodoWriteTool.js +1 -1
- package/dist/src/tools/ToolSearchTool/prompt.js +1 -1
- package/dist/src/tools/WebSearchTool/prompt.js +1 -1
- package/dist/src/tools/shared/gitOperationTracking.js +1 -1
- package/dist/src/types/permissions.js +1 -1
- package/dist/src/utils/Cursor.js +1 -1
- package/dist/src/utils/QueryGuard.js +1 -1
- package/dist/src/utils/Shell.js +1 -1
- package/dist/src/utils/ShellCommand.js +1 -1
- package/dist/src/utils/activityManager.js +1 -1
- package/dist/src/utils/advisor.js +1 -1
- package/dist/src/utils/appleTerminalBackup.js +1 -1
- package/dist/src/utils/argumentSubstitution.js +1 -1
- package/dist/src/utils/authFileDescriptor.js +1 -1
- package/dist/src/utils/autoUpdater.js +1 -1
- package/dist/src/utils/background/remote/preconditions.js +1 -1
- package/dist/src/utils/background/remote/remoteSession.js +1 -1
- package/dist/src/utils/bash/ShellSnapshot.js +1 -1
- package/dist/src/utils/bash/ast.js +1 -1
- package/dist/src/utils/bash/bashParser.js +1 -1
- package/dist/src/utils/bash/bashPipeCommand.js +1 -1
- package/dist/src/utils/bash/parser.js +1 -1
- package/dist/src/utils/bash/shellQuote.js +1 -1
- package/dist/src/utils/bash/shellQuoting.js +1 -1
- package/dist/src/utils/billing.js +1 -1
- package/dist/src/utils/caCerts.js +1 -1
- package/dist/src/utils/claudeInChrome/common.js +1 -1
- package/dist/src/utils/claudeInChrome/setupPortable.js +1 -1
- package/dist/src/utils/claudemd.js +1 -1
- package/dist/src/utils/collapseBackgroundBashNotifications.js +1 -1
- package/dist/src/utils/collapseReadSearch.js +1 -1
- package/dist/src/utils/completionCache.js +1 -1
- package/dist/src/utils/computerUse/common.js +1 -1
- package/dist/src/utils/concurrentSessions.js +1 -1
- package/dist/src/utils/context.js +1 -1
- package/dist/src/utils/cron.js +1 -1
- package/dist/src/utils/cronTasks.js +1 -1
- package/dist/src/utils/cwd.js +1 -1
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debugFilter.js +1 -1
- package/dist/src/utils/detectRepository.js +1 -1
- package/dist/src/utils/diagLogs.js +1 -1
- package/dist/src/utils/diff.js +1 -1
- package/dist/src/utils/directMemberMessage.js +1 -1
- package/dist/src/utils/doctorDiagnostic.js +1 -1
- package/dist/src/utils/dxt/helpers.js +1 -1
- package/dist/src/utils/dxt/zip.js +1 -1
- package/dist/src/utils/earlyInput.js +1 -1
- package/dist/src/utils/editor.js +1 -1
- package/dist/src/utils/effort.js +1 -1
- package/dist/src/utils/embeddedTools.js +1 -1
- package/dist/src/utils/envDynamic.js +1 -1
- package/dist/src/utils/envUtils.js +1 -1
- package/dist/src/utils/execFileNoThrowPortable.js +1 -1
- package/dist/src/utils/execSyncWrapper.js +1 -1
- package/dist/src/utils/exportRenderer.js +1 -1
- package/dist/src/utils/extraUsage.js +1 -1
- package/dist/src/utils/fastMode.js +1 -1
- package/dist/src/utils/fileOperationAnalytics.js +1 -1
- package/dist/src/utils/fileRead.js +1 -1
- package/dist/src/utils/findExecutable.js +1 -1
- package/dist/src/utils/format.js +1 -1
- package/dist/src/utils/frontmatterParser.js +1 -1
- package/dist/src/utils/fsOperations.js +1 -1
- package/dist/src/utils/fullscreen.js +1 -1
- package/dist/src/utils/genericProcessUtils.js +1 -1
- package/dist/src/utils/getWorktreePaths.js +1 -1
- package/dist/src/utils/git/gitConfigParser.js +1 -1
- package/dist/src/utils/git/gitFilesystem.js +1 -1
- package/dist/src/utils/git/gitignore.js +1 -1
- package/dist/src/utils/gitDiff.js +1 -1
- package/dist/src/utils/gitSettings.js +1 -1
- package/dist/src/utils/glob.js +1 -1
- package/dist/src/utils/gracefulShutdown.js +1 -1
- package/dist/src/utils/groupToolUses.js +1 -1
- package/dist/src/utils/handlePromptSubmit.js +1 -1
- package/dist/src/utils/hash.js +1 -1
- package/dist/src/utils/hooks/fileChangedWatcher.js +1 -1
- package/dist/src/utils/hooks/hooksSettings.js +1 -1
- package/dist/src/utils/hooks/registerSkillHooks.js +1 -1
- package/dist/src/utils/hooks/sessionHooks.js +1 -1
- package/dist/src/utils/http.js +1 -1
- package/dist/src/utils/hyperlink.js +1 -1
- package/dist/src/utils/ide.js +1 -1
- package/dist/src/utils/idePathConversion.js +1 -1
- package/dist/src/utils/imagePaste.js +1 -1
- package/dist/src/utils/imageResizer.js +1 -1
- package/dist/src/utils/imageStore.js +1 -1
- package/dist/src/utils/inProcessTeammateHelpers.js +1 -1
- package/dist/src/utils/ink.js +1 -1
- package/dist/src/utils/jetbrains.js +1 -1
- package/dist/src/utils/json.js +1 -1
- package/dist/src/utils/listSessionsImpl.js +1 -1
- package/dist/src/utils/localInstaller.js +1 -1
- package/dist/src/utils/lockfile.js +1 -1
- package/dist/src/utils/logoV2Utils.js +1 -1
- package/dist/src/utils/markdown.js +1 -1
- package/dist/src/utils/mcp/dateTimeParser.js +1 -1
- package/dist/src/utils/mcpOutputStorage.js +1 -1
- package/dist/src/utils/mcpValidation.js +1 -1
- package/dist/src/utils/memoize.js +1 -1
- package/dist/src/utils/memory/types.js +1 -1
- package/dist/src/utils/memoryFileDetection.js +1 -1
- package/dist/src/utils/messageQueueManager.js +1 -1
- package/dist/src/utils/messages/mappers.js +1 -1
- package/dist/src/utils/messages/systemInit.js +1 -1
- package/dist/src/utils/model/antModels.js +1 -1
- package/dist/src/utils/model/check1mAccess.js +1 -1
- package/dist/src/utils/model/contextWindowUpgradeCheck.js +1 -1
- package/dist/src/utils/model/model.js +1 -1
- package/dist/src/utils/model/modelAllowlist.js +1 -1
- package/dist/src/utils/model/modelCapabilities.js +1 -1
- package/dist/src/utils/model/modelOptions.js +1 -1
- package/dist/src/utils/model/modelStrings.js +1 -1
- package/dist/src/utils/model/providerModels.js +1 -1
- package/dist/src/utils/model/providerProfiles.js +1 -1
- package/dist/src/utils/model/providerProfilesDb.js +1 -1
- package/dist/src/utils/model/providerSwitch.js +1 -1
- package/dist/src/utils/model/providers.js +1 -1
- package/dist/src/utils/modelCost.js +1 -1
- package/dist/src/utils/modifiers.js +1 -1
- package/dist/src/utils/mtls.js +1 -1
- package/dist/src/utils/nativeInstaller/download.js +1 -1
- package/dist/src/utils/nativeInstaller/installer.js +1 -1
- package/dist/src/utils/nativeInstaller/packageManagers.js +1 -1
- package/dist/src/utils/nativeInstaller/pidLock.js +1 -1
- package/dist/src/utils/notebook.js +1 -1
- package/dist/src/utils/pasteStore.js +1 -1
- package/dist/src/utils/path.js +1 -1
- package/dist/src/utils/permissions/PermissionMode.js +1 -1
- package/dist/src/utils/permissions/PermissionPromptToolResultSchema.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdate.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdateSchema.js +1 -1
- package/dist/src/utils/permissions/autoModeState.js +1 -1
- package/dist/src/utils/permissions/bypassPermissionsKillswitch.js +1 -1
- package/dist/src/utils/permissions/filesystem.js +1 -1
- package/dist/src/utils/permissions/getNextPermissionMode.js +1 -1
- package/dist/src/utils/permissions/pathValidation.js +1 -1
- package/dist/src/utils/permissions/permissionRuleParser.js +1 -1
- package/dist/src/utils/permissions/permissionsDb.js +1 -1
- package/dist/src/utils/permissions/permissionsLoader.js +1 -1
- package/dist/src/utils/permissions/shellRuleMatching.js +1 -1
- package/dist/src/utils/planModeV2.js +1 -1
- package/dist/src/utils/plans.js +1 -1
- package/dist/src/utils/platform.js +1 -1
- package/dist/src/utils/plugins/addDirPluginSettings.js +1 -1
- package/dist/src/utils/plugins/cacheUtils.js +1 -1
- package/dist/src/utils/plugins/dependencyResolver.js +1 -1
- package/dist/src/utils/plugins/fetchTelemetry.js +1 -1
- package/dist/src/utils/plugins/gitAvailability.js +1 -1
- package/dist/src/utils/plugins/hintRecommendation.js +1 -1
- package/dist/src/utils/plugins/installedPluginsManager.js +1 -1
- package/dist/src/utils/plugins/loadPluginAgents.js +1 -1
- package/dist/src/utils/plugins/loadPluginCommands.js +1 -1
- package/dist/src/utils/plugins/loadPluginHooks.js +1 -1
- package/dist/src/utils/plugins/loadPluginOutputStyles.js +1 -1
- package/dist/src/utils/plugins/lspPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/lspRecommendation.js +1 -1
- package/dist/src/utils/plugins/managedPlugins.js +1 -1
- package/dist/src/utils/plugins/marketplaceHelpers.js +1 -1
- package/dist/src/utils/plugins/marketplaceManager.js +1 -1
- package/dist/src/utils/plugins/mcpPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/mcpbHandler.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceGcs.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceStartupCheck.js +1 -1
- package/dist/src/utils/plugins/orphanedPluginFilter.js +1 -1
- package/dist/src/utils/plugins/performStartupChecks.js +1 -1
- package/dist/src/utils/plugins/pluginAutoupdate.js +1 -1
- package/dist/src/utils/plugins/pluginBlocklist.js +1 -1
- package/dist/src/utils/plugins/pluginDirectories.js +1 -1
- package/dist/src/utils/plugins/pluginFlagging.js +1 -1
- package/dist/src/utils/plugins/pluginInstallationHelpers.js +1 -1
- package/dist/src/utils/plugins/pluginLoader.js +1 -1
- package/dist/src/utils/plugins/pluginOptionsStorage.js +1 -1
- package/dist/src/utils/plugins/pluginPolicy.js +1 -1
- package/dist/src/utils/plugins/pluginStartupCheck.js +1 -1
- package/dist/src/utils/plugins/pluginVersioning.js +1 -1
- package/dist/src/utils/plugins/reconciler.js +1 -1
- package/dist/src/utils/plugins/refresh.js +1 -1
- package/dist/src/utils/plugins/schemas.js +1 -1
- package/dist/src/utils/plugins/walkPluginMarkdown.js +1 -1
- package/dist/src/utils/plugins/zipCache.js +1 -1
- package/dist/src/utils/powershell/parser.js +1 -1
- package/dist/src/utils/processUserInput/processBashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processTextPrompt.js +1 -1
- package/dist/src/utils/processUserInput/processUserInput.js +1 -1
- package/dist/src/utils/profilerBase.js +1 -1
- package/dist/src/utils/promptCategory.js +1 -1
- package/dist/src/utils/promptEditor.js +1 -1
- package/dist/src/utils/promptShellExecution.js +1 -1
- package/dist/src/utils/proxy.js +1 -1
- package/dist/src/utils/queryHelpers.js +1 -1
- package/dist/src/utils/queryProfiler.js +1 -1
- package/dist/src/utils/queueProcessor.js +1 -1
- package/dist/src/utils/readFileInRange.js +1 -1
- package/dist/src/utils/releaseNotes.js +1 -1
- package/dist/src/utils/renderOptions.js +1 -1
- package/dist/src/utils/ripgrep.js +1 -1
- package/dist/src/utils/sandbox/sandbox-adapter.js +1 -1
- package/dist/src/utils/sdkEventQueue.js +1 -1
- package/dist/src/utils/secureStorage/index.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainHelpers.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainStorage.js +1 -1
- package/dist/src/utils/secureStorage/plainTextStorage.js +1 -1
- package/dist/src/utils/secureStorage/sqliteStorage.js +1 -1
- package/dist/src/utils/sessionEnvironment.js +1 -1
- package/dist/src/utils/sessionIngressAuth.js +1 -1
- package/dist/src/utils/sessionRestore.js +1 -1
- package/dist/src/utils/sessionStart.js +1 -1
- package/dist/src/utils/sessionTitle.js +1 -1
- package/dist/src/utils/settings/managedPath.js +1 -1
- package/dist/src/utils/settings/mdm/rawRead.js +1 -1
- package/dist/src/utils/settings/mdm/settings.js +1 -1
- package/dist/src/utils/settings/permissionValidation.js +1 -1
- package/dist/src/utils/settings/pluginOnlyPolicy.js +1 -1
- package/dist/src/utils/settings/schemaOutput.js +1 -1
- package/dist/src/utils/settings/settings.js +1 -1
- package/dist/src/utils/settings/types.js +1 -1
- package/dist/src/utils/settings/validateEditTool.js +1 -1
- package/dist/src/utils/settings/validation.js +1 -1
- package/dist/src/utils/shell/bashProvider.js +1 -1
- package/dist/src/utils/shell/powershellDetection.js +1 -1
- package/dist/src/utils/shell/powershellProvider.js +1 -1
- package/dist/src/utils/shell/readOnlyCommandValidation.js +1 -1
- package/dist/src/utils/shell/resolveDefaultShell.js +1 -1
- package/dist/src/utils/shell/shellToolUtils.js +1 -1
- package/dist/src/utils/shell/specPrefix.js +1 -1
- package/dist/src/utils/shellConfig.js +1 -1
- package/dist/src/utils/sideQuestion.js +1 -1
- package/dist/src/utils/skills/skillChangeDetector.js +1 -1
- package/dist/src/utils/slashCommandParsing.js +1 -1
- package/dist/src/utils/sliceAnsi.js +1 -1
- package/dist/src/utils/slowOperations.js +1 -1
- package/dist/src/utils/standaloneAgent.js +1 -1
- package/dist/src/utils/startupProfiler.js +1 -1
- package/dist/src/utils/staticRender.js +1 -1
- package/dist/src/utils/status.js +1 -1
- package/dist/src/utils/statusNoticeDefinitions.js +1 -1
- package/dist/src/utils/suggestions/commandSuggestions.js +1 -1
- package/dist/src/utils/suggestions/directoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/shellHistoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/skillUsageTracking.js +1 -1
- package/dist/src/utils/suggestions/slackChannelSuggestions.js +1 -1
- package/dist/src/utils/swarm/backends/detection.js +1 -1
- package/dist/src/utils/swarm/permissionSync.js +1 -1
- package/dist/src/utils/swarm/reconnection.js +1 -1
- package/dist/src/utils/swarm/spawnUtils.js +91 -1
- package/dist/src/utils/swarm/teammateInit.js +1 -1
- package/dist/src/utils/systemDirectories.js +1 -1
- package/dist/src/utils/systemPrompt.js +1 -1
- package/dist/src/utils/systemTheme.js +1 -1
- package/dist/src/utils/task/TaskOutput.js +1 -1
- package/dist/src/utils/task/diskOutput.js +1 -1
- package/dist/src/utils/tasks.js +1 -1
- package/dist/src/utils/teamDiscovery.js +1 -1
- package/dist/src/utils/teamMemoryOps.js +1 -1
- package/dist/src/utils/teammateMailbox.js +1 -1
- package/dist/src/utils/telemetry/betaSessionTracing.js +1 -1
- package/dist/src/utils/telemetry/bigqueryExporter.js +1 -1
- package/dist/src/utils/telemetry/events.js +1 -1
- package/dist/src/utils/telemetry/instrumentation.js +1 -1
- package/dist/src/utils/telemetry/logger.js +1 -1
- package/dist/src/utils/telemetry/perfettoTracing.js +1 -1
- package/dist/src/utils/telemetry/pluginTelemetry.js +1 -1
- package/dist/src/utils/telemetry/sessionTracing.js +1 -1
- package/dist/src/utils/telemetryAttributes.js +1 -1
- package/dist/src/utils/teleport/api.js +1 -1
- package/dist/src/utils/teleport/environments.js +1 -1
- package/dist/src/utils/teleport/gitBundle.js +1 -1
- package/dist/src/utils/teleport.js +1 -1
- package/dist/src/utils/tempfile.js +1 -1
- package/dist/src/utils/terminal.js +1 -1
- package/dist/src/utils/terminalPanel.js +1 -1
- package/dist/src/utils/textHighlighting.js +1 -1
- package/dist/src/utils/theme.js +1 -1
- package/dist/src/utils/themes/bootstrap.js +1 -1
- package/dist/src/utils/themes/loader.js +1 -1
- package/dist/src/utils/thinking.js +1 -1
- package/dist/src/utils/tmuxSocket.js +1 -1
- package/dist/src/utils/tokens.js +1 -1
- package/dist/src/utils/toolPool.js +1 -1
- package/dist/src/utils/toolResultStorage.js +1 -1
- package/dist/src/utils/transcriptSearch.js +1 -1
- package/dist/src/utils/truncate.js +1 -1
- package/dist/src/utils/ultraplan/keyword.js +1 -1
- package/dist/src/utils/unaryLogging.js +1 -1
- package/dist/src/utils/undercover.js +1 -1
- package/dist/src/utils/user.js +1 -1
- package/dist/src/utils/userPromptKeywords.js +1 -1
- package/dist/src/utils/which.js +1 -1
- package/dist/src/utils/windowsPaths.js +1 -1
- package/dist/src/utils/worktree.js +1 -1
- package/dist/src/utils/zodToJsonSchema.js +1 -1
- package/dist/src/vim/operators.js +1 -1
- package/dist/src/vim/textObjects.js +1 -1
- package/dist/src/vim/transitions.js +1 -1
- package/dist/src/voice/voiceModeEnabled.js +1 -1
- package/dist/src/webapp/auth.js +1 -1
- package/dist/src/webapp/tunnel.js +1 -1
- package/dist/src/whatsapp/bridge.js +1 -1
- package/dist/src/whatsapp/mirror.js +1 -1
- package/package.json +1 -1
package/dist/src/Task.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomBytes as t}from"crypto";import{getTaskOutputPath as e}from"./utils/task/diskOutput.js";export function isTerminalTaskStatus(t){return"completed"===t||"failed"===t||"killed"===t}const o={local_bash:"b",local_agent:"a",remote_agent:"r",in_process_teammate:"t",local_workflow:"w",monitor_mcp:"m",dream:"d"};
|
|
1
|
+
import{randomBytes as t}from"crypto";import{getTaskOutputPath as e}from"./utils/task/diskOutput.js";export function isTerminalTaskStatus(t){return"completed"===t||"failed"===t||"killed"===t}const o={local_bash:"b",local_agent:"a",remote_agent:"r",in_process_teammate:"t",local_workflow:"w",monitor_mcp:"m",dream:"d"};export function generateTaskId(e){const a=function(t){return o[t]??"x"}(e),r=t(8);let n=a;for(let t=0;t<8;t++)n+="0123456789abcdefghijklmnopqrstuvwxyz"[r[t]%36];return n}export function createTaskStateBase(t,o,a,r){return{id:t,type:o,status:"pending",description:a,toolUseId:r,startTime:Date.now(),outputFile:e(t),outputOffset:0,notified:!1}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as o,jsx as
|
|
1
|
+
import{jsxs as o,jsx as r}from"react/jsx-runtime";import{c as e}from"react/compiler-runtime";import t from"chalk";import i from"figures";import{useEffect as s}from"react";import{getAdditionalDirectoriesForClaudeMd as n,setAdditionalDirectoriesForClaudeMd as a}from"../../bootstrap/state.js";import{MessageResponse as c}from"../../components/MessageResponse.js";import{AddWorkspaceDirectory as d}from"../../components/permissions/rules/AddWorkspaceDirectory.js";import{Box as m,Text as l}from"../../ink.js";import{applyPermissionUpdate as p,persistPermissionUpdate as u}from"../../utils/permissions/PermissionUpdate.js";import{SandboxManager as f}from"../../utils/sandbox/sandbox-adapter.js";import{addDirHelpMessage as g,validateDirectoryForWorkspace as j}from"./validation.js";function AddDirError(t){const n=e(10),{message:a,args:d,onDone:p}=t;let u,f,g,j,b;return n[0]!==p?(u=()=>{const o=setTimeout(p,0);return()=>clearTimeout(o)},f=[p],n[0]=p,n[1]=u,n[2]=f):(u=n[1],f=n[2]),s(u,f),n[3]!==d?(g=o(l,{dimColor:!0,children:[i.pointer," /add-dir ",d]}),n[3]=d,n[4]=g):g=n[4],n[5]!==a?(j=r(c,{children:r(l,{children:a})}),n[5]=a,n[6]=j):j=n[6],n[7]!==g||n[8]!==j?(b=o(m,{flexDirection:"column",children:[g,j]}),n[7]=g,n[8]=j,n[9]=b):b=n[9],b}export async function call(o,e,i){const s=(i??"").trim(),c=e.getAppState(),handleAddDirectory=async(r,i=!1)=>{const s={type:"addDirectories",directories:[r],destination:i?"localSettings":"session"},c=e.getAppState(),d=p(c.toolPermissionContext,s);e.setAppState(o=>({...o,toolPermissionContext:d}));const m=n();let l;if(m.includes(r)||a([...m,r]),f.refreshConfig(),i)try{u(s),l=`Se añadió ${t.bold(r)} como directorio de trabajo y se guardó en la configuración local`}catch(o){l=`Se añadió ${t.bold(r)} como directorio de trabajo. No se pudo guardar en la configuración local: ${o instanceof Error?o.message:"Error desconocido"}`}else l=`Se añadió ${t.bold(r)} como directorio de trabajo para esta sesión`;const g=`${l} ${t.dim("· /permissions para administrar")}`;o(g)};if(!s)return r(d,{permissionContext:c.toolPermissionContext,onAddDirectory:handleAddDirectory,onCancel:()=>{o("No se añadió ningún directorio de trabajo.")}});const m=await j(s,c.toolPermissionContext);if("success"!==m.resultType){const e=g(m);return r(AddDirError,{message:e,args:i??"",onDone:()=>o(e)})}return r(d,{directoryPath:m.absolutePath,permissionContext:c.toolPermissionContext,onAddDirectory:handleAddDirectory,onCancel:()=>{o(`No se añadió ${t.bold(m.absolutePath)} como directorio de trabajo.`)}})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"chalk";import{stat as t}from"fs/promises";import{dirname as e,resolve as o}from"path";import{getErrnoCode as
|
|
1
|
+
import r from"chalk";import{stat as t}from"fs/promises";import{dirname as e,resolve as o}from"path";import{getErrnoCode as a}from"../../utils/errors.js";import{expandPath as i}from"../../utils/path.js";import{allWorkingDirectories as s,pathInWorkingPath as c}from"../../utils/permissions/filesystem.js";export async function validateDirectoryForWorkspace(r,e){if(!r)return{resultType:"emptyPath"};const n=o(i(r));try{if(!(await t(n)).isDirectory())return{resultType:"notADirectory",directoryPath:r,absolutePath:n}}catch(t){const e=a(t);if("ENOENT"===e||"ENOTDIR"===e||"EACCES"===e||"EPERM"===e)return{resultType:"pathNotFound",directoryPath:r,absolutePath:n};throw t}const u=s(e);for(const t of u)if(c(n,t))return{resultType:"alreadyInWorkingDirectory",directoryPath:r,workingDir:t};return{resultType:"success",absolutePath:n}}export function addDirHelpMessage(t){switch(t.resultType){case"emptyPath":return"Por favor, proporciona una ruta de directorio.";case"pathNotFound":return`La ruta ${r.bold(t.absolutePath)} no fue encontrada.`;case"notADirectory":{const o=e(t.absolutePath);return`${r.bold(t.directoryPath)} no es un directorio. ¿Quisiste decir añadir el directorio padre ${r.bold(o)}?`}case"alreadyInWorkingDirectory":return`${r.bold(t.directoryPath)} ya está accesible dentro del directorio de trabajo existente ${r.bold(t.workingDir)}.`;case"success":return`Se añadió ${r.bold(t.absolutePath)} como directorio de trabajo.`}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEnvTruthy as e}from"
|
|
1
|
+
import{isEnvTruthy as e}from"src/utils/envUtils.js";function getOauthConfigType(){if("ant"===process.env.USER_TYPE){if(e(process.env.USE_LOCAL_OAUTH))return"local";if(e(process.env.USE_STAGING_OAUTH))return"staging"}return"prod"}export function fileSuffixForOauthConfig(){if(process.env.CONTEXT_CODE_CUSTOM_OAUTH_URL||process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return"-custom-oauth";switch(getOauthConfigType()){case"local":return"-local-oauth";case"staging":return"-staging-oauth";case"prod":return""}}function parseSpaceSeparatedList(e){return e?.split(/\s+/).filter(Boolean)??[]}const t="/auth/callback",_=`http://localhost:1455${t}`,a=["openid","profile","email","offline_access"];export const CLAUDE_AI_INFERENCE_SCOPE="user:inference";export const CLAUDE_AI_PROFILE_SCOPE="user:profile";export const OAUTH_BETA_HEADER="oauth-2025-04-20";export const CONSOLE_OAUTH_SCOPES=["org:create_api_key","user:profile"];export const CLAUDE_AI_OAUTH_SCOPES=["user:profile","user:inference","user:sessions:claude_code","user:mcp_servers","user:file_upload"];export const ALL_OAUTH_SCOPES=Array.from(new Set([...CONSOLE_OAUTH_SCOPES,...CLAUDE_AI_OAUTH_SCOPES]));const o={BASE_API_URL:"https://api.anthropic.com",CONSOLE_AUTHORIZE_URL:"https://platform.claude.com/oauth/authorize",CLAUDE_AI_AUTHORIZE_URL:"https://claude.com/cai/oauth/authorize",CLAUDE_AI_ORIGIN:"https://claude.ai",TOKEN_URL:"https://platform.claude.com/v1/oauth/token",API_KEY_URL:"https://api.anthropic.com/api/oauth/claude_cli/create_api_key",ROLES_URL:"https://api.anthropic.com/api/oauth/claude_cli/roles",CONSOLE_SUCCESS_URL:"https://platform.claude.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code",CLAUDEAI_SUCCESS_URL:"https://platform.claude.com/oauth/code/success?app=claude-code",MANUAL_REDIRECT_URL:"https://platform.claude.com/oauth/code/callback",CLIENT_ID:"9d1c250a-e61b-44d9-88ed-5944d1962f5e",OAUTH_FILE_SUFFIX:"",MCP_PROXY_URL:"https://mcp-proxy.anthropic.com",MCP_PROXY_PATH:"/v1/mcp/{server_id}"};export const MCP_CLIENT_METADATA_URL="https://claude.ai/oauth/claude-code-client-metadata";const c="ant"===process.env.USER_TYPE?{BASE_API_URL:"https://api-staging.anthropic.com",CONSOLE_AUTHORIZE_URL:"https://platform.staging.ant.dev/oauth/authorize",CLAUDE_AI_AUTHORIZE_URL:"https://claude-ai.staging.ant.dev/oauth/authorize",CLAUDE_AI_ORIGIN:"https://claude-ai.staging.ant.dev",TOKEN_URL:"https://platform.staging.ant.dev/v1/oauth/token",API_KEY_URL:"https://api-staging.anthropic.com/api/oauth/claude_cli/create_api_key",ROLES_URL:"https://api-staging.anthropic.com/api/oauth/claude_cli/roles",CONSOLE_SUCCESS_URL:"https://platform.staging.ant.dev/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code",CLAUDEAI_SUCCESS_URL:"https://platform.staging.ant.dev/oauth/code/success?app=claude-code",MANUAL_REDIRECT_URL:"https://platform.staging.ant.dev/oauth/code/callback",CLIENT_ID:"22422756-60c9-4084-8eb7-27705fd5cf9a",OAUTH_FILE_SUFFIX:"-staging-oauth",MCP_PROXY_URL:"https://mcp-proxy-staging.anthropic.com",MCP_PROXY_PATH:"/v1/mcp/{server_id}"}:void 0,s=["https://beacon.claude-ai.staging.ant.dev","https://claude.fedstart.com","https://claude-staging.fedstart.com"];export function getOauthConfig(){let e=(()=>{switch(getOauthConfigType()){case"local":return function(){const e=(process.env.CONTEXT_LOCAL_OAUTH_API_BASE??process.env.CLAUDE_LOCAL_OAUTH_API_BASE)?.replace(/\/$/,"")??"http://localhost:8000",t=(process.env.CONTEXT_LOCAL_OAUTH_APPS_BASE??process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE)?.replace(/\/$/,"")??"http://localhost:4000",_=(process.env.CONTEXT_LOCAL_OAUTH_CONSOLE_BASE??process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE)?.replace(/\/$/,"")??"http://localhost:3000";return{BASE_API_URL:e,CONSOLE_AUTHORIZE_URL:`${_}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${t}/oauth/authorize`,CLAUDE_AI_ORIGIN:t,TOKEN_URL:`${e}/v1/oauth/token`,API_KEY_URL:`${e}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${e}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${_}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${_}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${_}/oauth/code/callback`,CLIENT_ID:"22422756-60c9-4084-8eb7-27705fd5cf9a",OAUTH_FILE_SUFFIX:"-local-oauth",MCP_PROXY_URL:"http://localhost:8205",MCP_PROXY_PATH:"/v1/toolbox/shttp/mcp/{server_id}"}}();case"staging":return c??o;case"prod":return o}})();const t=process.env.CONTEXT_CODE_CUSTOM_OAUTH_URL??process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){const _=t.replace(/\/$/,"");if(!s.includes(_)){const e=void 0!==process.env.CONTEXT_CODE_CUSTOM_OAUTH_URL?"CONTEXT_CODE_CUSTOM_OAUTH_URL":"CLAUDE_CODE_CUSTOM_OAUTH_URL";throw new Error(`${e} is not an approved endpoint.`)}e={...e,BASE_API_URL:_,CONSOLE_AUTHORIZE_URL:`${_}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${_}/oauth/authorize`,CLAUDE_AI_ORIGIN:_,TOKEN_URL:`${_}/v1/oauth/token`,API_KEY_URL:`${_}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${_}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${_}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${_}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${_}/oauth/code/callback`,OAUTH_FILE_SUFFIX:"-custom-oauth"}}const _=process.env.CONTEXT_CODE_OAUTH_CLIENT_ID??process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return _&&(e={...e,CLIENT_ID:_}),e}export function getOpenAIOAuthConfig(){const e=process.env.OPENAI_OAUTH_BASE_URL?.replace(/\/$/,"")??process.env.OPENAI_OAUTH_ENDPOINT_BASE?.replace(/\/$/,"")??"https://auth.openai.com";return{AUTHORIZE_URL:process.env.OPENAI_OAUTH_AUTHORIZE_URL??`${e}/oauth/authorize`,TOKEN_URL:process.env.OPENAI_OAUTH_TOKEN_URL??`${e}/oauth/token`,CLIENT_ID:process.env.OPENAI_OAUTH_CLIENT_ID??"app_EMoamEEZ73f0CkXaXp7hrann",MANUAL_REDIRECT_URL:process.env.OPENAI_OAUTH_MANUAL_REDIRECT_URL??process.env.OPENAI_OAUTH_REDIRECT_URL??_,LOCAL_REDIRECT_URL:process.env.OPENAI_OAUTH_LOCAL_REDIRECT_URL??_,CALLBACK_PATH:process.env.OPENAI_OAUTH_CALLBACK_PATH??t,CALLBACK_PORT:parseInt(process.env.OPENAI_OAUTH_CALLBACK_PORT||String(1455),10),SUCCESS_URL:process.env.OPENAI_OAUTH_SUCCESS_URL??(e?`${e}/oauth/code/success?app=codex`:void 0),FILE_SUFFIX:"-openai-oauth",BASE_API_URL:e,PROFILE_URL:process.env.OPENAI_OAUTH_PROFILE_URL??(e?`${e}/api/oauth/profile`:void 0),SCOPES:parseSpaceSeparatedList(process.env.OPENAI_OAUTH_SCOPES).length>0?parseSpaceSeparatedList(process.env.OPENAI_OAUTH_SCOPES):[...a]}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{c as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{c as e}from"react/compiler-runtime";import{createContext as o,useContext as t}from"react";import{Mailbox as i}from"../utils/mailbox.js";const n=o(void 0);export function MailboxProvider(o){const t=e(3),{children:a}=o;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=new i,t[0]=s):s=t[0];const c=s;let m;return t[1]!==a?(m=r(n.Provider,{value:c,children:a}),t[1]=a,t[2]=m):m=t[2],m}export function useMailbox(){const r=t(n);if(!r)throw new Error("useMailbox must be used within a MailboxProvider");return r}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{createContext as r,useContext as o,useState as i,useSyncExternalStore as c}from"react";import{createStore as n}from"../state/store.js";const
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{createContext as r,useContext as o,useState as i,useSyncExternalStore as c}from"react";import{createStore as n}from"../state/store.js";const s={voiceState:"idle",voiceError:null,voiceInterimTranscript:"",voiceAudioLevels:[],voiceWarmingUp:!1},u=r(null);export function VoiceProvider(r){const o=t(3),{children:c}=r,[n]=i(_temp);let s;return o[0]!==c||o[1]!==n?(s=e(u.Provider,{value:n,children:c}),o[0]=c,o[1]=n,o[2]=s):s=o[2],s}function _temp(){return n(s)}function useVoiceStore(){const e=o(u);if(!e)throw new Error("useVoiceState must be used within a VoiceProvider");return e}export function useVoiceState(e){const r=t(3),o=useVoiceStore();let i;r[0]!==e||r[1]!==o?(i=()=>e(o.getState()),r[0]=e,r[1]=o,r[2]=i):i=r[2];const n=i;return c(o.subscribe,n,n)}export function useSetVoiceState(){return useVoiceStore().setState}export function useGetVoiceState(){return useVoiceStore().getState}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as e}from"react";import{TerminalSizeContext as n}from"
|
|
1
|
+
import{useContext as e}from"react";import{TerminalSizeContext as n}from"src/ink/components/TerminalSizeContext.js";export function useTerminalSize(){const t=e(n);if(!t)throw new Error("useTerminalSize must be used within an Ink App component");return t}
|
package/dist/src/ink/Ansi.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{c as e}from"react/compiler-runtime";import i from"react";import t from"./components/Link.js";import n from"./components/Text.js";import{Parser as o}from"./termio.js";export const Ansi=i.memo(function(i){const l=e(12),{children:s,dimColor:c}=i;if("string"!=typeof s){let e;return l[0]!==s||l[1]!==c?(e=r(n,c?{dim:!0,children:String(s)}:{children:String(s)}),l[0]=s,l[1]=c,l[2]=e):e=l[2],e}if(""===s)return null;let a,d;if(l[3]!==s||l[4]!==c){d=Symbol.for("react.early_return_sentinel");r:{const e=function(r){const e=(new o).feed(r),i=[];let t;for(const r of e)if("link"!==r.type){if("text"===r.type){const e=r.graphemes.map(r=>r.value).join("");if(!e)continue;const n=textStyleToSpanProps(r.style);t&&(n.hyperlink=t);const o=i[i.length-1];o&&propsEqual(o.props,n)?o.text+=e:i.push({text:e,props:n})}}else t="start"===r.action.type?r.action.url:void 0;return i}(s);if(0===e.length){d=null;break r}if(1===e.length&&
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{c as e}from"react/compiler-runtime";import i from"react";import t from"./components/Link.js";import n from"./components/Text.js";import{Parser as o}from"./termio.js";export const Ansi=i.memo(function(i){const l=e(12),{children:s,dimColor:c}=i;if("string"!=typeof s){let e;return l[0]!==s||l[1]!==c?(e=r(n,c?{dim:!0,children:String(s)}:{children:String(s)}),l[0]=s,l[1]=c,l[2]=e):e=l[2],e}if(""===s)return null;let a,d;if(l[3]!==s||l[4]!==c){d=Symbol.for("react.early_return_sentinel");r:{const e=function(r){const e=(new o).feed(r),i=[];let t;for(const r of e)if("link"!==r.type){if("text"===r.type){const e=r.graphemes.map(r=>r.value).join("");if(!e)continue;const n=textStyleToSpanProps(r.style);t&&(n.hyperlink=t);const o=i[i.length-1];o&&propsEqual(o.props,n)?o.text+=e:i.push({text:e,props:n})}}else t="start"===r.action.type?r.action.url:void 0;return i}(s);if(0===e.length){d=null;break r}if(1===e.length&&void 0===(p=e[0].props).color&&void 0===p.backgroundColor&&!0!==p.dim&&!0!==p.bold&&!0!==p.italic&&!0!==p.underline&&!0!==p.strikethrough&&!0!==p.inverse&&void 0===p.hyperlink){d=r(n,c?{dim:!0,children:e[0].text}:{children:e[0].text});break r}let i;l[7]!==c?(i=(e,i)=>{const n=e.props.hyperlink;c&&(e.props.dim=!0);const o=function(r){return void 0!==r.color||void 0!==r.backgroundColor||!0===r.dim||!0===r.bold||!0===r.italic||!0===r.underline||!0===r.strikethrough||!0===r.inverse}(e.props);return n?r(t,o?{url:n,children:r(StyledText,{color:e.props.color,backgroundColor:e.props.backgroundColor,dim:e.props.dim,bold:e.props.bold,italic:e.props.italic,underline:e.props.underline,strikethrough:e.props.strikethrough,inverse:e.props.inverse,children:e.text})}:{url:n,children:e.text},i):o?r(StyledText,{color:e.props.color,backgroundColor:e.props.backgroundColor,dim:e.props.dim,bold:e.props.bold,italic:e.props.italic,underline:e.props.underline,strikethrough:e.props.strikethrough,inverse:e.props.inverse,children:e.text},i):e.text},l[7]=c,l[8]=i):i=l[8],a=e.map(i)}l[3]=s,l[4]=c,l[5]=a,l[6]=d}else a=l[5],d=l[6];var p;if(d!==Symbol.for("react.early_return_sentinel"))return d;const u=a;let h;return l[9]!==u||l[10]!==c?(h=r(n,c?{dim:!0,children:u}:{children:u}),l[9]=u,l[10]=c,l[11]=h):h=l[11],h});function textStyleToSpanProps(r){const e={};r.bold&&(e.bold=!0),r.dim&&(e.dim=!0),r.italic&&(e.italic=!0),"none"!==r.underline&&(e.underline=!0),r.strikethrough&&(e.strikethrough=!0),r.inverse&&(e.inverse=!0);const i=colorToString(r.fg);i&&(e.color=i);const t=colorToString(r.bg);return t&&(e.backgroundColor=t),e}const l={black:"ansi:black",red:"ansi:red",green:"ansi:green",yellow:"ansi:yellow",blue:"ansi:blue",magenta:"ansi:magenta",cyan:"ansi:cyan",white:"ansi:white",brightBlack:"ansi:blackBright",brightRed:"ansi:redBright",brightGreen:"ansi:greenBright",brightYellow:"ansi:yellowBright",brightBlue:"ansi:blueBright",brightMagenta:"ansi:magentaBright",brightCyan:"ansi:cyanBright",brightWhite:"ansi:whiteBright"};function colorToString(r){switch(r.type){case"named":return l[r.name];case"indexed":return`ansi256(${r.index})`;case"rgb":return`rgb(${r.r},${r.g},${r.b})`;case"default":return}}function propsEqual(r,e){return r.color===e.color&&r.backgroundColor===e.backgroundColor&&r.bold===e.bold&&r.dim===e.dim&&r.italic===e.italic&&r.underline===e.underline&&r.strikethrough===e.strikethrough&&r.inverse===e.inverse&&r.hyperlink===e.hyperlink}function StyledText(i){const t=e(14);let o,l,s,c,a;if(t[0]!==i?(({bold:o,dim:s,children:l,...c}=i),t[0]=i,t[1]=o,t[2]=l,t[3]=s,t[4]=c):(o=t[1],l=t[2],s=t[3],c=t[4]),s){let e;return t[5]!==l||t[6]!==c?(e=r(n,{...c,dim:!0,children:l}),t[5]=l,t[6]=c,t[7]=e):e=t[7],e}if(o){let e;return t[8]!==l||t[9]!==c?(e=r(n,{...c,bold:!0,children:l}),t[8]=l,t[9]=c,t[10]=e):e=t[10],e}return t[11]!==l||t[12]!==c?(a=r(n,{...c,children:l}),t[11]=l,t[12]=c,t[13]=a):a=t[13],a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CURSOR_HOME as e,csi as
|
|
1
|
+
import{CURSOR_HOME as e,csi as s,ERASE_SCREEN as r,ERASE_SCROLLBACK as o}from"./termio/csi.js";const n=s(0,"f");export function getClearTerminalSequence(){return"win32"===process.platform?"win32"===process.platform&&process.env.WT_SESSION||"win32"===process.platform&&"vscode"===process.env.TERM_PROGRAM&&process.env.TERM_PROGRAM_VERSION||("mintty"===process.env.TERM_PROGRAM||"win32"===process.platform&&process.env.MSYSTEM)?r+o+e:r+n:r+o+e}export const clearTerminal=getClearTerminalSequence();
|
package/dist/src/ink/colorize.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"chalk";export const CHALK_BOOSTED_FOR_XTERMJS="vscode"===process.env.TERM_PROGRAM&&2===r.level&&(r.level=3,!0);export const CHALK_CLAMPED_FOR_TMUX=!(process.env.CONTEXT_CODE_TMUX_TRUECOLOR||process.env.CLAUDE_CODE_TMUX_TRUECOLOR||!(process.env.TMUX&&r.level>2)||(r.level=2,0));const e=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,t=/^ansi256\(\s?(\d+)\s?\)$/;export const colorize=(n,o,g)=>{if(!o)return n;if(o.startsWith("ansi:"))
|
|
1
|
+
import r from"chalk";export const CHALK_BOOSTED_FOR_XTERMJS="vscode"===process.env.TERM_PROGRAM&&2===r.level&&(r.level=3,!0);export const CHALK_CLAMPED_FOR_TMUX=!(process.env.CONTEXT_CODE_TMUX_TRUECOLOR||process.env.CLAUDE_CODE_TMUX_TRUECOLOR||!(process.env.TMUX&&r.level>2)||(r.level=2,0));const e=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,t=/^ansi256\(\s?(\d+)\s?\)$/;export const colorize=(n,o,g)=>{if(!o)return n;if(o.startsWith("ansi:"))switch(o.substring(5)){case"black":return"foreground"===g?r.black(n):r.bgBlack(n);case"red":return"foreground"===g?r.red(n):r.bgRed(n);case"green":return"foreground"===g?r.green(n):r.bgGreen(n);case"yellow":return"foreground"===g?r.yellow(n):r.bgYellow(n);case"blue":return"foreground"===g?r.blue(n):r.bgBlue(n);case"magenta":return"foreground"===g?r.magenta(n):r.bgMagenta(n);case"cyan":return"foreground"===g?r.cyan(n):r.bgCyan(n);case"white":return"foreground"===g?r.white(n):r.bgWhite(n);case"blackBright":return"foreground"===g?r.blackBright(n):r.bgBlackBright(n);case"redBright":return"foreground"===g?r.redBright(n):r.bgRedBright(n);case"greenBright":return"foreground"===g?r.greenBright(n):r.bgGreenBright(n);case"yellowBright":return"foreground"===g?r.yellowBright(n):r.bgYellowBright(n);case"blueBright":return"foreground"===g?r.blueBright(n):r.bgBlueBright(n);case"magentaBright":return"foreground"===g?r.magentaBright(n):r.bgMagentaBright(n);case"cyanBright":return"foreground"===g?r.cyanBright(n):r.bgCyanBright(n);case"whiteBright":return"foreground"===g?r.whiteBright(n):r.bgWhiteBright(n)}if(o.startsWith("#"))return"foreground"===g?r.hex(o)(n):r.bgHex(o)(n);if(o.startsWith("ansi256")){const e=t.exec(o);if(!e)return n;const i=Number(e[1]);return"foreground"===g?r.ansi256(i)(n):r.bgAnsi256(i)(n)}if(o.startsWith("rgb")){const t=e.exec(o);if(!t)return n;const i=Number(t[1]),u=Number(t[2]),s=Number(t[3]);return"foreground"===g?r.rgb(i,u,s)(n):r.bgRgb(i,u,s)(n)}return n};export function applyTextStyles(e,t){let n=e;return t.inverse&&(n=r.inverse(n)),t.strikethrough&&(n=r.strikethrough(n)),t.underline&&(n=r.underline(n)),t.italic&&(n=r.italic(n)),t.bold&&(n=r.bold(n)),t.dim&&(n=r.dim(n)),t.color&&(n=colorize(n,t.color,"foreground")),t.backgroundColor&&(n=colorize(n,t.backgroundColor,"background")),n}export function applyColor(r,e){return e?colorize(r,e,"foreground"):r}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{PureComponent as t}from"react";import{updateLastInteractionTime as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{PureComponent as t}from"react";import{updateLastInteractionTime as s}from"../../bootstrap/state.js";import{logForDebugging as i}from"../../utils/debug.js";import{stopCapturingEarlyInput as r}from"../../utils/earlyInput.js";import{isEnvTruthy as o}from"../../utils/envUtils.js";import{isMouseClicksDisabled as n}from"../../utils/fullscreen.js";import{logError as a}from"../../utils/log.js";import{EventEmitter as p}from"../events/emitter.js";import{InputEvent as l}from"../events/input-event.js";import{TerminalFocusEvent as d}from"../events/terminal-focus-event.js";import{INITIAL_STATE as m,parseMultipleKeypresses as u}from"../parse-keypress.js";import c from"../reconciler.js";import{finishSelection as h,hasSelection as T,startSelection as E}from"../selection.js";import{isXtermJs as C,setXtversionName as f,supportsExtendedKeys as S}from"../terminal.js";import{getTerminalFocused as v,setTerminalFocused as w}from"../terminal-focus-state.js";import{TerminalQuerier as I,xtversion as R}from"../terminal-querier.js";import{DISABLE_KITTY_KEYBOARD as k,DISABLE_MODIFY_OTHER_KEYS as g,ENABLE_KITTY_KEYBOARD as M,ENABLE_MODIFY_OTHER_KEYS as _,FOCUS_IN as b,FOCUS_OUT as O}from"../termio/csi.js";import{DBP as y,DFE as D,DISABLE_MOUSE_TRACKING as A,EBP as j,EFE as H,HIDE_CURSOR as x,SHOW_CURSOR as P}from"../termio/dec.js";import L from"./AppContext.js";import{ClockProvider as N}from"./ClockContext.js";import Y from"./CursorDeclarationContext.js";import F from"./ErrorOverview.js";import U from"./StdinContext.js";import{TerminalFocusProvider as B}from"./TerminalFocusContext.js";import{TerminalSizeContext as K}from"./TerminalSizeContext.js";const q="win32"!==process.platform;export default class App extends t{static displayName="InternalApp";static getDerivedStateFromError(e){return{error:e}}state={error:void 0};rawModeEnabledCount=0;internal_eventEmitter=new p;keyParseState=m;incompleteEscapeTimer=null;NORMAL_TIMEOUT=50;PASTE_TIMEOUT=500;querier=new I(this.props.stdout);lastClickTime=0;lastClickCol=-1;lastClickRow=-1;clickCount=0;pendingHyperlinkTimer=null;lastHoverCol=-1;lastHoverRow=-1;lastStdinTime=Date.now();isRawModeSupported(){return this.props.stdin.isTTY}render(){return e(K.Provider,{value:{columns:this.props.terminalColumns,rows:this.props.terminalRows},children:e(L.Provider,{value:{exit:this.handleExit},children:e(U.Provider,{value:{stdin:this.props.stdin,setRawMode:this.handleSetRawMode,isRawModeSupported:this.isRawModeSupported(),internal_exitOnCtrlC:this.props.exitOnCtrlC,internal_eventEmitter:this.internal_eventEmitter,internal_querier:this.querier},children:e(B,{children:e(N,{children:e(Y.Provider,{value:this.props.onCursorDeclaration??(()=>{}),children:this.state.error?e(F,{error:this.state.error}):this.props.children})})})})})})}componentDidMount(){!this.props.stdout.isTTY||o(process.env.CONTEXT_CODE_ACCESSIBILITY)||o(process.env.CLAUDE_CODE_ACCESSIBILITY)||this.props.stdout.write(x)}componentWillUnmount(){this.props.stdout.isTTY&&this.props.stdout.write(P),this.incompleteEscapeTimer&&(clearTimeout(this.incompleteEscapeTimer),this.incompleteEscapeTimer=null),this.pendingHyperlinkTimer&&(clearTimeout(this.pendingHyperlinkTimer),this.pendingHyperlinkTimer=null),this.isRawModeSupported()&&this.handleSetRawMode(!1)}componentDidCatch(e){this.handleExit(e)}handleSetRawMode=e=>{const{stdin:t}=this.props;if(!this.isRawModeSupported())throw t===process.stdin?new Error("Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported"):new Error("Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");if(t.setEncoding("utf8"),e)return 0===this.rawModeEnabledCount&&(r(),t.ref(),t.setRawMode(!0),t.addListener("readable",this.handleReadable),this.props.stdout.write(j),this.props.stdout.write(H),S()&&(this.props.stdout.write(M),this.props.stdout.write(_)),setImmediate(()=>{Promise.all([this.querier.send(R()),this.querier.flush()]).then(([e])=>{e?(f(e.name),i(`XTVERSION: terminal identified as "${e.name}"`)):i("XTVERSION: no reply (terminal ignored query)")})})),void this.rawModeEnabledCount++;0===--this.rawModeEnabledCount&&(this.props.stdout.write(g),this.props.stdout.write(k),this.props.stdout.write(D),this.props.stdout.write(y),t.setRawMode(!1),t.removeListener("readable",this.handleReadable),t.unref())};flushIncomplete=()=>{this.incompleteEscapeTimer=null,this.keyParseState.incomplete&&(this.props.stdin.readableLength>0?this.incompleteEscapeTimer=setTimeout(this.flushIncomplete,this.NORMAL_TIMEOUT):this.processInput(null))};processInput=e=>{const[t,s]=u(this.keyParseState,e);this.keyParseState=s,t.length>0&&c.discreteUpdates(processKeysInBatch,this,t,void 0,void 0),this.keyParseState.incomplete&&(this.incompleteEscapeTimer&&clearTimeout(this.incompleteEscapeTimer),this.incompleteEscapeTimer=setTimeout(this.flushIncomplete,"IN_PASTE"===this.keyParseState.mode?this.PASTE_TIMEOUT:this.NORMAL_TIMEOUT))};handleReadable=()=>{const e=Date.now();e-this.lastStdinTime>5e3&&this.props.onStdinResume?.(),this.lastStdinTime=e;try{let e;for(;null!==(e=this.props.stdin.read());)this.processInput(e)}catch(e){a(e);const{stdin:t}=this.props;this.rawModeEnabledCount>0&&!t.listeners("readable").includes(this.handleReadable)&&(i("handleReadable: re-attaching stdin readable listener after error recovery",{level:"warn"}),t.addListener("readable",this.handleReadable))}};handleInput=e=>{""===e&&this.props.exitOnCtrlC&&this.handleExit()};handleExit=e=>{this.isRawModeSupported()&&this.handleSetRawMode(!1),this.props.onExit(e)};handleTerminalFocus=e=>{w(e)};handleSuspend=()=>{if(!this.isRawModeSupported())return;const e=this.rawModeEnabledCount;for(;this.rawModeEnabledCount>0;)this.handleSetRawMode(!1);this.props.stdout.isTTY&&this.props.stdout.write(P+D+A),this.internal_eventEmitter.emit("suspend");const resumeHandler=()=>{for(let t=0;t<e;t++)this.isRawModeSupported()&&this.handleSetRawMode(!0);this.props.stdout.isTTY&&(o(process.env.CONTEXT_CODE_ACCESSIBILITY)||o(process.env.CLAUDE_CODE_ACCESSIBILITY)||this.props.stdout.write(x),this.props.stdout.write(H)),this.internal_eventEmitter.emit("resume"),process.removeListener("SIGCONT",resumeHandler)};process.on("SIGCONT",resumeHandler),process.kill(process.pid,"SIGSTOP")}}function processKeysInBatch(e,t,i,r){t.some(e=>"key"===e.kind||"mouse"===e.kind&&!(32&e.button&&!(3&~e.button)))&&s();for(const s of t){if("response"===s.kind){e.querier.onResponse(s.response);continue}if("mouse"===s.kind){handleMouseEvent(e,s);continue}const t=s.sequence;if(t===b){e.handleTerminalFocus(!0);const t=new d("terminalfocus");e.internal_eventEmitter.emit("terminalfocus",t);continue}if(t===O){e.handleTerminalFocus(!1),e.props.selection.isDragging&&(h(e.props.selection),e.props.onSelectionChange());const t=new d("terminalblur");e.internal_eventEmitter.emit("terminalblur",t);continue}if(v()||w(!0),"z"===s.name&&s.ctrl&&q){e.handleSuspend();continue}e.handleInput(t);const i=new l(s);e.internal_eventEmitter.emit("input",i),e.props.dispatchKeyboardEvent(s)}}export function handleMouseEvent(e,t){if(n())return;const s=e.props.selection,i=t.col-1,r=t.row-1,o=3&t.button;if("press"===t.action){if(32&t.button&&3===o){if(s.isDragging&&(h(s),e.props.onSelectionChange()),i===e.lastHoverCol&&r===e.lastHoverRow)return;return e.lastHoverCol=i,e.lastHoverRow=r,void e.props.onHoverAt(i,r)}if(0!==o)return void(e.clickCount=0);if(32&t.button)return void e.props.onSelectionDrag(i,r);s.isDragging&&(h(s),e.props.onSelectionChange());const n=Date.now(),a=n-e.lastClickTime<500&&Math.abs(i-e.lastClickCol)<=1&&Math.abs(r-e.lastClickRow)<=1;if(e.clickCount=a?e.clickCount+1:1,e.lastClickTime=n,e.lastClickCol=i,e.lastClickRow=r,e.clickCount>=2){e.pendingHyperlinkTimer&&(clearTimeout(e.pendingHyperlinkTimer),e.pendingHyperlinkTimer=null);const t=2===e.clickCount?2:3;return void e.props.onMultiClick(i,r,t)}return E(s,i,r),s.lastPressHadAlt=!!(8&t.button),void e.props.onSelectionChange()}if(0!==o){if(!s.isDragging)return;return h(s),void e.props.onSelectionChange()}if(h(s),!T(s)&&s.anchor&&!e.props.onClickAt(i,r)){const t=e.props.getHyperlinkAt(i,r);t&&"vscode"!==process.env.TERM_PROGRAM&&!C()&&(e.pendingHyperlinkTimer&&clearTimeout(e.pendingHyperlinkTimer),e.pendingHyperlinkTimer=setTimeout((e,t)=>{e.pendingHyperlinkTimer=null,e.props.onOpenHyperlink(t)},500,e,t))}e.props.onSelectionChange()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as o,useRef as n,useState as r}from"react";import c from"./Box.js";function Button(
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as o,useRef as n,useState as r}from"react";import c from"./Box.js";function Button(u){const s=t(30);let m,l,a,i,f,_;s[0]!==u?(({onAction:a,tabIndex:_,autoFocus:m,children:l,ref:i,...f}=u),s[0]=u,s[1]=m,s[2]=l,s[3]=a,s[4]=i,s[5]=f,s[6]=_):(m=s[1],l=s[2],a=s[3],i=s[4],f=s[5],_=s[6]);const p=void 0===_?0:_,[y,d]=r(!1),[h,b]=r(!1),[x,S]=r(!1),v=n(null);let B,j,k;s[7]===Symbol.for("react.memo_cache_sentinel")?(B=()=>()=>{v.current&&clearTimeout(v.current)},j=[],s[7]=B,s[8]=j):(B=s[7],j=s[8]),o(B,j),s[9]!==a?(k=e=>{"return"!==e.key&&" "!==e.key||(e.preventDefault(),S(!0),a(),v.current&&clearTimeout(v.current),v.current=setTimeout(_temp,100,S))},s[9]=a,s[10]=k):k=s[10];const F=k;let T;s[11]!==a?(T=e=>{a()},s[11]=a,s[12]=T):T=s[12];const D=T;let E;s[13]===Symbol.for("react.memo_cache_sentinel")?(E=e=>d(!0),s[13]=E):E=s[13];const I=E;let M;s[14]===Symbol.for("react.memo_cache_sentinel")?(M=e=>d(!1),s[14]=M):M=s[14];const w=M;let A;s[15]===Symbol.for("react.memo_cache_sentinel")?(A=()=>b(!0),s[15]=A):A=s[15];const C=A;let K;s[16]===Symbol.for("react.memo_cache_sentinel")?(K=()=>b(!1),s[16]=K):K=s[16];const L=K;let R;s[17]!==l||s[18]!==x||s[19]!==y||s[20]!==h?(R="function"==typeof l?l({focused:y,hovered:h,active:x}):l,s[17]=l,s[18]=x,s[19]=y,s[20]=h,s[21]=R):R=s[21];const g=R;let q;return s[22]!==m||s[23]!==g||s[24]!==D||s[25]!==F||s[26]!==i||s[27]!==f||s[28]!==p?(q=e(c,{ref:i,tabIndex:p,autoFocus:m,onKeyDown:F,onClick:D,onFocus:I,onBlur:w,onMouseEnter:C,onMouseLeave:L,...f,children:g}),s[22]=m,s[23]=g,s[24]=D,s[25]=F,s[26]=i,s[27]=f,s[28]=p,s[29]=q):q=s[29],q}function _temp(e){return e(!1)}export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{createContext as n,useEffect as o,useState as r}from"react";import{FRAME_INTERVAL_MS as a}from"../constants.js";import{useTerminalFocus as c}from"../hooks/use-terminal-focus.js";export function createClock(e){const t=new Map;let n=null,o=e,r=0,a=0;function tick(){a=Date.now()-r;for(const e of t.keys())e()}function updateInterval(){[...t.values()].some(Boolean)?(n&&(clearInterval(n),n=null),0===r&&(r=Date.now()),n=setInterval(tick,o)):n&&(clearInterval(n),n=null)}return{subscribe:(e,n)=>(t.set(e,n),updateInterval(),()=>{t.delete(e),updateInterval()}),now:()=>(0===r&&(r=Date.now()),n&&a?a:Date.now()-r),setTickInterval(e){e!==o&&(o=e,updateInterval())}}}export const ClockContext=n(null);const l=2*a;export function ClockProvider(n){const s=t(7),{children:u}=n,[i]=r(_temp),m=c();let p,f,v;return s[0]!==i||s[1]!==m?(p=()=>{i.setTickInterval(m?a:l)},f=[i,m],s[0]=i,s[1]=m,s[2]=p,s[3]=f):(p=s[2],f=s[3]),o(p,f),s[4]!==u||s[5]!==i?(v=e(ClockContext.Provider,{value:i,children:u}),s[4]=u,s[5]=i,s[6]=v):v=s[6],v}function _temp(){return createClock(a)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as t}from"react";const
|
|
1
|
+
import{createContext as t}from"react";const e=t(()=>{});export default e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{supportsHyperlinks as e}from"../supports-hyperlinks.js";import i from"./Text.js";export default function Link(n){const o=t(5),{children:
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{supportsHyperlinks as e}from"../supports-hyperlinks.js";import i from"./Text.js";export default function Link(n){const o=t(5),{children:s,url:l,fallback:c}=n,p=s??l;if(e()){let t;return o[0]!==p||o[1]!==l?(t=r(i,{children:r("ink-link",{href:l,children:p})}),o[0]=p,o[1]=l,o[2]=t):t=o[2],t}const m=c??p;let f;return o[3]!==m?(f=r(i,{children:m}),o[3]=m,o[4]=f):f=o[4],f}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as t}from"react";import{EventEmitter as e}from"../events/emitter.js";const n=t({stdin:process.stdin,internal_eventEmitter:new e,setRawMode(){},isRawModeSupported:!1,internal_exitOnCtrlC:!0,internal_querier:null});n.displayName="InternalStdinContext";export default n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{c as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{createContext as r,useSyncExternalStore as o}from"react";import{getTerminalFocused as a,getTerminalFocusState as s,subscribeTerminalFocus as n}from"../terminal-focus-state.js";const i=r({isTerminalFocused:!0,terminalFocusState:"unknown"});i.displayName="TerminalFocusContext";export function TerminalFocusProvider(r){const c=t(6),{children:m}=r,l=o(n,a),u=o(n,s);let d;c[0]!==l||c[1]!==u?(d={isTerminalFocused:l,terminalFocusState:u},c[0]=l,c[1]=u,c[2]=d):d=c[2];const F=d;let p;return c[3]!==m||c[4]!==F?(p=e(i.Provider,{value:F,children:m}),c[3]=m,c[4]=F,c[5]=p):p=c[5],p}export default i;
|
package/dist/src/ink/dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLayoutNode as e}from"./layout/engine.js";import{LayoutDisplay as
|
|
1
|
+
import{createLayoutNode as e}from"./layout/engine.js";import{LayoutDisplay as o,LayoutMeasureMode as t}from"./layout/node.js";import r from"./measure-text.js";import{addPendingClear as n,nodeCache as d}from"./node-cache.js";import a from"./squash-text-nodes.js";import{expandTabs as i}from"./tabstops.js";import s from"./wrap-text.js";export const createNode=o=>{const t={nodeName:o,style:{},attributes:{},childNodes:[],parentNode:void 0,yogaNode:"ink-virtual-text"!==o&&"ink-link"!==o&&"ink-progress"!==o?e():void 0,dirty:!1};return"ink-text"===o?t.yogaNode?.setMeasureFunc(measureTextNode.bind(null,t)):"ink-raw-ansi"===o&&t.yogaNode?.setMeasureFunc(measureRawAnsiNode.bind(null,t)),t};export const appendChildNode=(e,o)=>{o.parentNode&&removeChildNode(o.parentNode,o),o.parentNode=e,e.childNodes.push(o),o.yogaNode&&e.yogaNode?.insertChild(o.yogaNode,e.yogaNode.getChildCount()),markDirty(e)};export const insertBeforeNode=(e,o,t)=>{o.parentNode&&removeChildNode(o.parentNode,o),o.parentNode=e;const r=e.childNodes.indexOf(t);if(r>=0){let t=0;if(o.yogaNode&&e.yogaNode)for(let o=0;o<r;o++)e.childNodes[o]?.yogaNode&&t++;return e.childNodes.splice(r,0,o),o.yogaNode&&e.yogaNode&&e.yogaNode.insertChild(o.yogaNode,t),void markDirty(e)}e.childNodes.push(o),o.yogaNode&&e.yogaNode?.insertChild(o.yogaNode,e.yogaNode.getChildCount()),markDirty(e)};export const removeChildNode=(e,o)=>{o.yogaNode&&o.parentNode?.yogaNode?.removeChild(o.yogaNode),collectRemovedRects(e,o),o.parentNode=void 0;const t=e.childNodes.indexOf(o);t>=0&&e.childNodes.splice(t,1),markDirty(e)};function collectRemovedRects(e,o,t=!1){if("#text"===o.nodeName)return;const r=o,a=t||"absolute"===r.style.position,i=d.get(r);i&&(n(e,i,a),d.delete(r));for(const o of r.childNodes)collectRemovedRects(e,o,a)}export const setAttribute=(e,o,t)=>{"children"!==o&&e.attributes[o]!==t&&(e.attributes[o]=t,markDirty(e))};export const setStyle=(e,o)=>{shallowEqual(e.style,o)||(e.style=o,markDirty(e))};export const setTextStyles=(e,o)=>{shallowEqual(e.textStyles,o)||(e.textStyles=o,markDirty(e))};function shallowEqual(e,o){if(e===o)return!0;if(void 0===e||void 0===o)return!1;const t=Object.keys(e),r=Object.keys(o);if(t.length!==r.length)return!1;for(const r of t)if(e[r]!==o[r])return!1;return!0}export const createTextNode=e=>{const o={nodeName:"#text",nodeValue:e,yogaNode:void 0,parentNode:void 0,style:{}};return setTextNodeValue(o,e),o};const measureTextNode=function(e,o,n){const d="#text"===e.nodeName?e.nodeValue:a(e),l=i(d),c=r(l,o);if(c.width<=o)return c;if(c.width>=1&&o>0&&o<1)return c;if(l.includes("\n")&&n===t.Undefined){const e=Math.max(o,c.width);return r(l,e)}const N=e.style?.textWrap??"wrap",u=s(l,o,N);return r(u,o)},measureRawAnsiNode=function(e){return{width:e.attributes.rawWidth,height:e.attributes.rawHeight}};export const markDirty=e=>{let o=e,t=!1;for(;o;)"#text"!==o.nodeName&&(o.dirty=!0,t||"ink-text"!==o.nodeName&&"ink-raw-ansi"!==o.nodeName||!o.yogaNode||(o.yogaNode.markDirty(),t=!0)),o=o.parentNode};export const scheduleRenderFrom=e=>{let o=e;for(;o?.parentNode;)o=o.parentNode;o&&"#text"!==o.nodeName&&o.onRender?.()};export const setTextNodeValue=(e,o)=>{"string"!=typeof o&&(o=String(o)),e.nodeValue!==o&&(e.nodeValue=o,markDirty(e))};function isDOMElement(e){return"#text"!==e.nodeName}export const clearYogaNodeReferences=e=>{if("childNodes"in e)for(const o of e.childNodes)clearYogaNodeReferences(o);e.yogaNode=void 0};export function findOwnerChainAtRow(e,t){let r=[];return function walk(e,n){const d=e.yogaNode;if(!d||d.getDisplay()===o.None)return;const a=n+d.getComputedTop(),i=d.getComputedHeight();if(!(t<a||t>=a+i)){e.debugOwnerChain&&(r=e.debugOwnerChain);for(const o of e.childNodes)isDOMElement(o)&&walk(o,a)}}(e,0),r}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TerminalEvent as
|
|
1
|
+
import{TerminalEvent as e}from"./terminal-event.js";export class KeyboardEvent extends e{key;ctrl;shift;meta;superKey;fn;constructor(e){super("keydown",{bubbles:!0,cancelable:!0}),this.key=function(e){const t=e.sequence??"",n=e.name??"";if(e.ctrl)return n;if(1===t.length){const e=t.charCodeAt(0);if(e>=32&&127!==e)return t}return n||t}(e),this.ctrl=e.ctrl,this.shift=e.shift,this.meta=e.meta||e.option,this.superKey=e.super,this.fn=e.fn}}
|
package/dist/src/ink/hit-test.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ClickEvent as e}from"./events/click-event.js";import{nodeCache as t}from"./node-cache.js";export function hitTest(e,o
|
|
1
|
+
import{ClickEvent as e}from"./events/click-event.js";import{nodeCache as t}from"./node-cache.js";export function hitTest(e,n,o){const r=t.get(e);if(!r)return null;if(n<r.x||n>=r.x+r.width||o<r.y||o>=r.y+r.height)return null;for(let t=e.childNodes.length-1;t>=0;t--){const r=e.childNodes[t];if("#text"===r.nodeName)continue;const s=hitTest(r,n,o);if(s)return s}return e}export function dispatchClick(n,o,r,s=!1){let i=hitTest(n,o,r)??void 0;if(!i)return!1;if(n.focusManager){let e=i;for(;e;){if("number"==typeof e.attributes.tabIndex){n.focusManager.handleClickFocus(e);break}e=e.parentNode}}const a=new e(o,r,s);let c=!1;for(;i;){const e=i._eventHandlers?.onClick;if(e){c=!0;const n=t.get(i);if(n&&(a.localCol=o-n.x,a.localRow=r-n.y),e(a),a.didStopImmediatePropagation())return!0}i=i.parentNode}return c}export function dispatchHover(e,t,n,o){const r=new Set;let s=hitTest(e,t,n)??void 0;for(;s;){const e=s._eventHandlers;(e?.onMouseEnter||e?.onMouseLeave)&&r.add(s),s=s.parentNode}for(const e of o)r.has(e)||(o.delete(e),e.parentNode&&e._eventHandlers?.onMouseLeave?.());for(const e of r)o.has(e)||(o.add(e),e._eventHandlers?.onMouseEnter?.())}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t,useEffect as e,useState as o}from"react";import{ClockContext as n}from"../components/ClockContext.js";import{useTerminalViewport as r}from"./use-terminal-viewport.js";export function useAnimationFrame(s=16){const i=t(n),[u,{isVisible:a}]=r(),[m,c]=o(()=>i?.now()??0),l=a&&null!==s;return e(()=>{if(!i||!l)return;let t=i.now();return i.subscribe(()=>{const e=i.now();e-t>=s&&(t=e,c(e))},!0)},[i,s,l]),[u,m]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t}from"react";import o from"../components/AppContext.js";export default()=>t(o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as t,useLayoutEffect as e}from"react";import{useEventCallback as i}from"usehooks-ts";import
|
|
1
|
+
import{useEffect as t,useLayoutEffect as e}from"react";import{useEventCallback as i}from"usehooks-ts";import s from"./use-stdin.js";export default(r,n={})=>{const{setRawMode:o,internal_exitOnCtrlC:c,internal_eventEmitter:u}=s();e(()=>{if(!1!==n.isActive)return o(!0),()=>{o(!1)}},[n.isActive,o]);const a=i(t=>{if(!1===n.isActive)return;const{input:e,key:i}=t;"c"===e&&i.ctrl&&c||r(e,i,t)});t(()=>(u?.on("input",a),()=>{u?.removeListener("input",a)}),[u,a])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t,useEffect as n,useRef as e,useState as o}from"react";import{ClockContext as r}from"../components/ClockContext.js";export function useAnimationTimer(e){const s=t(r),[u,c]=o(()=>s?.now()??0);return n(()=>{if(!s)return;let t=s.now();return s.subscribe(()=>{const n=s.now();n-t>=e&&(t=n,c(n))},!1)},[s,e]),u}export function useInterval(o,s){const u=e(o);u.current=o;const c=t(r);n(()=>{if(!c||null===s)return;let t=c.now();return c.subscribe(()=>{const n=c.now();n-t>=s&&(t=n,u.current())},!1)},[c,s])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as e,useMemo as o,useSyncExternalStore as t}from"react";import c from"../components/StdinContext.js";import
|
|
1
|
+
import{useContext as e,useMemo as o,useSyncExternalStore as t}from"react";import c from"../components/StdinContext.js";import s from"../instances.js";import{shiftAnchor as n}from"../selection.js";export function useSelection(){e(c);const t=s.get(process.stdout);return o(()=>t?{copySelection:()=>t.copySelection(),copySelectionNoClear:()=>t.copySelectionNoClear(),clearSelection:()=>t.clearTextSelection(),hasSelection:()=>t.hasTextSelection(),getState:()=>t.selection,subscribe:e=>t.subscribeToSelectionChange(e),shiftAnchor:(e,o,c)=>n(t.selection,e,o,c),shiftSelection:(e,o,c)=>t.shiftSelectionForScroll(e,o,c),moveFocus:e=>t.moveSelectionFocus(e),captureScrolledRows:(e,o,c)=>t.captureScrolledRows(e,o,c),setSelectionBgColor:e=>t.setSelectionBgColor(e)}:{copySelection:()=>"",copySelectionNoClear:()=>"",clearSelection:()=>{},hasSelection:()=>!1,getState:()=>null,subscribe:()=>()=>{},shiftAnchor:()=>{},shiftSelection:()=>{},moveFocus:()=>{},captureScrolledRows:()=>{},setSelectionBgColor:()=>{}},[t])}const NO_SUBSCRIBE=()=>()=>{},ALWAYS_FALSE=()=>!1;export function useHasSelection(){e(c);const o=s.get(process.stdout);return t(o?o.subscribeToSelectionChange:NO_SUBSCRIBE,o?o.hasTextSelection:ALWAYS_FALSE)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t,useEffect as
|
|
1
|
+
import{useContext as t,useEffect as s,useRef as r}from"react";import{CLEAR_TAB_STATUS as a,supportsTabStatus as o,tabStatus as i,wrapForMultiplexer as u}from"../termio/osc.js";import{TerminalWriteContext as e}from"../useTerminalNotification.js";const rgb=(t,s,r)=>({type:"rgb",r:t,g:s,b:r}),n={idle:{indicator:rgb(0,215,95),status:"Idle",statusColor:rgb(136,136,136)},busy:{indicator:rgb(255,149,0),status:"Working…",statusColor:rgb(255,149,0)},waiting:{indicator:rgb(95,135,255),status:"Waiting",statusColor:rgb(95,135,255)}};export function useTabStatus(l){const c=t(e),f=r(null);s(()=>{if(null===l)return null!==f.current&&c&&o()&&c(u(a)),void(f.current=null);f.current=l,c&&o()&&c(u(i(n[l])))},[l,c])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as o}from"react";import
|
|
1
|
+
import{useContext as o}from"react";import e from"../components/TerminalFocusContext.js";export function useTerminalFocus(){const{isTerminalFocused:t}=o(e);return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t,useEffect as o}from"react";import r from"strip-ansi";import{OSC as s,osc as e}from"../termio/osc.js";import{TerminalWriteContext as i}from"../useTerminalNotification.js";export function useTerminalTitle(n){const m=t(i);o(()=>{if(null===n||!m)return;const t=r(n);"win32"===process.platform?process.title=t:m(e(s.SET_TITLE_AND_ICON,t))},[n,m])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as e,useContext as o,useLayoutEffect as t,useRef as r}from"react";import{TerminalSizeContext as s}from"../components/TerminalSizeContext.js";export function useTerminalViewport(){const n=o(s),a=r(null),i=r({isVisible:!0}),u=e(e=>{a.current=e},[]);return t(()=>{const e=a.current;if(!e?.yogaNode||!n)return;const o=e.yogaNode.getComputedHeight(),t=n.rows;let r=e.yogaNode.getComputedTop(),s=e.parentNode,u=e.yogaNode;for(;s;)s.yogaNode&&(r+=s.yogaNode.getComputedTop(),u=s.yogaNode),s.scrollTop&&(r-=s.scrollTop),s=s.parentNode;const c=u.getComputedHeight(),l=r+o,p=c>t?1:0,d=Math.max(0,c-t)+p,g=l>d&&r<d+t;g!==i.current.isVisible&&(i.current={isVisible:g})}),[u,i.current]}
|
package/dist/src/ink/ink.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import e from"auto-bind";import{closeSync as s,constants as i,openSync as o,readSync as r,writeSync as n}from"fs";import h from"lodash-es/noop.js";import a from"lodash-es/throttle.js";import{ConcurrentRoot as l}from"react-reconciler/constants.js";import{onExit as c}from"signal-exit";import{flushInteractionTime as d}from"../bootstrap/state.js";import{getYogaCounters as u}from"../native-ts/yoga-layout/index.js";import{logForDebugging as m}from"../utils/debug.js";import{logError as p}from"../utils/log.js";import{format as f}from"util";import{colorize as g}from"./colorize.js";import w from"./components/App.js";import{FRAME_INTERVAL_MS as y}from"./constants.js";import*as S from"./dom.js";import{KeyboardEvent as v}from"./events/keyboard-event.js";import{FocusManager as P}from"./focus.js";import{emptyFrame as C}from"./frame.js";import{dispatchClick as k,dispatchHover as F}from"./hit-test.js";import R from"./instances.js";import{LogUpdate as T}from"./log-update.js";import{nodeCache as b}from"./node-cache.js";import{optimize as A}from"./optimizer.js";import x from"./output.js";import N,{dispatcher as M,getLastCommitMs as j,getLastYogaMs as E,isDebugRepaintsEnabled as H,recordYogaMs as Y,resetProfileCounters as L}from"./reconciler.js";import $,{consumeFollowScroll as O,didLayoutShift as D}from"./render-node-to-output.js";import{applyPositionedHighlight as z,scanPositions as B}from"./render-to-screen.js";import U from"./renderer.js";import{CharPool as Q,cellAt as I,createScreen as W,HyperlinkPool as K,isEmptyCellAt as _,migrateScreenPools as q,StylePool as G}from"./screen.js";import{applySearchHighlight as J}from"./searchHighlight.js";import{applySelectionOverlay as X,captureScrolledRows as V,clearSelection as Z,createSelectionState as tt,extendSelection as et,findPlainTextUrlAt as st,getSelectedText as it,hasSelection as ot,moveFocus as rt,selectLineAt as nt,selectWordAt as ht,shiftAnchor as at,shiftSelection as lt,shiftSelectionForFollow as ct,startSelection as dt,updateSelection as ut}from"./selection.js";import{SYNC_OUTPUT_SUPPORTED as mt,supportsExtendedKeys as pt,writeDiffToTerminal as ft}from"./terminal.js";import{CURSOR_HOME as gt,cursorMove as wt,cursorPosition as yt,DISABLE_KITTY_KEYBOARD as St,DISABLE_MODIFY_OTHER_KEYS as vt,ENABLE_KITTY_KEYBOARD as Pt,ENABLE_MODIFY_OTHER_KEYS as Ct,ERASE_SCREEN as kt}from"./termio/csi.js";import{DBP as Ft,DFE as Rt,DISABLE_MOUSE_TRACKING as Tt,ENABLE_MOUSE_TRACKING as bt,ENTER_ALT_SCREEN as At,EXIT_ALT_SCREEN as xt,SHOW_CURSOR as Nt}from"./termio/dec.js";import{CLEAR_ITERM2_PROGRESS as Mt,CLEAR_TAB_STATUS as jt,setClipboard as Et,supportsTabStatus as Ht,wrapForMultiplexer as Yt}from"./termio/osc.js";import{TerminalWriteProvider as Lt}from"./useTerminalNotification.js";const $t=Object.freeze({x:0,y:0,visible:!1}),Ot=Object.freeze({type:"stdout",content:gt}),Dt=Object.freeze({type:"stdout",content:kt+gt});function makeAltScreenParkPatch(t){return Object.freeze({type:"stdout",content:yt(t,1)})}export default class Ink{options;log;terminal;scheduleRender;isUnmounted=!1;isPaused=!1;container;rootNode;focusManager;renderer;stylePool;charPool;hyperlinkPool;exitPromise;restoreConsole;restoreStderr;unsubscribeTTYHandlers;terminalColumns;terminalRows;currentNode=null;frontFrame;backFrame;lastPoolResetTime=performance.now();drainTimer=null;lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0};altScreenParkPatch;selection=tt();searchHighlightQuery="";searchPositions=null;selectionListeners=new Set;hoveredNodes=new Set;altScreenActive=!1;altScreenMouseTracking=!1;prevFrameContaminated=!1;needsEraseBeforePaint=!1;cursorDeclaration=null;displayCursor=null;constructor(t){this.options=t,e(this),this.options.patchConsole&&(this.restoreConsole=this.patchConsole(),this.restoreStderr=this.patchStderr()),this.terminal={stdout:t.stdout,stderr:t.stderr},this.terminalColumns=t.stdout.columns||80,this.terminalRows=t.stdout.rows||24,this.altScreenParkPatch=makeAltScreenParkPatch(this.terminalRows),this.stylePool=new G,this.charPool=new Q,this.hyperlinkPool=new K,this.frontFrame=C(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.log=new T({isTTY:t.stdout.isTTY||!1,stylePool:this.stylePool});this.scheduleRender=a(()=>queueMicrotask(this.onRender),y,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.unsubscribeExit=c(this.unmount,{alwaysLast:!1}),t.stdout.isTTY&&(t.stdout.on("resize",this.handleResize),process.on("SIGCONT",this.handleResume),this.unsubscribeTTYHandlers=()=>{t.stdout.off("resize",this.handleResize),process.off("SIGCONT",this.handleResume)}),this.rootNode=S.createNode("ink-root"),this.focusManager=new P((t,e)=>M.dispatchDiscrete(t,e)),this.rootNode.focusManager=this.focusManager,this.renderer=U(this.rootNode,this.stylePool),this.rootNode.onRender=this.scheduleRender,this.rootNode.onImmediateRender=this.onRender,this.rootNode.onComputeLayout=()=>{if(!this.isUnmounted&&this.rootNode.yogaNode){const t=performance.now();this.rootNode.yogaNode.setWidth(this.terminalColumns),this.rootNode.yogaNode.calculateLayout(this.terminalColumns);const e=performance.now()-t;Y(e);const s=u();this.lastYogaCounters={ms:e,...s}}},this.container=N.createContainer(this.rootNode,l,null,!1,null,"id",h,h,h,h)}handleResume=()=>{this.options.stdout.isTTY&&(this.altScreenActive?this.reenterAltScreen():(this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null))};handleResize=()=>{const t=this.options.stdout.columns||80,e=this.options.stdout.rows||24;t===this.terminalColumns&&e===this.terminalRows||(this.terminalColumns=t,this.terminalRows=e,this.altScreenParkPatch=makeAltScreenParkPatch(this.terminalRows),this.altScreenActive&&!this.isPaused&&this.options.stdout.isTTY&&(this.altScreenMouseTracking&&this.options.stdout.write(bt),this.resetFramesForAltScreen(),this.needsEraseBeforePaint=!0),null!==this.currentNode&&this.render(this.currentNode))};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};enterAlternateScreen(){this.pause(),this.suspendStdin(),this.options.stdout.write(St+vt+(this.altScreenMouseTracking?Tt:"")+(this.altScreenActive?"":"[?1049h")+"[?1004l[0m[?25h[2J[H")}exitAlternateScreen(){this.options.stdout.write((this.altScreenActive?At:"")+"[2J[H"+(this.altScreenMouseTracking?bt:"")+(this.altScreenActive?"":"[?1049l")+"[?25l"),this.resumeStdin(),this.altScreenActive?this.resetFramesForAltScreen():this.repaint(),this.resume(),this.options.stdout.write("[?1004h"+(pt()?St+Pt+Ct:""))}onRender(){if(this.isUnmounted||this.isPaused)return;null!==this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),d();const t=performance.now(),e=this.options.stdout.columns||80,s=this.options.stdout.rows||24,i=this.renderer({frontFrame:this.frontFrame,backFrame:this.backFrame,isTTY:this.options.stdout.isTTY,terminalWidth:e,terminalRows:s,altScreen:this.altScreenActive,prevFrameContaminated:this.prevFrameContaminated}),o=performance.now()-t,r=O();if(r&&this.selection.anchor&&this.selection.anchor.row>=r.viewportTop&&this.selection.anchor.row<=r.viewportBottom){const{delta:t,viewportTop:e,viewportBottom:s}=r;if(this.selection.isDragging)ot(this.selection)&&V(this.selection,this.frontFrame.screen,e,e+t-1,"above"),at(this.selection,-t,e,s);else if(!this.selection.focus||this.selection.focus.row>=e&&this.selection.focus.row<=s){ot(this.selection)&&V(this.selection,this.frontFrame.screen,e,e+t-1,"above");if(ct(this.selection,-t,e,s))for(const t of this.selectionListeners)t()}}let n=!1,h=!1;if(this.altScreenActive&&(n=ot(this.selection),n&&X(i.screen,this.selection,this.stylePool),h=J(i.screen,this.searchHighlightQuery,this.stylePool),this.searchPositions)){const t=this.searchPositions,e=z(i.screen,this.stylePool,t.positions,t.rowOffset,t.currentIdx);h=h||e}(D()||n||h||this.prevFrameContaminated)&&(i.screen.damage={x:0,y:0,width:i.screen.width,height:i.screen.height});let a=this.frontFrame;this.altScreenActive&&(a={...this.frontFrame,cursor:$t});const l=performance.now(),c=this.log.render(a,i,this.altScreenActive,mt),u=performance.now()-l;this.backFrame=this.frontFrame,this.frontFrame=i,t-this.lastPoolResetTime>3e5&&(this.resetPools(),this.lastPoolResetTime=t);const p=[];for(const t of c)if("clearTerminal"===t.type&&(p.push({desiredHeight:i.screen.height,availableHeight:i.viewport.height,reason:t.reason}),H()&&t.debug)){const e=S.findOwnerChainAtRow(this.rootNode,t.debug.triggerY);m(`[REPAINT] full reset · ${t.reason} · row ${t.debug.triggerY}\n prev: "${t.debug.prevLine}"\n next: "${t.debug.nextLine}"\n culprit: ${e.length?e.join(" < "):"(no owner chain captured)"}`,{level:"warn"})}const f=performance.now(),g=A(c),w=performance.now()-f,v=g.length>0;this.altScreenActive&&v&&(this.needsEraseBeforePaint?(this.needsEraseBeforePaint=!1,g.unshift(Dt)):g.unshift(Ot),g.push(this.altScreenParkPatch));const P=this.cursorDeclaration,C=null!==P?b.get(P.node):void 0,k=null!==P&&void 0!==C?{x:C.x+P.relativeX,y:C.y+P.relativeY}:null,F=this.displayCursor,R=null!==k&&(null===F||F.x!==k.x||F.y!==k.y);if(v||R||null===k&&null!==F){if(null!==F&&!this.altScreenActive&&v){const t=a.cursor.x-F.x,e=a.cursor.y-F.y;0===t&&0===e||g.unshift({type:"stdout",content:wt(t,e)})}if(null!==k){if(this.altScreenActive){const t=Math.min(Math.max(k.y+1,1),s),i=Math.min(Math.max(k.x+1,1),e);g.push({type:"stdout",content:yt(t,i)})}else{const t=v||null===F?{x:i.cursor.x,y:i.cursor.y}:F,e=k.x-t.x,s=k.y-t.y;0===e&&0===s||g.push({type:"stdout",content:wt(e,s)})}this.displayCursor=k}else{if(null!==F&&!this.altScreenActive&&!v){const t=i.cursor.x-F.x,e=i.cursor.y-F.y;0===t&&0===e||g.push({type:"stdout",content:wt(t,e)})}this.displayCursor=null}}const T=performance.now();ft(this.terminal,g,this.altScreenActive&&!mt);const x=performance.now()-T;this.prevFrameContaminated=n||h,i.scrollDrainPending&&(this.drainTimer=setTimeout(()=>this.onRender(),y>>2));const N=E(),M=j(),Y=this.lastYogaCounters;L(),this.lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0},this.options.onFrame?.({durationMs:performance.now()-t,phases:{renderer:o,diff:u,optimize:w,write:x,patches:c.length,yoga:N,commit:M,yogaVisited:Y.visited,yogaMeasured:Y.measured,yogaCacheHits:Y.cacheHits,yogaLive:Y.live},flickers:p})}pause(){N.flushSyncFromReconciler(),this.onRender(),this.isPaused=!0}resume(){this.isPaused=!1,this.onRender()}repaint(){this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null}forceRedraw(){!this.options.stdout.isTTY||this.isUnmounted||this.isPaused||(this.options.stdout.write(kt+gt),this.altScreenActive?this.resetFramesForAltScreen():(this.repaint(),this.prevFrameContaminated=!0),this.onRender())}invalidatePrevFrame(){this.prevFrameContaminated=!0}setAltScreenActive(t,e=!1){this.altScreenActive!==t&&(this.altScreenActive=t,this.altScreenMouseTracking=t&&e,t?this.resetFramesForAltScreen():this.repaint())}get isAltScreenActive(){return this.altScreenActive}reassertTerminalModes=(t=!1)=>{this.options.stdout.isTTY&&(this.isPaused||(pt()&&this.options.stdout.write(St+Pt+Ct),this.altScreenActive&&(this.altScreenMouseTracking&&this.options.stdout.write(bt),t&&this.reenterAltScreen())))};detachForShutdown(){this.isUnmounted=!0,this.scheduleRender.cancel?.();const t=this.options.stdin;this.drainStdin(),t.isTTY&&t.isRaw&&t.setRawMode&&t.setRawMode(!1)}drainStdin(){drainStdin(this.options.stdin)}reenterAltScreen(){this.options.stdout.write(At+kt+gt+(this.altScreenMouseTracking?bt:"")),this.resetFramesForAltScreen()}resetFramesForAltScreen(){const t=this.terminalRows,e=this.terminalColumns,blank=()=>({screen:W(e,t,this.stylePool,this.charPool,this.hyperlinkPool),viewport:{width:e,height:t+1},cursor:{x:0,y:0,visible:!0}});this.frontFrame=blank(),this.backFrame=blank(),this.log.reset(),this.displayCursor=null,this.prevFrameContaminated=!0}copySelectionNoClear(){if(!ot(this.selection))return"";const t=it(this.selection,this.frontFrame.screen);return t&&Et(t).then(t=>{t&&this.options.stdout.write(t)}),t}copySelection(){if(!ot(this.selection))return"";const t=this.copySelectionNoClear();return Z(this.selection),this.notifySelectionChange(),t}clearTextSelection(){ot(this.selection)&&(Z(this.selection),this.notifySelectionChange())}setSearchHighlight(t){this.searchHighlightQuery!==t&&(this.searchHighlightQuery=t,this.scheduleRender())}scanElementSubtree(t){if(!this.searchHighlightQuery||!t.yogaNode)return[];const e=Math.ceil(t.yogaNode.getComputedWidth()),s=Math.ceil(t.yogaNode.getComputedHeight());if(e<=0||s<=0)return[];const i=t.yogaNode.getComputedLeft(),o=t.yogaNode.getComputedTop(),r=W(e,s,this.stylePool,this.charPool,this.hyperlinkPool),n=new x({width:e,height:s,stylePool:this.stylePool,screen:r});$(t,n,{offsetX:-i,offsetY:-o,prevScreen:void 0});const h=n.get();S.markDirty(t);const a=B(h,this.searchHighlightQuery);return m(`scanElementSubtree: q='${this.searchHighlightQuery}' el=${e}x${s}@(${i},${o}) n=${a.length} [${a.slice(0,10).map(t=>`${t.row}:${t.col}`).join(",")}`+(a.length>10?",…":"")+"]"),a}setSearchPositions(t){this.searchPositions=t,this.scheduleRender()}setSelectionBgColor(t){const e=g("\0",t,"background"),s=e.indexOf("\0");s<=0||s===e.length-1?this.stylePool.setSelectionBg(null):this.stylePool.setSelectionBg({type:"ansi",code:e.slice(0,s),endCode:e.slice(s+1)})}captureScrolledRows(t,e,s){V(this.selection,this.frontFrame.screen,t,e,s)}shiftSelectionForScroll(t,e,s){const i=ot(this.selection);lt(this.selection,t,e,s,this.frontFrame.screen.width),i&&!ot(this.selection)&&this.notifySelectionChange()}moveSelectionFocus(t){if(!this.altScreenActive)return;const{focus:e}=this.selection;if(!e)return;const{width:s,height:i}=this.frontFrame.screen,o=s-1,r=i-1;let{col:n,row:h}=e;switch(t){case"left":n>0?n--:h>0&&(n=o,h--);break;case"right":n<o?n++:h<r&&(n=0,h++);break;case"up":h>0&&h--;break;case"down":h<r&&h++;break;case"lineStart":n=0;break;case"lineEnd":n=o}n===e.col&&h===e.row||(rt(this.selection,n,h),this.notifySelectionChange())}hasTextSelection(){return ot(this.selection)}subscribeToSelectionChange(t){return this.selectionListeners.add(t),()=>this.selectionListeners.delete(t)}notifySelectionChange(){this.onRender();for(const t of this.selectionListeners)t()}dispatchClick(t,e){if(!this.altScreenActive)return!1;const s=_(this.frontFrame.screen,t,e);return k(this.rootNode,t,e,s)}dispatchHover(t,e){this.altScreenActive&&F(this.rootNode,t,e,this.hoveredNodes)}dispatchKeyboardEvent(t){const e=this.focusManager.activeElement??this.rootNode,s=new v(t);M.dispatchDiscrete(e,s),s.defaultPrevented||"tab"!==t.name||t.ctrl||t.meta||(t.shift?this.focusManager.focusPrevious(this.rootNode):this.focusManager.focusNext(this.rootNode))}getHyperlinkAt(t,e){if(!this.altScreenActive)return;const s=this.frontFrame.screen,i=I(s,t,e);let o=i?.hyperlink;return!o&&2===i?.width&&t>0&&(o=I(s,t-1,e)?.hyperlink),o??st(s,t,e)}onHyperlinkClick;openHyperlink(t){this.onHyperlinkClick?.(t)}handleMultiClick(t,e,s){if(!this.altScreenActive)return;const i=this.frontFrame.screen;dt(this.selection,t,e),2===s?ht(this.selection,i,t,e):nt(this.selection,i,e),this.selection.focus||(this.selection.focus=this.selection.anchor),this.notifySelectionChange()}handleSelectionDrag(t,e){if(!this.altScreenActive)return;const s=this.selection;s.anchorSpan?et(s,this.frontFrame.screen,t,e):ut(s,t,e),this.notifySelectionChange()}stdinListeners=[];wasRawMode=!1;suspendStdin(){const t=this.options.stdin;if(!t.isTTY)return;const e=t.listeners("readable");m(`[stdin] suspendStdin: removing ${e.length} readable listener(s), wasRawMode=${t.isRaw??!1}`),e.forEach(e=>{this.stdinListeners.push({event:"readable",listener:e}),t.removeListener("readable",e)});const s=t;s.isRaw&&s.setRawMode&&(s.setRawMode(!1),this.wasRawMode=!0)}resumeStdin(){const t=this.options.stdin;if(t.isTTY&&(0!==this.stdinListeners.length||this.wasRawMode||m("[stdin] resumeStdin: called with no stored listeners and wasRawMode=false (possible desync)",{level:"warn"}),m(`[stdin] resumeStdin: re-attaching ${this.stdinListeners.length} listener(s), wasRawMode=${this.wasRawMode}`),this.stdinListeners.forEach(({event:e,listener:s})=>{t.addListener(e,s)}),this.stdinListeners=[],this.wasRawMode)){const e=t;e.setRawMode&&e.setRawMode(!0),this.wasRawMode=!1}}writeRaw(t){this.options.stdout.write(t)}setCursorDeclaration=(t,e)=>{null===t&&void 0!==e&&this.cursorDeclaration?.node!==e||(this.cursorDeclaration=t)};render(e){this.currentNode=e;const s=t(w,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount,terminalColumns:this.terminalColumns,terminalRows:this.terminalRows,selection:this.selection,onSelectionChange:this.notifySelectionChange,onClickAt:this.dispatchClick,onHoverAt:this.dispatchHover,getHyperlinkAt:this.getHyperlinkAt,onOpenHyperlink:this.openHyperlink,onMultiClick:this.handleMultiClick,onSelectionDrag:this.handleSelectionDrag,onStdinResume:this.reassertTerminalModes,onCursorDeclaration:this.setCursorDeclaration,dispatchKeyboardEvent:this.dispatchKeyboardEvent,children:t(Lt,{value:this.writeRaw,children:e})});N.updateContainerSync(s,this.container,null,h),N.flushSyncWork()}unmount(t){if(this.isUnmounted)return;this.onRender(),this.unsubscribeExit(),"function"==typeof this.restoreConsole&&this.restoreConsole(),this.restoreStderr?.(),this.unsubscribeTTYHandlers?.();const e=this.log.renderPreviousOutput_DEPRECATED(this.frontFrame);ft(this.terminal,A(e)),this.options.stdout.isTTY&&(this.altScreenActive&&n(1,xt),n(1,Tt),this.drainStdin(),n(1,vt),n(1,St),n(1,Rt),n(1,Ft),n(1,Nt),n(1,Mt),Ht()&&n(1,Yt(jt))),this.isUnmounted=!0,this.scheduleRender.cancel?.(),null!==this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),N.updateContainerSync(null,this.container,null,h),N.flushSyncWork(),R.delete(this.options.stdout),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,t instanceof Error?this.rejectExitPromise(t):this.resolveExitPromise()}async waitUntilExit(){return this.exitPromise||=new Promise((t,e)=>{this.resolveExitPromise=t,this.rejectExitPromise=e}),this.exitPromise}resetLineCount(){this.options.stdout.isTTY&&(this.backFrame=this.frontFrame,this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null)}resetPools(){this.charPool=new Q,this.hyperlinkPool=new K,q(this.frontFrame.screen,this.charPool,this.hyperlinkPool),this.backFrame.screen.charPool=this.charPool,this.backFrame.screen.hyperlinkPool=this.hyperlinkPool}patchConsole(){const t=console,e={},toDebug=(...t)=>m(`console.log: ${f(...t)}`),toError=(...t)=>p(new Error(`console.error: ${f(...t)}`));for(const s of zt)e[s]=t[s],t[s]=toDebug;for(const s of Bt)e[s]=t[s],t[s]=toError;return e.assert=t.assert,t.assert=(t,...e)=>{t||toError(...e)},()=>Object.assign(t,e)}patchStderr(){const t=process.stderr,e=t.write;let s=!1;const intercept=(i,o,r)=>{const n="function"==typeof o?o:r;if(s){const s="string"==typeof o?o:void 0;return e.call(t,i,s,n)}s=!0;try{const t="string"==typeof i?i:Buffer.from(i).toString("utf8");m(`[stderr] ${t}`,{level:"warn"}),!this.altScreenActive||this.isUnmounted||this.isPaused||(this.prevFrameContaminated=!0,this.scheduleRender())}finally{s=!1,n?.()}return!0};return t.write=intercept,()=>{t.write===intercept&&(t.write=e)}}}export function drainStdin(t=process.stdin){if(!t.isTTY)return;try{for(;null!==t.read(););}catch{}if("win32"===process.platform)return;const e=t,n=!0===e.isRaw;let h=-1;try{n||e.setRawMode?.(!0),h=o("/dev/tty",i.O_RDONLY|i.O_NONBLOCK);const t=Buffer.alloc(1024);for(let e=0;e<64&&!(r(h,t,0,t.length,null)<=0);e++);}catch{}finally{if(h>=0)try{s(h)}catch{}if(!n)try{e.setRawMode?.(!1)}catch{}}}const zt=["log","info","debug","dir","dirxml","count","countReset","group","groupCollapsed","groupEnd","table","time","timeEnd","timeLog"],Bt=["warn","error","trace"];
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"auto-bind";import{closeSync as s,constants as i,openSync as o,readSync as r,writeSync as n}from"fs";import a from"lodash-es/noop.js";import h from"lodash-es/throttle.js";import{ConcurrentRoot as l}from"react-reconciler/constants.js";import{onExit as c}from"signal-exit";import{flushInteractionTime as d}from"src/bootstrap/state.js";import{getYogaCounters as u}from"src/native-ts/yoga-layout/index.js";import{logForDebugging as m}from"src/utils/debug.js";import{logError as p}from"src/utils/log.js";import{format as f}from"util";import{colorize as g}from"./colorize.js";import S from"./components/App.js";import{FRAME_INTERVAL_MS as y}from"./constants.js";import*as w from"./dom.js";import{KeyboardEvent as P}from"./events/keyboard-event.js";import{FocusManager as v}from"./focus.js";import{emptyFrame as C}from"./frame.js";import{dispatchClick as R,dispatchHover as T}from"./hit-test.js";import F from"./instances.js";import{LogUpdate as k}from"./log-update.js";import{nodeCache as A}from"./node-cache.js";import{optimize as E}from"./optimizer.js";import b from"./output.js";import M,{dispatcher as N,getLastCommitMs as x,getLastYogaMs as j,isDebugRepaintsEnabled as H,recordYogaMs as L,resetProfileCounters as Y}from"./reconciler.js";import O,{consumeFollowScroll as _,didLayoutShift as D}from"./render-node-to-output.js";import{applyPositionedHighlight as B,scanPositions as $}from"./render-to-screen.js";import U from"./renderer.js";import{CharPool as I,cellAt as z,createScreen as K,HyperlinkPool as W,isEmptyCellAt as Q,migrateScreenPools as G,StylePool as X}from"./screen.js";import{applySearchHighlight as q}from"./searchHighlight.js";import{applySelectionOverlay as J,captureScrolledRows as V,clearSelection as Z,createSelectionState as ee,extendSelection as te,findPlainTextUrlAt as se,getSelectedText as ie,hasSelection as oe,moveFocus as re,selectLineAt as ne,selectWordAt as ae,shiftAnchor as he,shiftSelection as le,shiftSelectionForFollow as ce,startSelection as de,updateSelection as ue}from"./selection.js";import{SYNC_OUTPUT_SUPPORTED as me,supportsExtendedKeys as pe,writeDiffToTerminal as fe}from"./terminal.js";import{CURSOR_HOME as ge,cursorMove as Se,cursorPosition as ye,DISABLE_KITTY_KEYBOARD as we,DISABLE_MODIFY_OTHER_KEYS as Pe,ENABLE_KITTY_KEYBOARD as ve,ENABLE_MODIFY_OTHER_KEYS as Ce,ERASE_SCREEN as Re}from"./termio/csi.js";import{DBP as Te,DFE as Fe,DISABLE_MOUSE_TRACKING as ke,ENABLE_MOUSE_TRACKING as Ae,ENTER_ALT_SCREEN as Ee,EXIT_ALT_SCREEN as be,SHOW_CURSOR as Me}from"./termio/dec.js";import{CLEAR_ITERM2_PROGRESS as Ne,CLEAR_TAB_STATUS as xe,setClipboard as je,supportsTabStatus as He,wrapForMultiplexer as Le}from"./termio/osc.js";import{TerminalWriteProvider as Ye}from"./useTerminalNotification.js";const Oe=Object.freeze({x:0,y:0,visible:!1}),_e=Object.freeze({type:"stdout",content:ge}),De=Object.freeze({type:"stdout",content:Re+ge});function makeAltScreenParkPatch(e){return Object.freeze({type:"stdout",content:ye(e,1)})}export default class Ink{options;log;terminal;scheduleRender;isUnmounted=!1;isPaused=!1;container;rootNode;focusManager;renderer;stylePool;charPool;hyperlinkPool;exitPromise;restoreConsole;restoreStderr;unsubscribeTTYHandlers;terminalColumns;terminalRows;currentNode=null;frontFrame;backFrame;lastPoolResetTime=performance.now();drainTimer=null;lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0};altScreenParkPatch;selection=ee();searchHighlightQuery="";searchPositions=null;selectionListeners=new Set;hoveredNodes=new Set;altScreenActive=!1;altScreenMouseTracking=!1;prevFrameContaminated=!1;needsEraseBeforePaint=!1;cursorDeclaration=null;displayCursor=null;constructor(e){this.options=e,t(this),this.options.patchConsole&&(this.restoreConsole=this.patchConsole(),this.restoreStderr=this.patchStderr()),this.terminal={stdout:e.stdout,stderr:e.stderr},this.terminalColumns=e.stdout.columns||80,this.terminalRows=e.stdout.rows||24,this.altScreenParkPatch=makeAltScreenParkPatch(this.terminalRows),this.stylePool=new X,this.charPool=new I,this.hyperlinkPool=new W,this.frontFrame=C(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.log=new k({isTTY:e.stdout.isTTY||!1,stylePool:this.stylePool}),this.scheduleRender=h(()=>queueMicrotask(this.onRender),y,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.unsubscribeExit=c(this.unmount,{alwaysLast:!1}),e.stdout.isTTY&&(e.stdout.on("resize",this.handleResize),process.on("SIGCONT",this.handleResume),this.unsubscribeTTYHandlers=()=>{e.stdout.off("resize",this.handleResize),process.off("SIGCONT",this.handleResume)}),this.rootNode=w.createNode("ink-root"),this.focusManager=new v((e,t)=>N.dispatchDiscrete(e,t)),this.rootNode.focusManager=this.focusManager,this.renderer=U(this.rootNode,this.stylePool),this.rootNode.onRender=this.scheduleRender,this.rootNode.onImmediateRender=this.onRender,this.rootNode.onComputeLayout=()=>{if(!this.isUnmounted&&this.rootNode.yogaNode){const e=performance.now();this.rootNode.yogaNode.setWidth(this.terminalColumns),this.rootNode.yogaNode.calculateLayout(this.terminalColumns);const t=performance.now()-e;L(t);const s=u();this.lastYogaCounters={ms:t,...s}}},this.container=M.createContainer(this.rootNode,l,null,!1,null,"id",a,a,a,a)}handleResume=()=>{this.options.stdout.isTTY&&(this.altScreenActive?this.reenterAltScreen():(this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null))};handleResize=()=>{const e=this.options.stdout.columns||80,t=this.options.stdout.rows||24;e===this.terminalColumns&&t===this.terminalRows||(this.terminalColumns=e,this.terminalRows=t,this.altScreenParkPatch=makeAltScreenParkPatch(this.terminalRows),this.altScreenActive&&!this.isPaused&&this.options.stdout.isTTY&&(this.altScreenMouseTracking&&this.options.stdout.write(Ae),this.resetFramesForAltScreen(),this.needsEraseBeforePaint=!0),null!==this.currentNode&&this.render(this.currentNode))};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};enterAlternateScreen(){this.pause(),this.suspendStdin(),this.options.stdout.write(we+Pe+(this.altScreenMouseTracking?ke:"")+(this.altScreenActive?"":"[?1049h")+"[?1004l[0m[?25h[2J[H")}exitAlternateScreen(){this.options.stdout.write((this.altScreenActive?Ee:"")+"[2J[H"+(this.altScreenMouseTracking?Ae:"")+(this.altScreenActive?"":"[?1049l")+"[?25l"),this.resumeStdin(),this.altScreenActive?this.resetFramesForAltScreen():this.repaint(),this.resume(),this.options.stdout.write("[?1004h"+(pe()?we+ve+Ce:""))}onRender(){if(this.isUnmounted||this.isPaused)return;null!==this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),d();const e=performance.now(),t=this.options.stdout.columns||80,s=this.options.stdout.rows||24,i=this.renderer({frontFrame:this.frontFrame,backFrame:this.backFrame,isTTY:this.options.stdout.isTTY,terminalWidth:t,terminalRows:s,altScreen:this.altScreenActive,prevFrameContaminated:this.prevFrameContaminated}),o=performance.now()-e,r=_();if(r&&this.selection.anchor&&this.selection.anchor.row>=r.viewportTop&&this.selection.anchor.row<=r.viewportBottom){const{delta:e,viewportTop:t,viewportBottom:s}=r;if(this.selection.isDragging)oe(this.selection)&&V(this.selection,this.frontFrame.screen,t,t+e-1,"above"),he(this.selection,-e,t,s);else if((!this.selection.focus||this.selection.focus.row>=t&&this.selection.focus.row<=s)&&(oe(this.selection)&&V(this.selection,this.frontFrame.screen,t,t+e-1,"above"),ce(this.selection,-e,t,s)))for(const e of this.selectionListeners)e()}let n=!1,a=!1;if(this.altScreenActive&&(n=oe(this.selection),n&&J(i.screen,this.selection,this.stylePool),a=q(i.screen,this.searchHighlightQuery,this.stylePool),this.searchPositions)){const e=this.searchPositions,t=B(i.screen,this.stylePool,e.positions,e.rowOffset,e.currentIdx);a=a||t}(D()||n||a||this.prevFrameContaminated)&&(i.screen.damage={x:0,y:0,width:i.screen.width,height:i.screen.height});let h=this.frontFrame;this.altScreenActive&&(h={...this.frontFrame,cursor:Oe});const l=performance.now(),c=this.log.render(h,i,this.altScreenActive,me),u=performance.now()-l;this.backFrame=this.frontFrame,this.frontFrame=i,e-this.lastPoolResetTime>3e5&&(this.resetPools(),this.lastPoolResetTime=e);const p=[];for(const e of c)if("clearTerminal"===e.type&&(p.push({desiredHeight:i.screen.height,availableHeight:i.viewport.height,reason:e.reason}),H()&&e.debug)){const t=w.findOwnerChainAtRow(this.rootNode,e.debug.triggerY);m(`[REPAINT] full reset · ${e.reason} · row ${e.debug.triggerY}\n prev: "${e.debug.prevLine}"\n next: "${e.debug.nextLine}"\n culprit: ${t.length?t.join(" < "):"(no owner chain captured)"}`,{level:"warn"})}const f=performance.now(),g=E(c),S=performance.now()-f,P=g.length>0;this.altScreenActive&&P&&(this.needsEraseBeforePaint?(this.needsEraseBeforePaint=!1,g.unshift(De)):g.unshift(_e),g.push(this.altScreenParkPatch));const v=this.cursorDeclaration,C=null!==v?A.get(v.node):void 0,R=null!==v&&void 0!==C?{x:C.x+v.relativeX,y:C.y+v.relativeY}:null,T=this.displayCursor,F=null!==R&&(null===T||T.x!==R.x||T.y!==R.y);if(P||F||null===R&&null!==T){if(null!==T&&!this.altScreenActive&&P){const e=h.cursor.x-T.x,t=h.cursor.y-T.y;0===e&&0===t||g.unshift({type:"stdout",content:Se(e,t)})}if(null!==R){if(this.altScreenActive){const e=Math.min(Math.max(R.y+1,1),s),i=Math.min(Math.max(R.x+1,1),t);g.push({type:"stdout",content:ye(e,i)})}else{const e=P||null===T?{x:i.cursor.x,y:i.cursor.y}:T,t=R.x-e.x,s=R.y-e.y;0===t&&0===s||g.push({type:"stdout",content:Se(t,s)})}this.displayCursor=R}else{if(null!==T&&!this.altScreenActive&&!P){const e=i.cursor.x-T.x,t=i.cursor.y-T.y;0===e&&0===t||g.push({type:"stdout",content:Se(e,t)})}this.displayCursor=null}}const k=performance.now();fe(this.terminal,g,this.altScreenActive&&!me);const b=performance.now()-k;this.prevFrameContaminated=n||a,i.scrollDrainPending&&(this.drainTimer=setTimeout(()=>this.onRender(),y>>2));const M=j(),N=x(),L=this.lastYogaCounters;Y(),this.lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0},this.options.onFrame?.({durationMs:performance.now()-e,phases:{renderer:o,diff:u,optimize:S,write:b,patches:c.length,yoga:M,commit:N,yogaVisited:L.visited,yogaMeasured:L.measured,yogaCacheHits:L.cacheHits,yogaLive:L.live},flickers:p})}pause(){M.flushSyncFromReconciler(),this.onRender(),this.isPaused=!0}resume(){this.isPaused=!1,this.onRender()}repaint(){this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=C(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null}forceRedraw(){!this.options.stdout.isTTY||this.isUnmounted||this.isPaused||(this.options.stdout.write(Re+ge),this.altScreenActive?this.resetFramesForAltScreen():(this.repaint(),this.prevFrameContaminated=!0),this.onRender())}invalidatePrevFrame(){this.prevFrameContaminated=!0}setAltScreenActive(e,t=!1){this.altScreenActive!==e&&(this.altScreenActive=e,this.altScreenMouseTracking=e&&t,e?this.resetFramesForAltScreen():this.repaint())}get isAltScreenActive(){return this.altScreenActive}reassertTerminalModes=(e=!1)=>{this.options.stdout.isTTY&&(this.isPaused||(pe()&&this.options.stdout.write(we+ve+Ce),this.altScreenActive&&(this.altScreenMouseTracking&&this.options.stdout.write(Ae),e&&this.reenterAltScreen())))};detachForShutdown(){this.isUnmounted=!0,this.scheduleRender.cancel?.();const e=this.options.stdin;this.drainStdin(),e.isTTY&&e.isRaw&&e.setRawMode&&e.setRawMode(!1)}drainStdin(){drainStdin(this.options.stdin)}reenterAltScreen(){this.options.stdout.write(Ee+Re+ge+(this.altScreenMouseTracking?Ae:"")),this.resetFramesForAltScreen()}resetFramesForAltScreen(){const e=this.terminalRows,t=this.terminalColumns,blank=()=>({screen:K(t,e,this.stylePool,this.charPool,this.hyperlinkPool),viewport:{width:t,height:e+1},cursor:{x:0,y:0,visible:!0}});this.frontFrame=blank(),this.backFrame=blank(),this.log.reset(),this.displayCursor=null,this.prevFrameContaminated=!0}copySelectionNoClear(){if(!oe(this.selection))return"";const e=ie(this.selection,this.frontFrame.screen);return e&&je(e).then(e=>{e&&this.options.stdout.write(e)}),e}copySelection(){if(!oe(this.selection))return"";const e=this.copySelectionNoClear();return Z(this.selection),this.notifySelectionChange(),e}clearTextSelection(){oe(this.selection)&&(Z(this.selection),this.notifySelectionChange())}setSearchHighlight(e){this.searchHighlightQuery!==e&&(this.searchHighlightQuery=e,this.scheduleRender())}scanElementSubtree(e){if(!this.searchHighlightQuery||!e.yogaNode)return[];const t=Math.ceil(e.yogaNode.getComputedWidth()),s=Math.ceil(e.yogaNode.getComputedHeight());if(t<=0||s<=0)return[];const i=e.yogaNode.getComputedLeft(),o=e.yogaNode.getComputedTop(),r=K(t,s,this.stylePool,this.charPool,this.hyperlinkPool),n=new b({width:t,height:s,stylePool:this.stylePool,screen:r});O(e,n,{offsetX:-i,offsetY:-o,prevScreen:void 0});const a=n.get();w.markDirty(e);const h=$(a,this.searchHighlightQuery);return m(`scanElementSubtree: q='${this.searchHighlightQuery}' el=${t}x${s}@(${i},${o}) n=${h.length} [${h.slice(0,10).map(e=>`${e.row}:${e.col}`).join(",")}`+(h.length>10?",…":"")+"]"),h}setSearchPositions(e){this.searchPositions=e,this.scheduleRender()}setSelectionBgColor(e){const t=g("\0",e,"background"),s=t.indexOf("\0");s<=0||s===t.length-1?this.stylePool.setSelectionBg(null):this.stylePool.setSelectionBg({type:"ansi",code:t.slice(0,s),endCode:t.slice(s+1)})}captureScrolledRows(e,t,s){V(this.selection,this.frontFrame.screen,e,t,s)}shiftSelectionForScroll(e,t,s){const i=oe(this.selection);le(this.selection,e,t,s,this.frontFrame.screen.width),i&&!oe(this.selection)&&this.notifySelectionChange()}moveSelectionFocus(e){if(!this.altScreenActive)return;const{focus:t}=this.selection;if(!t)return;const{width:s,height:i}=this.frontFrame.screen,o=s-1,r=i-1;let{col:n,row:a}=t;switch(e){case"left":n>0?n--:a>0&&(n=o,a--);break;case"right":n<o?n++:a<r&&(n=0,a++);break;case"up":a>0&&a--;break;case"down":a<r&&a++;break;case"lineStart":n=0;break;case"lineEnd":n=o}n===t.col&&a===t.row||(re(this.selection,n,a),this.notifySelectionChange())}hasTextSelection(){return oe(this.selection)}subscribeToSelectionChange(e){return this.selectionListeners.add(e),()=>this.selectionListeners.delete(e)}notifySelectionChange(){this.onRender();for(const e of this.selectionListeners)e()}dispatchClick(e,t){if(!this.altScreenActive)return!1;const s=Q(this.frontFrame.screen,e,t);return R(this.rootNode,e,t,s)}dispatchHover(e,t){this.altScreenActive&&T(this.rootNode,e,t,this.hoveredNodes)}dispatchKeyboardEvent(e){const t=this.focusManager.activeElement??this.rootNode,s=new P(e);N.dispatchDiscrete(t,s),s.defaultPrevented||"tab"!==e.name||e.ctrl||e.meta||(e.shift?this.focusManager.focusPrevious(this.rootNode):this.focusManager.focusNext(this.rootNode))}getHyperlinkAt(e,t){if(!this.altScreenActive)return;const s=this.frontFrame.screen,i=z(s,e,t);let o=i?.hyperlink;return!o&&2===i?.width&&e>0&&(o=z(s,e-1,t)?.hyperlink),o??se(s,e,t)}onHyperlinkClick;openHyperlink(e){this.onHyperlinkClick?.(e)}handleMultiClick(e,t,s){if(!this.altScreenActive)return;const i=this.frontFrame.screen;de(this.selection,e,t),2===s?ae(this.selection,i,e,t):ne(this.selection,i,t),this.selection.focus||(this.selection.focus=this.selection.anchor),this.notifySelectionChange()}handleSelectionDrag(e,t){if(!this.altScreenActive)return;const s=this.selection;s.anchorSpan?te(s,this.frontFrame.screen,e,t):ue(s,e,t),this.notifySelectionChange()}stdinListeners=[];wasRawMode=!1;suspendStdin(){const e=this.options.stdin;if(!e.isTTY)return;const t=e.listeners("readable");m(`[stdin] suspendStdin: removing ${t.length} readable listener(s), wasRawMode=${e.isRaw??!1}`),t.forEach(t=>{this.stdinListeners.push({event:"readable",listener:t}),e.removeListener("readable",t)});const s=e;s.isRaw&&s.setRawMode&&(s.setRawMode(!1),this.wasRawMode=!0)}resumeStdin(){const e=this.options.stdin;if(e.isTTY&&(0!==this.stdinListeners.length||this.wasRawMode||m("[stdin] resumeStdin: called with no stored listeners and wasRawMode=false (possible desync)",{level:"warn"}),m(`[stdin] resumeStdin: re-attaching ${this.stdinListeners.length} listener(s), wasRawMode=${this.wasRawMode}`),this.stdinListeners.forEach(({event:t,listener:s})=>{e.addListener(t,s)}),this.stdinListeners=[],this.wasRawMode)){const t=e;t.setRawMode&&t.setRawMode(!0),this.wasRawMode=!1}}writeRaw(e){this.options.stdout.write(e)}setCursorDeclaration=(e,t)=>{null===e&&void 0!==t&&this.cursorDeclaration?.node!==t||(this.cursorDeclaration=e)};render(t){this.currentNode=t;const s=e(S,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount,terminalColumns:this.terminalColumns,terminalRows:this.terminalRows,selection:this.selection,onSelectionChange:this.notifySelectionChange,onClickAt:this.dispatchClick,onHoverAt:this.dispatchHover,getHyperlinkAt:this.getHyperlinkAt,onOpenHyperlink:this.openHyperlink,onMultiClick:this.handleMultiClick,onSelectionDrag:this.handleSelectionDrag,onStdinResume:this.reassertTerminalModes,onCursorDeclaration:this.setCursorDeclaration,dispatchKeyboardEvent:this.dispatchKeyboardEvent,children:e(Ye,{value:this.writeRaw,children:t})});M.updateContainerSync(s,this.container,null,a),M.flushSyncWork()}unmount(e){if(this.isUnmounted)return;this.onRender(),this.unsubscribeExit(),"function"==typeof this.restoreConsole&&this.restoreConsole(),this.restoreStderr?.(),this.unsubscribeTTYHandlers?.();const t=this.log.renderPreviousOutput_DEPRECATED(this.frontFrame);fe(this.terminal,E(t)),this.options.stdout.isTTY&&(this.altScreenActive&&n(1,be),n(1,ke),this.drainStdin(),n(1,Pe),n(1,we),n(1,Fe),n(1,Te),n(1,Me),n(1,Ne),He()&&n(1,Le(xe))),this.isUnmounted=!0,this.scheduleRender.cancel?.(),null!==this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),M.updateContainerSync(null,this.container,null,a),M.flushSyncWork(),F.delete(this.options.stdout),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,e instanceof Error?this.rejectExitPromise(e):this.resolveExitPromise()}async waitUntilExit(){return this.exitPromise||=new Promise((e,t)=>{this.resolveExitPromise=e,this.rejectExitPromise=t}),this.exitPromise}resetLineCount(){this.options.stdout.isTTY&&(this.backFrame=this.frontFrame,this.frontFrame=C(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null)}resetPools(){this.charPool=new I,this.hyperlinkPool=new W,G(this.frontFrame.screen,this.charPool,this.hyperlinkPool),this.backFrame.screen.charPool=this.charPool,this.backFrame.screen.hyperlinkPool=this.hyperlinkPool}patchConsole(){const e=console,t={},toDebug=(...e)=>m(`console.log: ${f(...e)}`),toError=(...e)=>p(new Error(`console.error: ${f(...e)}`));for(const s of Be)t[s]=e[s],e[s]=toDebug;for(const s of $e)t[s]=e[s],e[s]=toError;return t.assert=e.assert,e.assert=(e,...t)=>{e||toError(...t)},()=>Object.assign(e,t)}patchStderr(){const e=process.stderr,t=e.write;let s=!1;const intercept=(i,o,r)=>{const n="function"==typeof o?o:r;if(s){const s="string"==typeof o?o:void 0;return t.call(e,i,s,n)}s=!0;try{const e="string"==typeof i?i:Buffer.from(i).toString("utf8");m(`[stderr] ${e}`,{level:"warn"}),!this.altScreenActive||this.isUnmounted||this.isPaused||(this.prevFrameContaminated=!0,this.scheduleRender())}finally{s=!1,n?.()}return!0};return e.write=intercept,()=>{e.write===intercept&&(e.write=t)}}}export function drainStdin(e=process.stdin){if(!e.isTTY)return;try{for(;null!==e.read(););}catch{}if("win32"===process.platform)return;const t=e,n=!0===t.isRaw;let a=-1;try{n||t.setRawMode?.(!0),a=o("/dev/tty",i.O_RDONLY|i.O_NONBLOCK);const e=Buffer.alloc(1024);for(let t=0;t<64&&!(r(a,e,0,e.length,null)<=0);t++);}catch{}finally{if(a>=0)try{s(a)}catch{}if(!n)try{t.setRawMode?.(!1)}catch{}}}const Be=["log","info","debug","dir","dirxml","count","countReset","group","groupCollapsed","groupEnd","table","time","timeEnd","timeLog"],$e=["warn","error","trace"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t,{Align as e,Direction as s,Display as o,Edge as i,FlexDirection as a,Gutter as r,Justify as n,MeasureMode as g,Overflow as h,PositionType as l,Wrap as y}from"
|
|
1
|
+
import t,{Align as e,Direction as s,Display as o,Edge as i,FlexDirection as a,Gutter as r,Justify as n,MeasureMode as g,Overflow as h,PositionType as l,Wrap as y}from"src/native-ts/yoga-layout/index.js";import{LayoutDisplay as u,LayoutMeasureMode as d}from"./node.js";const c={all:i.All,horizontal:i.Horizontal,vertical:i.Vertical,left:i.Left,right:i.Right,top:i.Top,bottom:i.Bottom,start:i.Start,end:i.End},p={all:r.All,column:r.Column,row:r.Row};export class YogaLayoutNode{yoga;constructor(t){this.yoga=t}insertChild(t,e){this.yoga.insertChild(t.yoga,e)}removeChild(t){this.yoga.removeChild(t.yoga)}getChildCount(){return this.yoga.getChildCount()}getParent(){const t=this.yoga.getParent();return t?new YogaLayoutNode(t):null}calculateLayout(t,e){this.yoga.calculateLayout(t,void 0,s.LTR)}setMeasureFunc(t){this.yoga.setMeasureFunc((e,s)=>{const o=s===g.Exactly?d.Exactly:s===g.AtMost?d.AtMost:d.Undefined;return t(e,o)})}unsetMeasureFunc(){this.yoga.unsetMeasureFunc()}markDirty(){this.yoga.markDirty()}getComputedLeft(){return this.yoga.getComputedLeft()}getComputedTop(){return this.yoga.getComputedTop()}getComputedWidth(){return this.yoga.getComputedWidth()}getComputedHeight(){return this.yoga.getComputedHeight()}getComputedBorder(t){return this.yoga.getComputedBorder(c[t])}getComputedPadding(t){return this.yoga.getComputedPadding(c[t])}setWidth(t){this.yoga.setWidth(t)}setWidthPercent(t){this.yoga.setWidthPercent(t)}setWidthAuto(){this.yoga.setWidthAuto()}setHeight(t){this.yoga.setHeight(t)}setHeightPercent(t){this.yoga.setHeightPercent(t)}setHeightAuto(){this.yoga.setHeightAuto()}setMinWidth(t){this.yoga.setMinWidth(t)}setMinWidthPercent(t){this.yoga.setMinWidthPercent(t)}setMinHeight(t){this.yoga.setMinHeight(t)}setMinHeightPercent(t){this.yoga.setMinHeightPercent(t)}setMaxWidth(t){this.yoga.setMaxWidth(t)}setMaxWidthPercent(t){this.yoga.setMaxWidthPercent(t)}setMaxHeight(t){this.yoga.setMaxHeight(t)}setMaxHeightPercent(t){this.yoga.setMaxHeightPercent(t)}setFlexDirection(t){const e={row:a.Row,"row-reverse":a.RowReverse,column:a.Column,"column-reverse":a.ColumnReverse};this.yoga.setFlexDirection(e[t])}setFlexGrow(t){this.yoga.setFlexGrow(t)}setFlexShrink(t){this.yoga.setFlexShrink(t)}setFlexBasis(t){this.yoga.setFlexBasis(t)}setFlexBasisPercent(t){this.yoga.setFlexBasisPercent(t)}setFlexWrap(t){const e={nowrap:y.NoWrap,wrap:y.Wrap,"wrap-reverse":y.WrapReverse};this.yoga.setFlexWrap(e[t])}setAlignItems(t){const s={auto:e.Auto,stretch:e.Stretch,"flex-start":e.FlexStart,center:e.Center,"flex-end":e.FlexEnd};this.yoga.setAlignItems(s[t])}setAlignSelf(t){const s={auto:e.Auto,stretch:e.Stretch,"flex-start":e.FlexStart,center:e.Center,"flex-end":e.FlexEnd};this.yoga.setAlignSelf(s[t])}setJustifyContent(t){const e={"flex-start":n.FlexStart,center:n.Center,"flex-end":n.FlexEnd,"space-between":n.SpaceBetween,"space-around":n.SpaceAround,"space-evenly":n.SpaceEvenly};this.yoga.setJustifyContent(e[t])}setDisplay(t){this.yoga.setDisplay("flex"===t?o.Flex:o.None)}getDisplay(){return this.yoga.getDisplay()===o.None?u.None:u.Flex}setPositionType(t){this.yoga.setPositionType("absolute"===t?l.Absolute:l.Relative)}setPosition(t,e){this.yoga.setPosition(c[t],e)}setPositionPercent(t,e){this.yoga.setPositionPercent(c[t],e)}setOverflow(t){const e={visible:h.Visible,hidden:h.Hidden,scroll:h.Scroll};this.yoga.setOverflow(e[t])}setMargin(t,e){this.yoga.setMargin(c[t],e)}setPadding(t,e){this.yoga.setPadding(c[t],e)}setBorder(t,e){this.yoga.setBorder(c[t],e)}setGap(t,e){this.yoga.setGap(p[t],e)}free(){this.yoga.free()}freeRecursive(){this.yoga.freeRecursive()}}export function createYogaLayoutNode(){return new YogaLayoutNode(t.Node.create())}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{stringWidth as t}from"./stringWidth.js";const
|
|
1
|
+
import{stringWidth as t}from"./stringWidth.js";const i=new Map;export function lineWidth(n){const r=i.get(n);if(void 0!==r)return r;const e=t(n);return i.size>=4096&&i.clear(),i.set(n,e),e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ansiCodesToString as e,diffAnsiCodes as t}from"@alcalzone/ansi-tokenize";import{logForDebugging as r}from"../utils/debug.js";import{cellAt as n,charInCellAt as i,diffEach as o,isEmptyCellAt as s,shiftRows as c,visibleCellAtIndex as h}from"./screen.js";import{CURSOR_HOME as
|
|
1
|
+
import{ansiCodesToString as e,diffAnsiCodes as t}from"@alcalzone/ansi-tokenize";import{logForDebugging as r}from"../utils/debug.js";import{cellAt as n,charInCellAt as i,diffEach as o,isEmptyCellAt as s,shiftRows as c,visibleCellAtIndex as h}from"./screen.js";import{CURSOR_HOME as l,scrollDown as u,scrollUp as d,RESET_SCROLL_REGION as f,setScrollRegion as p}from"./termio/csi.js";import{LINK_END as a,link as y}from"./termio/osc.js";const g={type:"carriageReturn"},x={type:"stdout",content:"\n"};export class LogUpdate{options;state;constructor(e){this.options=e,this.state={previousOutput:""}}renderPreviousOutput_DEPRECATED(e){return this.options.isTTY?this.getRenderOpsForDone(e):[x]}reset(){this.state.previousOutput=""}renderFullFrame(r){const{screen:i}=r,o=[];let s,c=[];for(let r=0;r<i.height;r++){let h="";for(let o=0;o<i.width;o++){const l=n(i,o,r);if(l&&2!==l.width){l.hyperlink!==s&&(void 0!==s&&(h+=a),void 0!==l.hyperlink&&(h+=y(l.hyperlink)),s=l.hyperlink);const r=this.options.stylePool.get(l.styleId),n=t(c,r);n.length>0&&(h+=e(n),c=r),h+=l.char}}void 0!==s&&(h+=a,s=void 0);const l=t(c,[]);l.length>0&&(h+=e(l),c=[]),o.push(h.trimEnd())}return 0===o.length?[]:[{type:"stdout",content:o.join("\n")}]}getRenderOpsForDone(e){return this.state.previousOutput="",e.cursor.visible?[]:[{type:"cursorShow"}]}render(e,t,n=!1,i=!0){if(!this.options.isTTY)return this.renderFullFrame(t);const h=performance.now(),a=this.options.stylePool;if(t.viewport.height<e.viewport.height||0!==e.viewport.width&&t.viewport.width!==e.viewport.width)return fullResetSequence_CAUSES_FLICKER(t,"resize",a);let y=[];if(n&&t.scrollHint&&i){const{top:r,bottom:n,delta:i}=t.scrollHint;r>=0&&n<e.screen.height&&n<t.screen.height&&(c(e.screen,r,n,i),y=[{type:"stdout",content:p(r+1,n+1)+(i>0?d(i):u(-i))+f+l}])}const w=e.cursor.y>=e.screen.height,v=t.screen.height>e.screen.height,S=w&&e.screen.height>=e.viewport.height,m=t.screen.height<e.screen.height,C=t.screen.height<=e.viewport.height;if(S&&C&&m)return r(`Full reset (shrink->below): prevHeight=${e.screen.height}, nextHeight=${t.screen.height}, viewport=${e.viewport.height}`),fullResetSequence_CAUSES_FLICKER(t,"offscreen",a);if(e.screen.height>=e.viewport.height&&e.screen.height>0&&w&&!v){const r=e.screen.height-e.viewport.height+1;let n=-1;if(o(e.screen,t.screen,(e,t)=>{if(t<r)return n=t,!0}),n>=0){const r=readLine(e.screen,n),i=readLine(t.screen,n);return fullResetSequence_CAUSES_FLICKER(t,"offscreen",a,{triggerY:n,prevLine:r,nextLine:i})}}const E=new VirtualScreen(e.cursor,t.viewport.width),R=Math.max(t.screen.height,1)-Math.max(e.screen.height,1),L=R>0;if(R<0){const r=e.screen.height-t.screen.height;if(r>e.viewport.height)return fullResetSequence_CAUSES_FLICKER(t,"offscreen",this.options.stylePool);E.txn(e=>[[{type:"clear",count:r},{type:"cursorMove",x:0,y:-1}],{dx:-e.x,dy:-r}])}const k=S?1:0,F=L?Math.max(0,e.screen.height-e.viewport.height+k):Math.max(e.screen.height,t.screen.height)-t.viewport.height+k;let _,A=a.none,I=!1,T=-1;if(o(e.screen,t.screen,(r,n,i,o)=>{if(!(L&&n>=e.screen.height)&&(!o||2!==o.width&&3!==o.width)&&(!i||2!==i.width&&3!==i.width||o)&&(!o||!s(t.screen,r,n)||i)){if(n<F)return I=!0,T=n,!0;if(moveCursorTo(E,r,n),o){const e=o.hyperlink;_=transitionHyperlink(E.diff,_,e);const t=a.transition(A,o.styleId);writeCellWithStyleStr(E,o,t)&&(A=o.styleId)}else if(i){const e=A,t=_;A=a.none,_=void 0,E.txn(()=>{const r=[];return transitionStyle(r,a,e,a.none),transitionHyperlink(r,t,void 0),r.push({type:"stdout",content:" "}),[r,{dx:1,dy:0}]})}}}),I)return fullResetSequence_CAUSES_FLICKER(t,"offscreen",a,{triggerY:T,prevLine:readLine(e.screen,T),nextLine:readLine(t.screen,T)});A=transitionStyle(E.diff,a,A,a.none),_=transitionHyperlink(E.diff,_,void 0),L&&renderFrameSlice(E,t,e.screen.height,t.screen.height,a),n||(t.cursor.y>=t.screen.height?E.txn(e=>{const r=t.cursor.y-e.y;if(r>0){const t=new Array(1+r);t[0]=g;for(let e=0;e<r;e++)t[1+e]=x;return[t,{dx:-e.x,dy:r}]}const n=t.cursor.y-e.y;if(0!==n||e.x!==t.cursor.x){const r=[g];return r.push({type:"cursorMove",x:t.cursor.x,y:n}),[r,{dx:t.cursor.x-e.x,dy:n}]}return[[],{dx:0,dy:0}]}):moveCursorTo(E,t.cursor.x,t.cursor.y));const H=performance.now()-h;if(H>50){const e=t.screen.damage,n=e?`${e.width}x${e.height} at (${e.x},${e.y})`:"none";r(`Slow render: ${H.toFixed(1)}ms, screen: ${t.screen.height}x${t.screen.width}, damage: ${n}, changes: ${E.diff.length}`)}return y.length>0?[...y,...E.diff]:E.diff}}function transitionHyperlink(e,t,r){return t!==r?(e.push({type:"hyperlink",uri:r??""}),r):t}function transitionStyle(e,t,r,n){const i=t.transition(r,n);return i.length>0&&e.push({type:"styleStr",str:i}),n}function readLine(e,t){let r="";for(let n=0;n<e.width;n++)r+=i(e,n,t)??" ";return r.trimEnd()}function fullResetSequence_CAUSES_FLICKER(e,t,r,n){const i=new VirtualScreen({x:0,y:0},e.viewport.width);return function(e,t,r){renderFrameSlice(e,t,0,t.screen.height,r)}(i,e,r),[{type:"clearTerminal",reason:t,debug:n},...i.diff]}function renderFrameSlice(e,t,r,n,i){let o,s=i.none,c=-1;const{width:l,cells:u,charPool:d,hyperlinkPool:f}=t.screen;let p=r*l;for(let t=r;t<n;t+=1){if(e.cursor.y<t){const r=t-e.cursor.y;e.txn(e=>{const t=new Array(1+r);t[0]=g;for(let e=0;e<r;e++)t[1+e]=x;return[t,{dx:-e.x,dy:r}]})}c=-1;for(let r=0;r<l;r+=1,p+=1){const n=h(u,d,f,p,c);if(!n)continue;moveCursorTo(e,r,t);const l=n.hyperlink;o=transitionHyperlink(e.diff,o,l),writeCellWithStyleStr(e,n,i.transition(s,n.styleId))&&(s=n.styleId,c=n.styleId)}s=transitionStyle(e.diff,i,s,i.none),o=transitionHyperlink(e.diff,o,void 0),e.txn(e=>[[g,x],{dx:-e.x,dy:1}])}return transitionStyle(e.diff,i,s,i.none),transitionHyperlink(e.diff,o,void 0),e}function writeCellWithStyleStr(e,t,r){const n=1===t.width?2:1,i=e.cursor.x,o=e.viewportWidth;if(2===n&&i<o&&i+2>=(t.char.length>2?o:o+1))return!1;const s=e.diff;r.length>0&&s.push({type:"styleStr",str:r});const c=2===n&&function(e){const t=e.codePointAt(0);if(void 0===t)return!1;if(t>=129648&&t<=129791||t>=129792&&t<=130047)return!0;if(e.length>=2)for(let t=0;t<e.length;t++)if(65039===e.charCodeAt(t))return!0;return!1}(t.char);return c&&i+1<o&&(s.push({type:"cursorTo",col:i+2}),s.push({type:"stdout",content:" "}),s.push({type:"cursorTo",col:i+1})),s.push({type:"stdout",content:t.char}),c&&s.push({type:"cursorTo",col:i+n+1}),i>=o?(e.cursor.x=n,e.cursor.y++):e.cursor.x=i+n,!0}function moveCursorTo(e,t,r){e.txn(n=>{const i=t-n.x,o=r-n.y;return n.x>=e.viewportWidth||0!==o?[[g,{type:"cursorMove",x:t,y:o}],{dx:i,dy:o}]:[[{type:"cursorMove",x:i,y:o}],{dx:i,dy:o}]})}class VirtualScreen{viewportWidth;cursor;diff=[];constructor(e,t){this.viewportWidth=t,this.cursor={...e}}txn(e){const[t,r]=e(this.cursor);for(const e of t)this.diff.push(e);this.cursor.x+=r.dx,this.cursor.y+=r.dy}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lineWidth as t}from"./line-width-cache.js";function measureText(e,i){if(0===e.length)return{width:0,height:0};const n=i<=0||!Number.isFinite(i);let r=0,h=0,s=0;for(;s<=e.length;){const
|
|
1
|
+
import{lineWidth as t}from"./line-width-cache.js";function measureText(e,i){if(0===e.length)return{width:0,height:0};const n=i<=0||!Number.isFinite(i);let r=0,h=0,s=0;for(;s<=e.length;){const a=e.indexOf("\n",s),u=-1===a?e.substring(s):e.substring(s,a),f=t(u);if(h=Math.max(h,f),n?r++:r+=0===f?1:Math.ceil(f/i),-1===a)break;s=a+1}return{width:h,height:r}}export default measureText;
|