terminal-pilot 0.0.30 → 0.0.31
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/cli.js +1375 -435
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +485 -6
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.js +485 -6
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.js +485 -6
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.js +485 -6
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.js +626 -44
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +622 -40
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +68 -17
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +485 -6
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.js +485 -6
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.js +485 -6
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.js +485 -6
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.js +485 -6
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/screenshot.js +485 -6
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.js +485 -6
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.js +485 -6
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.js +550 -20
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +485 -6
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.js +485 -6
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +1375 -435
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +1385 -445
- package/dist/testing/qa-cli.js.map +4 -4
- package/node_modules/@poe-code/agent-defs/README.md +35 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +21 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +18 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +25 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +20 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +45 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +40 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +28 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.d.ts +1 -0
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +37 -18
- package/node_modules/@poe-code/agent-skill-config/dist/resolve-skill-reference.js +8 -4
- package/node_modules/@poe-code/agent-skill-config/package.json +1 -5
- package/node_modules/@poe-code/config-mutations/README.md +55 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +829 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +64 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +39 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +32 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +171 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.d.ts +4 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.js +27 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +75 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +76 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +43 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +62 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +55 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +194 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +168 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +29 -0
- package/node_modules/@poe-code/frontmatter/README.md +35 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.d.ts +25 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.js +100 -0
- package/node_modules/@poe-code/frontmatter/dist/index.d.ts +3 -0
- package/node_modules/@poe-code/frontmatter/dist/index.js +3 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +20 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.js +209 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.d.ts +1 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.js +48 -0
- package/node_modules/@poe-code/frontmatter/package.json +25 -0
- package/node_modules/toolcraft-design/README.md +160 -0
- package/node_modules/toolcraft-design/dist/acp/components.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/acp/components.js +137 -0
- package/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/acp/index.js +2 -0
- package/node_modules/toolcraft-design/dist/acp/writer.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/acp/writer.js +21 -0
- package/node_modules/toolcraft-design/dist/components/browser.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/browser.js +31 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +95 -0
- package/node_modules/toolcraft-design/dist/components/color.d.ts +31 -0
- package/node_modules/toolcraft-design/dist/components/color.js +102 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.js +23 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.d.ts +22 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.js +45 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +33 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.js +213 -0
- package/node_modules/toolcraft-design/dist/components/index.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/index.js +10 -0
- package/node_modules/toolcraft-design/dist/components/logger.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/components/logger.js +60 -0
- package/node_modules/toolcraft-design/dist/components/symbols.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/components/symbols.js +71 -0
- package/node_modules/toolcraft-design/dist/components/table.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/table.js +302 -0
- package/node_modules/toolcraft-design/dist/components/template.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/components/template.js +437 -0
- package/node_modules/toolcraft-design/dist/components/text.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/text.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.js +343 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.js +219 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.js +123 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.js +56 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +268 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +107 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.js +167 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.js +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.js +233 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.js +79 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.js +68 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.js +51 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +71 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.js +264 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.d.ts +38 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +39 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.js +297 -0
- package/node_modules/toolcraft-design/dist/explorer/events.d.ts +67 -0
- package/node_modules/toolcraft-design/dist/explorer/events.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.js +95 -0
- package/node_modules/toolcraft-design/dist/explorer/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/index.js +8 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.js +59 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.js +376 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +782 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.js +97 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.js +49 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.js +53 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.js +116 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.js +87 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +156 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.js +81 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +340 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +101 -0
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +137 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +86 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.d.ts +27 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/toolcraft-design/dist/index.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/index.js +43 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.js +12 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.js +22 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.js +50 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.js +71 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/toolcraft-design/dist/prompts/index.d.ts +91 -0
- package/node_modules/toolcraft-design/dist/prompts/index.js +137 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.js +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.js +47 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +274 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.js +53 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.js +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.js +28 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +131 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +52 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.js +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.js +89 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.js +32 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.js +60 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.js +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.js +104 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.js +39 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/toolcraft-design/dist/static/index.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/static/index.js +2 -0
- package/node_modules/toolcraft-design/dist/static/menu.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/static/menu.js +42 -0
- package/node_modules/toolcraft-design/dist/static/spinner.d.ts +14 -0
- package/node_modules/toolcraft-design/dist/static/spinner.js +52 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +36 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +1190 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +615 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/toolcraft-design/dist/tokens/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/index.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.js +6 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.js +8 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.js +5 -0
- package/node_modules/toolcraft-design/package.json +44 -0
- package/package.json +15 -5
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
const ESC = "\u001b";
|
|
2
|
+
export function hasAnsi(text) {
|
|
3
|
+
return text.includes(ESC);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parse a block of text that may contain ANSI SGR escape codes into a sequence of
|
|
7
|
+
* logical lines split on "\n". Each line is a list of styled segments: contiguous
|
|
8
|
+
* printable runs of characters sharing the same style.
|
|
9
|
+
*
|
|
10
|
+
* Common cursor-affecting line controls are rendered into their visible result.
|
|
11
|
+
* `baseStyle` is used as the initial style and as the restore target for SGR reset / default color.
|
|
12
|
+
*/
|
|
13
|
+
export function parseAnsi(text, baseStyle) {
|
|
14
|
+
const base = normalizeStyle(baseStyle);
|
|
15
|
+
let style = { ...base };
|
|
16
|
+
let concealed = false;
|
|
17
|
+
const lines = [];
|
|
18
|
+
let cells = [];
|
|
19
|
+
let column = 0;
|
|
20
|
+
const finishLine = () => {
|
|
21
|
+
lines.push({ segments: cellsToSegments(cells) });
|
|
22
|
+
cells = [];
|
|
23
|
+
column = 0;
|
|
24
|
+
};
|
|
25
|
+
let index = 0;
|
|
26
|
+
while (index < text.length) {
|
|
27
|
+
const ch = text[index];
|
|
28
|
+
if (ch === ESC && text[index + 1] === "[") {
|
|
29
|
+
const paramsStart = index + 2;
|
|
30
|
+
let cursor = paramsStart;
|
|
31
|
+
while (cursor < text.length && !isCsiFinalByte(text[cursor])) {
|
|
32
|
+
cursor += 1;
|
|
33
|
+
}
|
|
34
|
+
if (cursor >= text.length) {
|
|
35
|
+
index = text.length;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
const params = text.slice(paramsStart, cursor);
|
|
39
|
+
const finalByte = text[cursor];
|
|
40
|
+
if (finalByte === "m") {
|
|
41
|
+
const sgr = applySgr(style, concealed, parseParams(params), base);
|
|
42
|
+
style = sgr.style;
|
|
43
|
+
concealed = sgr.concealed;
|
|
44
|
+
}
|
|
45
|
+
else if (finalByte === "K" && parseParams(params)[0] === 2) {
|
|
46
|
+
cells = [];
|
|
47
|
+
}
|
|
48
|
+
index = cursor + 1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (ch === ESC) {
|
|
52
|
+
const next = text[index + 1];
|
|
53
|
+
if (next === "]" || next === "P" || next === "X" || next === "^" || next === "_") {
|
|
54
|
+
index = skipStringTerminated(text, index + 2);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
index += 2;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (ch === "\r") {
|
|
61
|
+
column = 0;
|
|
62
|
+
index += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (ch === "\n") {
|
|
66
|
+
finishLine();
|
|
67
|
+
index += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (ch === "\b") {
|
|
71
|
+
column = Math.max(0, column - 1);
|
|
72
|
+
index += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const code = ch.charCodeAt(0);
|
|
76
|
+
if (code < 0x20 && ch !== "\t") {
|
|
77
|
+
index += 1;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
cells[column] = { ch: concealed ? " " : ch, style: { ...style } };
|
|
81
|
+
column += 1;
|
|
82
|
+
index += 1;
|
|
83
|
+
}
|
|
84
|
+
finishLine();
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
87
|
+
function cellsToSegments(cells) {
|
|
88
|
+
const segments = [];
|
|
89
|
+
for (const cell of cells) {
|
|
90
|
+
const nextCell = cell ?? { ch: " ", style: {} };
|
|
91
|
+
const last = segments[segments.length - 1];
|
|
92
|
+
if (last && stylesEqual(last.style, nextCell.style)) {
|
|
93
|
+
last.text += nextCell.ch;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
segments.push({ text: nextCell.ch, style: { ...nextCell.style } });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return segments;
|
|
100
|
+
}
|
|
101
|
+
function isCsiFinalByte(ch) {
|
|
102
|
+
const code = ch.charCodeAt(0);
|
|
103
|
+
return code >= 0x40 && code <= 0x7e;
|
|
104
|
+
}
|
|
105
|
+
function skipStringTerminated(text, start) {
|
|
106
|
+
let index = start;
|
|
107
|
+
while (index < text.length) {
|
|
108
|
+
const ch = text[index];
|
|
109
|
+
if (ch === "\u0007") {
|
|
110
|
+
return index + 1;
|
|
111
|
+
}
|
|
112
|
+
if (ch === ESC && text[index + 1] === "\\") {
|
|
113
|
+
return index + 2;
|
|
114
|
+
}
|
|
115
|
+
index += 1;
|
|
116
|
+
}
|
|
117
|
+
return index;
|
|
118
|
+
}
|
|
119
|
+
function parseParams(params) {
|
|
120
|
+
if (params.length === 0) {
|
|
121
|
+
return [0];
|
|
122
|
+
}
|
|
123
|
+
return params.split(";").flatMap((part) => {
|
|
124
|
+
const colonParams = part.split(":");
|
|
125
|
+
if (colonParams.length > 2 && colonParams[1] === "2") {
|
|
126
|
+
colonParams.splice(2, 1);
|
|
127
|
+
}
|
|
128
|
+
return colonParams.map(parseParam);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function parseParam(part) {
|
|
132
|
+
if (part.length === 0) {
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
const parsed = Number.parseInt(part, 10);
|
|
136
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
137
|
+
}
|
|
138
|
+
const BASIC_COLORS = [
|
|
139
|
+
"black",
|
|
140
|
+
"red",
|
|
141
|
+
"green",
|
|
142
|
+
"yellow",
|
|
143
|
+
"blue",
|
|
144
|
+
"magenta",
|
|
145
|
+
"cyan",
|
|
146
|
+
"white"
|
|
147
|
+
];
|
|
148
|
+
const BRIGHT_COLORS = [
|
|
149
|
+
"gray",
|
|
150
|
+
"redBright",
|
|
151
|
+
"greenBright",
|
|
152
|
+
"yellowBright",
|
|
153
|
+
"blueBright",
|
|
154
|
+
"magentaBright",
|
|
155
|
+
"cyanBright",
|
|
156
|
+
"whiteBright"
|
|
157
|
+
];
|
|
158
|
+
function applySgr(style, concealed, params, base) {
|
|
159
|
+
let next = { ...style };
|
|
160
|
+
let nextConcealed = concealed;
|
|
161
|
+
let index = 0;
|
|
162
|
+
while (index < params.length) {
|
|
163
|
+
const code = params[index];
|
|
164
|
+
if (code === 0) {
|
|
165
|
+
next = { ...base };
|
|
166
|
+
nextConcealed = false;
|
|
167
|
+
index += 1;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (code === 1) {
|
|
171
|
+
next.bold = true;
|
|
172
|
+
index += 1;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (code === 2) {
|
|
176
|
+
next.dim = true;
|
|
177
|
+
index += 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (code === 7) {
|
|
181
|
+
next.inverse = true;
|
|
182
|
+
index += 1;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (code === 22) {
|
|
186
|
+
delete next.bold;
|
|
187
|
+
delete next.dim;
|
|
188
|
+
index += 1;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (code === 8) {
|
|
192
|
+
nextConcealed = true;
|
|
193
|
+
index += 1;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (code === 28) {
|
|
197
|
+
nextConcealed = false;
|
|
198
|
+
index += 1;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (code === 27) {
|
|
202
|
+
delete next.inverse;
|
|
203
|
+
index += 1;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (code >= 30 && code <= 37) {
|
|
207
|
+
next.fg = BASIC_COLORS[code - 30];
|
|
208
|
+
index += 1;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (code === 38) {
|
|
212
|
+
const mode = params[index + 1];
|
|
213
|
+
if (mode === 5) {
|
|
214
|
+
const palette = params[index + 2] ?? 0;
|
|
215
|
+
next.fg = convert256(palette);
|
|
216
|
+
index += 3;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (mode === 2) {
|
|
220
|
+
const r = params[index + 2] ?? 0;
|
|
221
|
+
const g = params[index + 3] ?? 0;
|
|
222
|
+
const b = params[index + 4] ?? 0;
|
|
223
|
+
next.fg = rgbToHex(r, g, b);
|
|
224
|
+
index += 5;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
index += 1;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (code === 39) {
|
|
231
|
+
if (base.fg !== undefined) {
|
|
232
|
+
next.fg = base.fg;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
delete next.fg;
|
|
236
|
+
}
|
|
237
|
+
index += 1;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (code >= 40 && code <= 47) {
|
|
241
|
+
next.bg = BASIC_COLORS[code - 40];
|
|
242
|
+
index += 1;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (code === 48) {
|
|
246
|
+
const mode = params[index + 1];
|
|
247
|
+
if (mode === 5) {
|
|
248
|
+
const palette = params[index + 2] ?? 0;
|
|
249
|
+
next.bg = convert256(palette);
|
|
250
|
+
index += 3;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (mode === 2) {
|
|
254
|
+
const r = params[index + 2] ?? 0;
|
|
255
|
+
const g = params[index + 3] ?? 0;
|
|
256
|
+
const b = params[index + 4] ?? 0;
|
|
257
|
+
next.bg = rgbToHex(r, g, b);
|
|
258
|
+
index += 5;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
index += 1;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (code === 49) {
|
|
265
|
+
if (base.bg !== undefined) {
|
|
266
|
+
next.bg = base.bg;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
delete next.bg;
|
|
270
|
+
}
|
|
271
|
+
index += 1;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (code >= 90 && code <= 97) {
|
|
275
|
+
next.fg = BRIGHT_COLORS[code - 90];
|
|
276
|
+
index += 1;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (code >= 100 && code <= 107) {
|
|
280
|
+
next.bg = BRIGHT_COLORS[code - 100];
|
|
281
|
+
index += 1;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
index += 1;
|
|
285
|
+
}
|
|
286
|
+
return { style: next, concealed: nextConcealed };
|
|
287
|
+
}
|
|
288
|
+
function convert256(palette) {
|
|
289
|
+
if (palette < 0 || palette > 255) {
|
|
290
|
+
return "#000000";
|
|
291
|
+
}
|
|
292
|
+
if (palette < 8) {
|
|
293
|
+
return BASIC_COLORS[palette];
|
|
294
|
+
}
|
|
295
|
+
if (palette < 16) {
|
|
296
|
+
return BRIGHT_COLORS[palette - 8];
|
|
297
|
+
}
|
|
298
|
+
if (palette >= 232) {
|
|
299
|
+
const level = 8 + (palette - 232) * 10;
|
|
300
|
+
return rgbToHex(level, level, level);
|
|
301
|
+
}
|
|
302
|
+
const offset = palette - 16;
|
|
303
|
+
const r = Math.floor(offset / 36);
|
|
304
|
+
const g = Math.floor((offset % 36) / 6);
|
|
305
|
+
const b = offset % 6;
|
|
306
|
+
return rgbToHex(cubeLevel(r), cubeLevel(g), cubeLevel(b));
|
|
307
|
+
}
|
|
308
|
+
function cubeLevel(value) {
|
|
309
|
+
return value === 0 ? 0 : 55 + value * 40;
|
|
310
|
+
}
|
|
311
|
+
function rgbToHex(r, g, b) {
|
|
312
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
313
|
+
}
|
|
314
|
+
function toHex(value) {
|
|
315
|
+
const clamped = Math.max(0, Math.min(255, Math.floor(value)));
|
|
316
|
+
return clamped.toString(16).padStart(2, "0");
|
|
317
|
+
}
|
|
318
|
+
function stylesEqual(left, right) {
|
|
319
|
+
return left.fg === right.fg
|
|
320
|
+
&& left.bg === right.bg
|
|
321
|
+
&& left.bold === right.bold
|
|
322
|
+
&& left.dim === right.dim
|
|
323
|
+
&& left.inverse === right.inverse;
|
|
324
|
+
}
|
|
325
|
+
function normalizeStyle(style) {
|
|
326
|
+
const next = {};
|
|
327
|
+
if (style?.fg !== undefined) {
|
|
328
|
+
next.fg = style.fg;
|
|
329
|
+
}
|
|
330
|
+
if (style?.bg !== undefined) {
|
|
331
|
+
next.bg = style.bg;
|
|
332
|
+
}
|
|
333
|
+
if (style?.bold !== undefined) {
|
|
334
|
+
next.bold = style.bold;
|
|
335
|
+
}
|
|
336
|
+
if (style?.dim !== undefined) {
|
|
337
|
+
next.dim = style.dim;
|
|
338
|
+
}
|
|
339
|
+
if (style?.inverse !== undefined) {
|
|
340
|
+
next.inverse = style.inverse;
|
|
341
|
+
}
|
|
342
|
+
return next;
|
|
343
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Cell, CellStyle, Rect } from "./types.js";
|
|
2
|
+
export declare class ScreenBuffer {
|
|
3
|
+
private _width;
|
|
4
|
+
private _height;
|
|
5
|
+
private _cells;
|
|
6
|
+
constructor(width: number, height: number);
|
|
7
|
+
get width(): number;
|
|
8
|
+
get height(): number;
|
|
9
|
+
put(x: number, y: number, text: string, style?: CellStyle): void;
|
|
10
|
+
get(x: number, y: number): Cell;
|
|
11
|
+
clear(style?: CellStyle): void;
|
|
12
|
+
clearRect(rect: Rect, style?: CellStyle): void;
|
|
13
|
+
resize(width: number, height: number): void;
|
|
14
|
+
putInRect(rect: Rect, row: number, text: string, style?: CellStyle): void;
|
|
15
|
+
private index;
|
|
16
|
+
private isInBounds;
|
|
17
|
+
private isInBoundsX;
|
|
18
|
+
private isInBoundsY;
|
|
19
|
+
}
|
|
20
|
+
export declare function diff(prev: ScreenBuffer, next: ScreenBuffer): Array<{
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
cell: Cell;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function cellToAnsi(cell: Cell): string;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { color } from "../components/color.js";
|
|
2
|
+
import { expandTabs, graphemes, graphemeWidth } from "./terminal-width.js";
|
|
3
|
+
const EMPTY_CELL = { ch: " ", style: {} };
|
|
4
|
+
export class ScreenBuffer {
|
|
5
|
+
_width;
|
|
6
|
+
_height;
|
|
7
|
+
_cells;
|
|
8
|
+
constructor(width, height) {
|
|
9
|
+
this._width = normalizeSize(width);
|
|
10
|
+
this._height = normalizeSize(height);
|
|
11
|
+
this._cells = createCells(this._width, this._height);
|
|
12
|
+
}
|
|
13
|
+
get width() {
|
|
14
|
+
return this._width;
|
|
15
|
+
}
|
|
16
|
+
get height() {
|
|
17
|
+
return this._height;
|
|
18
|
+
}
|
|
19
|
+
put(x, y, text, style) {
|
|
20
|
+
if (!this.isInBoundsY(y) || text.length === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const normalizedStyle = normalizeStyle(style);
|
|
24
|
+
let offset = 0;
|
|
25
|
+
for (const ch of graphemes(expandTabs(text, Math.max(0, x)))) {
|
|
26
|
+
const targetX = x + offset;
|
|
27
|
+
const width = graphemeWidth(ch);
|
|
28
|
+
offset += width;
|
|
29
|
+
if (!this.isInBoundsX(targetX)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
this._cells[this.index(targetX, y)] = { ch, style: normalizedStyle };
|
|
33
|
+
for (let continuation = 1; continuation < width; continuation += 1) {
|
|
34
|
+
if (this.isInBoundsX(targetX + continuation)) {
|
|
35
|
+
this._cells[this.index(targetX + continuation, y)] = { ch: "", style: normalizedStyle };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
get(x, y) {
|
|
41
|
+
if (!this.isInBounds(x, y)) {
|
|
42
|
+
return cloneCell(EMPTY_CELL);
|
|
43
|
+
}
|
|
44
|
+
return cloneCell(this._cells[this.index(x, y)] ?? EMPTY_CELL);
|
|
45
|
+
}
|
|
46
|
+
clear(style) {
|
|
47
|
+
this._cells = createCells(this._width, this._height, style);
|
|
48
|
+
}
|
|
49
|
+
clearRect(rect, style) {
|
|
50
|
+
const startX = Math.max(0, rect.x);
|
|
51
|
+
const startY = Math.max(0, rect.y);
|
|
52
|
+
const endX = Math.min(this._width, rect.x + Math.max(0, rect.width));
|
|
53
|
+
const endY = Math.min(this._height, rect.y + Math.max(0, rect.height));
|
|
54
|
+
const normalizedStyle = normalizeStyle(style);
|
|
55
|
+
for (let y = startY; y < endY; y += 1) {
|
|
56
|
+
for (let x = startX; x < endX; x += 1) {
|
|
57
|
+
this._cells[this.index(x, y)] = { ch: " ", style: normalizedStyle };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
resize(width, height) {
|
|
62
|
+
const nextWidth = normalizeSize(width);
|
|
63
|
+
const nextHeight = normalizeSize(height);
|
|
64
|
+
const nextCells = createCells(nextWidth, nextHeight);
|
|
65
|
+
const copyWidth = Math.min(this._width, nextWidth);
|
|
66
|
+
const copyHeight = Math.min(this._height, nextHeight);
|
|
67
|
+
for (let y = 0; y < copyHeight; y += 1) {
|
|
68
|
+
for (let x = 0; x < copyWidth; x += 1) {
|
|
69
|
+
nextCells[(y * nextWidth) + x] = cloneCell(this._cells[this.index(x, y)] ?? EMPTY_CELL);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
this._width = nextWidth;
|
|
73
|
+
this._height = nextHeight;
|
|
74
|
+
this._cells = nextCells;
|
|
75
|
+
}
|
|
76
|
+
putInRect(rect, row, text, style) {
|
|
77
|
+
if (row < 0 || row >= rect.height || text.length === 0 || rect.width <= 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const y = rect.y + row;
|
|
81
|
+
if (!this.isInBoundsY(y)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const normalizedStyle = normalizeStyle(style);
|
|
85
|
+
const rectEndX = rect.x + rect.width;
|
|
86
|
+
let offset = 0;
|
|
87
|
+
for (const ch of graphemes(expandTabs(text))) {
|
|
88
|
+
const targetX = rect.x + offset;
|
|
89
|
+
const width = graphemeWidth(ch);
|
|
90
|
+
offset += width;
|
|
91
|
+
if (targetX + width > rectEndX) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (!this.isInBoundsX(targetX)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
this._cells[this.index(targetX, y)] = { ch, style: normalizedStyle };
|
|
98
|
+
for (let continuation = 1; continuation < width; continuation += 1) {
|
|
99
|
+
if (this.isInBoundsX(targetX + continuation)) {
|
|
100
|
+
this._cells[this.index(targetX + continuation, y)] = { ch: "", style: normalizedStyle };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
index(x, y) {
|
|
106
|
+
return (y * this._width) + x;
|
|
107
|
+
}
|
|
108
|
+
isInBounds(x, y) {
|
|
109
|
+
return this.isInBoundsX(x) && this.isInBoundsY(y);
|
|
110
|
+
}
|
|
111
|
+
isInBoundsX(x) {
|
|
112
|
+
return x >= 0 && x < this._width;
|
|
113
|
+
}
|
|
114
|
+
isInBoundsY(y) {
|
|
115
|
+
return y >= 0 && y < this._height;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function diff(prev, next) {
|
|
119
|
+
const changes = [];
|
|
120
|
+
const width = Math.max(prev.width, next.width);
|
|
121
|
+
const height = Math.max(prev.height, next.height);
|
|
122
|
+
for (let y = 0; y < height; y += 1) {
|
|
123
|
+
for (let x = 0; x < width; x += 1) {
|
|
124
|
+
const previousCell = prev.get(x, y);
|
|
125
|
+
const nextCell = next.get(x, y);
|
|
126
|
+
if (!cellsEqual(previousCell, nextCell)) {
|
|
127
|
+
changes.push({ x, y, cell: nextCell });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return changes;
|
|
132
|
+
}
|
|
133
|
+
export function cellToAnsi(cell) {
|
|
134
|
+
if (cell.ch.length === 0) {
|
|
135
|
+
return "";
|
|
136
|
+
}
|
|
137
|
+
const style = cell.style ?? {};
|
|
138
|
+
let painter = color;
|
|
139
|
+
if (style.bold) {
|
|
140
|
+
painter = painter.bold;
|
|
141
|
+
}
|
|
142
|
+
if (style.dim) {
|
|
143
|
+
painter = painter.dim;
|
|
144
|
+
}
|
|
145
|
+
if (style.inverse) {
|
|
146
|
+
painter = painter.inverse;
|
|
147
|
+
}
|
|
148
|
+
if (style.underline) {
|
|
149
|
+
painter = painter.underline;
|
|
150
|
+
}
|
|
151
|
+
if (style.fg) {
|
|
152
|
+
painter = applyForegroundColor(painter, style.fg);
|
|
153
|
+
}
|
|
154
|
+
if (style.bg) {
|
|
155
|
+
painter = applyBackgroundColor(painter, style.bg);
|
|
156
|
+
}
|
|
157
|
+
return painter(cell.ch);
|
|
158
|
+
}
|
|
159
|
+
function createCells(width, height, style) {
|
|
160
|
+
const normalizedStyle = normalizeStyle(style);
|
|
161
|
+
return Array.from({ length: width * height }, () => ({ ch: " ", style: normalizedStyle }));
|
|
162
|
+
}
|
|
163
|
+
function cloneCell(cell) {
|
|
164
|
+
return {
|
|
165
|
+
ch: cell.ch,
|
|
166
|
+
style: normalizeStyle(cell.style)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function normalizeStyle(style) {
|
|
170
|
+
const next = {};
|
|
171
|
+
if (style?.fg !== undefined) {
|
|
172
|
+
next.fg = style.fg;
|
|
173
|
+
}
|
|
174
|
+
if (style?.bg !== undefined) {
|
|
175
|
+
next.bg = style.bg;
|
|
176
|
+
}
|
|
177
|
+
if (style?.bold !== undefined) {
|
|
178
|
+
next.bold = style.bold;
|
|
179
|
+
}
|
|
180
|
+
if (style?.dim !== undefined) {
|
|
181
|
+
next.dim = style.dim;
|
|
182
|
+
}
|
|
183
|
+
if (style?.inverse !== undefined) {
|
|
184
|
+
next.inverse = style.inverse;
|
|
185
|
+
}
|
|
186
|
+
if (style?.underline !== undefined) {
|
|
187
|
+
next.underline = style.underline;
|
|
188
|
+
}
|
|
189
|
+
return next;
|
|
190
|
+
}
|
|
191
|
+
function normalizeSize(value) {
|
|
192
|
+
return Math.max(0, Math.floor(value));
|
|
193
|
+
}
|
|
194
|
+
function cellsEqual(left, right) {
|
|
195
|
+
return left.ch === right.ch
|
|
196
|
+
&& left.style.fg === right.style.fg
|
|
197
|
+
&& left.style.bg === right.style.bg
|
|
198
|
+
&& left.style.bold === right.style.bold
|
|
199
|
+
&& left.style.dim === right.style.dim
|
|
200
|
+
&& left.style.inverse === right.style.inverse
|
|
201
|
+
&& left.style.underline === right.style.underline;
|
|
202
|
+
}
|
|
203
|
+
function applyForegroundColor(instance, ansiColor) {
|
|
204
|
+
if (ansiColor.startsWith("#")) {
|
|
205
|
+
return instance.hex(ansiColor);
|
|
206
|
+
}
|
|
207
|
+
const painter = instance[ansiColor];
|
|
208
|
+
return typeof painter === "function" ? painter : instance;
|
|
209
|
+
}
|
|
210
|
+
function applyBackgroundColor(instance, ansiColor) {
|
|
211
|
+
if (ansiColor.startsWith("#")) {
|
|
212
|
+
return instance.bgHex(ansiColor);
|
|
213
|
+
}
|
|
214
|
+
const methodName = ansiColor.startsWith("bg")
|
|
215
|
+
? ansiColor
|
|
216
|
+
: `bg${ansiColor.charAt(0).toUpperCase()}${ansiColor.slice(1)}`;
|
|
217
|
+
const painter = instance[methodName];
|
|
218
|
+
return typeof painter === "function" ? painter : instance;
|
|
219
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ScreenBuffer } from "../buffer.js";
|
|
2
|
+
import type { DashboardLayout } from "../layout.js";
|
|
3
|
+
import type { CellStyle } from "../types.js";
|
|
4
|
+
export type BorderOptions = {
|
|
5
|
+
leftTitle?: string;
|
|
6
|
+
rightTitle?: string;
|
|
7
|
+
style: CellStyle;
|
|
8
|
+
};
|
|
9
|
+
export declare function renderBorder(buffer: ScreenBuffer, layout: DashboardLayout, opts: BorderOptions): void;
|