{"id":13912664,"url":"https://github.com/essserrr/crt-terminal","last_synced_at":"2025-04-09T12:04:02.349Z","repository":{"id":44838552,"uuid":"443975482","full_name":"essserrr/crt-terminal","owner":"essserrr","description":"Retro styled terminal shell","archived":false,"fork":false,"pushed_at":"2025-02-09T04:11:37.000Z","size":142,"stargazers_count":33,"open_issues_count":1,"forks_count":21,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T11:06:35.264Z","etag":null,"topics":["react","shell","terminal","typescript"],"latest_commit_sha":null,"homepage":"https://crt-terminal.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/essserrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-03T07:27:49.000Z","updated_at":"2025-02-13T15:30:16.000Z","dependencies_parsed_at":"2025-03-24T05:02:24.118Z","dependency_job_id":"d9f10a33-6e78-4cca-b5e4-4d54bae765fd","html_url":"https://github.com/essserrr/crt-terminal","commit_stats":{"total_commits":35,"total_committers":3,"mean_commits":"11.666666666666666","dds":0.05714285714285716,"last_synced_commit":"b49e1c1d9d19218f7c8c64b86b118d4f834d5003"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essserrr%2Fcrt-terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essserrr%2Fcrt-terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essserrr%2Fcrt-terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essserrr%2Fcrt-terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/essserrr","download_url":"https://codeload.github.com/essserrr/crt-terminal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","shell","terminal","typescript"],"created_at":"2024-08-07T01:01:39.911Z","updated_at":"2025-04-09T12:04:02.303Z","avatar_url":"https://github.com/essserrr.png","language":"TypeScript","funding_links":[],"categories":["react","typescript"],"sub_categories":[],"readme":"[![NPM](https://img.shields.io/npm/v/react-select.svg)](https://www.npmjs.com/package/crt-terminal)\n\n# CRT terminal\n\nSimple retro styled React-hooks-based terminal shell.\n\n[Demo page](https://crt-terminal.vercel.app/).\n\n# Features\n\n1. Smooth printing\n2. Command history\n3. Loader\n4. Ability lock command input\n5. Typescript and React\n6. Hooks-based with event queues under the hood\n7. Zero additional dependencies\n\n# Installation and basic usage\n\nThe best way to use crt-terminal is to install it from npm and include it into your app.\n\n```\nyarn add crt-terminal\n\nnpm install crt-terminal\n```\n\nThen you need to import `Terminal`, `useEventQueue` (or implement your own EventQueue) and line/words helpers (or corresponding enum with IDs).\n\n**Important!** For better experience `Terminal` should be wrapped into a fixed size container.\n\n```js\nimport React from 'react';\nimport { Terminal, useEventQueue, textLine, textWord, commandWord } from 'crt-terminal';\n\nconst bannerText = `\nHello world!\n\nAnd not only world\n`;\n\nexport default function App() {\n  const eventQueue = useEventQueue();\n  const { print } = eventQueue.handlers;\n\n  return (\n    \u003cdiv style={{ width: '1000px', height: '600px' }}\u003e\n      \u003cTerminal\n        queue={eventQueue}\n        banner={[textLine({ words: [textWord({ characters: bannerText })] })]}\n        onCommand={(command) =\u003e\n          print([\n            textLine({\n              words: [\n                textWord({ characters: 'You entered command: ' }),\n                commandWord({ characters: command, prompt: '\u003e' }),\n              ],\n            }),\n          ])\n        }\n      /\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n# Advanced usage and API reference\n\n## Required Props\n\n1. `queue: QueueInterface` - object returned by `useEventQueue`, contains `state` and `api` fields;\n2. `(command: string) =\u003e void` - function to be called every time new command is submitted;\n\n## Optional props\n\n1.  `prompt?: string` - prompt symbol before command input; default: `\u003e\\xa0`;\n2.  `cursorSymbol?: string` - cursor symbol inside command input; default: `\\xa0`;\n3.  `maxHistoryCommands?: number` - max number of commands to be memorized in commands history; default: `10`;\n4.  `banner?: PrintableItem` - message to be printed after `Terminal` is mounted; default: `undefined`.\n5.  `loader?: Partial\u003cLoaderConfig\u003e` - loader config, consist of:\n\n    - `slides: string[]` - array of consecutive loader states; default: `['.', '..', '...']`;\n    - `loaderSpeed: number` - interval between state changes; default: `1000`;\n\n6.  `printer?: Partial\u003cPrinterConfig\u003e` - printer config, consist of:\n\n    - `printerSpeed: number` - interval between state changes; default: `20`;\n    - `charactersPerTick: number` - characters to print on each tick; default: `5`;\n\n7.  `effects?` enabling or disabling following effects:\n\n    - `scanner?: boolean` - scanner line; default: `true`;\n    - `pixels?: boolean` - \"pixels\" effect; default: `true`;\n    - `screenEffects?: boolean` - screen shaking; default: `true`;\n    - `textEffects?: boolean` - text glow, pulsing; default: `true`;\n\n## Event Queue\n\nEvent Queue is the main part of public interface through which component communicates with outer world. `useEventQueue` exports event creators in `handlers` field of returned object, namely:\n\n1. `print: (payload: PrintableItem) =\u003e void` - prints a message on terminal \"screen\". **Important!** Print is async operation, so your next message will be printed as soon as the previous ones are done printing;\n2. `clear: () =\u003e void` - clears terminal \"screen\" with respect to printing queue;\n3. `focus: () =\u003e void` - focuses terminal input;\n4. `lock: (payload: boolean) =\u003e void` - locks/unlocks terminal input preventing any user attempt to enter a command;\n5. `loading: (payload: boolean) =\u003e void` - starts/ends loader. **Important!** Loading start locks input automatically, if it is not locked yet. Loading end unlocks input automatically, if it was locked **by loader**.\n\nYou can use these handlers everywhere to fully control behavior of your terminal.\n\nIf you don't like event creators, you can use `enqueue` function from `api` field of the object returned by `useEventQueue`. In this case you also need to import enums `PrinterEvents` and `TerminalEvents`. **Important!** To avoid possible bugs, you should pass a newly created object every time `enqueue` method is called.\n\n## Sentence, Sentence Helpers\n\nAs one can notice `print` handler prints a `PrintableItem`. `PrintableItem` or sentence is an array of `Lines`. Line is essentially a new `div` on the screen, each line has field `words` containing array of `Words`. There are two types of lines:\n\n1. `TextLine` (larger x-padding, no y-padding)\n2. `CommandLine` (smaller x-padding, has y-padding).\n\n**Important!** Each `Lines` and `Words` have common optional fields:\n\n1. `data-crt-terminal` - can be defined for customization, better search, etc.\n2. `className`\n3. `id`\n\nWord is essentially a new `span` inside a line. Word can be multilined. Each word has `characters` filed containing content of a word. There are following types of words:\n\n1. `AnchorWord` - `\u003ca\u003e` element with optional `href` and `onClick` fields\n2. `TextWord` - `\u003cspan\u003e` element\n3. `ButtonWord` - `\u003cbutton\u003e` element with optional `onClick` field\n4. `CommandWord` - `\u003cspan\u003e` element with required `prompt` field\n\nThere are two ways of creating `Lines` and `Words`:\n\n1. Using helper functions `textWord`, `buttonWord`, `commandWord`, `anchorWord`, `commandLine`, `textLine`\n2. Using object literals, in this cases you need to import `WordTypes`, `LineTypes` enums\n\n## Styling\n\nEvery element inside terminal has special fixed style, to which you can safely refer to. You can also add your own `className` for lines and words.\n\n## Command history\n\nCommand history saves entered commands, but no more then `maxHistoryCommands`. You can get previous/next saved command by pressing `Arrow Up` / `Arrow Down`\n\n# Repo\n\nIt is a [turborepo](https://turborepo.org/)-based monorepo set up for testing and developing. Library itself is inside packages/crt-terminal, demo app is inside apps/web; to start locally just `yarn dev` in root folder.\n\n# License\n\nMIT Licensed. Copyright (c) Dmitriy Lipin 2022.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessserrr%2Fcrt-terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fessserrr%2Fcrt-terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessserrr%2Fcrt-terminal/lists"}