pyinkcli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. pyinkcli-0.1.0/.gitignore +154 -0
  2. pyinkcli-0.1.0/LICENSE +10 -0
  3. pyinkcli-0.1.0/PKG-INFO +95 -0
  4. pyinkcli-0.1.0/README.md +59 -0
  5. pyinkcli-0.1.0/pyproject.toml +90 -0
  6. pyinkcli-0.1.0/src/pyinkcli/__init__.py +59 -0
  7. pyinkcli-0.1.0/src/pyinkcli/_component_runtime.py +284 -0
  8. pyinkcli-0.1.0/src/pyinkcli/_restore_cursor.py +39 -0
  9. pyinkcli-0.1.0/src/pyinkcli/_suspense_runtime.py +127 -0
  10. pyinkcli-0.1.0/src/pyinkcli/_yoga.py +501 -0
  11. pyinkcli-0.1.0/src/pyinkcli/ansi_tokenizer.py +323 -0
  12. pyinkcli-0.1.0/src/pyinkcli/colorize.py +157 -0
  13. pyinkcli-0.1.0/src/pyinkcli/component.py +10 -0
  14. pyinkcli-0.1.0/src/pyinkcli/components/AccessibilityContext.py +5 -0
  15. pyinkcli-0.1.0/src/pyinkcli/components/App.py +170 -0
  16. pyinkcli-0.1.0/src/pyinkcli/components/AppContext.py +5 -0
  17. pyinkcli-0.1.0/src/pyinkcli/components/BackgroundContext.py +5 -0
  18. pyinkcli-0.1.0/src/pyinkcli/components/Box.py +89 -0
  19. pyinkcli-0.1.0/src/pyinkcli/components/CursorContext.py +30 -0
  20. pyinkcli-0.1.0/src/pyinkcli/components/ErrorBoundary.py +35 -0
  21. pyinkcli-0.1.0/src/pyinkcli/components/ErrorOverview.py +50 -0
  22. pyinkcli-0.1.0/src/pyinkcli/components/FocusContext.py +40 -0
  23. pyinkcli-0.1.0/src/pyinkcli/components/Newline.py +8 -0
  24. pyinkcli-0.1.0/src/pyinkcli/components/Spacer.py +12 -0
  25. pyinkcli-0.1.0/src/pyinkcli/components/Static.py +67 -0
  26. pyinkcli-0.1.0/src/pyinkcli/components/StderrContext.py +37 -0
  27. pyinkcli-0.1.0/src/pyinkcli/components/StdinContext.py +44 -0
  28. pyinkcli-0.1.0/src/pyinkcli/components/StdoutContext.py +37 -0
  29. pyinkcli-0.1.0/src/pyinkcli/components/Text.py +121 -0
  30. pyinkcli-0.1.0/src/pyinkcli/components/Transform.py +15 -0
  31. pyinkcli-0.1.0/src/pyinkcli/components/__init__.py +29 -0
  32. pyinkcli-0.1.0/src/pyinkcli/components/_accessibility_runtime.py +26 -0
  33. pyinkcli-0.1.0/src/pyinkcli/components/_app_context_runtime.py +45 -0
  34. pyinkcli-0.1.0/src/pyinkcli/components/_background_runtime.py +28 -0
  35. pyinkcli-0.1.0/src/pyinkcli/cursor_helpers.py +116 -0
  36. pyinkcli-0.1.0/src/pyinkcli/dom.py +41 -0
  37. pyinkcli-0.1.0/src/pyinkcli/get_max_width.py +18 -0
  38. pyinkcli-0.1.0/src/pyinkcli/hooks/__init__.py +37 -0
  39. pyinkcli-0.1.0/src/pyinkcli/hooks/_runtime.py +653 -0
  40. pyinkcli-0.1.0/src/pyinkcli/hooks/state.py +30 -0
  41. pyinkcli-0.1.0/src/pyinkcli/hooks/use_app.py +99 -0
  42. pyinkcli-0.1.0/src/pyinkcli/hooks/use_box_metrics.py +80 -0
  43. pyinkcli-0.1.0/src/pyinkcli/hooks/use_cursor.py +98 -0
  44. pyinkcli-0.1.0/src/pyinkcli/hooks/use_focus.py +241 -0
  45. pyinkcli-0.1.0/src/pyinkcli/hooks/use_focus_manager.py +60 -0
  46. pyinkcli-0.1.0/src/pyinkcli/hooks/use_input.py +204 -0
  47. pyinkcli-0.1.0/src/pyinkcli/hooks/use_is_screen_reader_enabled.py +27 -0
  48. pyinkcli-0.1.0/src/pyinkcli/hooks/use_paste.py +52 -0
  49. pyinkcli-0.1.0/src/pyinkcli/hooks/use_stderr.py +88 -0
  50. pyinkcli-0.1.0/src/pyinkcli/hooks/use_stdin.py +198 -0
  51. pyinkcli-0.1.0/src/pyinkcli/hooks/use_stdout.py +146 -0
  52. pyinkcli-0.1.0/src/pyinkcli/hooks/use_window_size.py +32 -0
  53. pyinkcli-0.1.0/src/pyinkcli/index.py +53 -0
  54. pyinkcli-0.1.0/src/pyinkcli/ink.py +1090 -0
  55. pyinkcli-0.1.0/src/pyinkcli/input_parser.py +272 -0
  56. pyinkcli-0.1.0/src/pyinkcli/instances.py +7 -0
  57. pyinkcli-0.1.0/src/pyinkcli/kitty_keyboard.py +30 -0
  58. pyinkcli-0.1.0/src/pyinkcli/log_update.py +285 -0
  59. pyinkcli-0.1.0/src/pyinkcli/measure_element.py +58 -0
  60. pyinkcli-0.1.0/src/pyinkcli/measure_text.py +34 -0
  61. pyinkcli-0.1.0/src/pyinkcli/output.py +5 -0
  62. pyinkcli-0.1.0/src/pyinkcli/packages/__init__.py +2 -0
  63. pyinkcli-0.1.0/src/pyinkcli/packages/ink/__init__.py +68 -0
  64. pyinkcli-0.1.0/src/pyinkcli/packages/ink/dom.py +413 -0
  65. pyinkcli-0.1.0/src/pyinkcli/packages/ink/host_config.py +22 -0
  66. pyinkcli-0.1.0/src/pyinkcli/packages/ink/output.py +669 -0
  67. pyinkcli-0.1.0/src/pyinkcli/packages/ink/render_background.py +41 -0
  68. pyinkcli-0.1.0/src/pyinkcli/packages/ink/render_border.py +92 -0
  69. pyinkcli-0.1.0/src/pyinkcli/packages/ink/render_node_to_output.py +285 -0
  70. pyinkcli-0.1.0/src/pyinkcli/packages/ink/renderer.py +75 -0
  71. pyinkcli-0.1.0/src/pyinkcli/packages/ink/styles.py +474 -0
  72. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/__init__.py +35 -0
  73. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/backend.py +3 -0
  74. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/backend_constants.py +10 -0
  75. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/backend_handlers.py +494 -0
  76. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/backend_inspection.py +319 -0
  77. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/hydration.py +1787 -0
  78. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/src/__init__.py +2 -0
  79. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/src/backend.py +365 -0
  80. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/src/editor.py +164 -0
  81. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/src/standalone.py +166 -0
  82. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/standalone.py +3 -0
  83. pyinkcli-0.1.0/src/pyinkcli/packages/react_devtools_core/window_polyfill.py +28 -0
  84. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactChildFiber.py +451 -0
  85. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactEventPriorities.py +14 -0
  86. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberClassComponent.py +421 -0
  87. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberCommitWork.py +54 -0
  88. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberComponentStack.py +102 -0
  89. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberConfig.py +213 -0
  90. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberContainerUpdate.py +286 -0
  91. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberDevToolsCommands.py +572 -0
  92. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberDevToolsHook.py +81 -0
  93. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberDevToolsInspection.py +1285 -0
  94. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberHostContext.py +29 -0
  95. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconciler.py +108 -0
  96. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerClassComponent.py +182 -0
  97. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerCommands.py +293 -0
  98. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerDevTools.py +26 -0
  99. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerFacade.py +48 -0
  100. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerInspection.py +326 -0
  101. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerMutation.py +150 -0
  102. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerRoot.py +118 -0
  103. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerState.py +153 -0
  104. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberReconcilerWorkLoop.py +70 -0
  105. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberRoot.py +28 -0
  106. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberTreeReflection.py +179 -0
  107. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactFiberWorkLoop.py +86 -0
  108. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/ReactReconcilerConstants.py +9 -0
  109. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/__init__.py +25 -0
  110. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/constants.py +3 -0
  111. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/index.py +3 -0
  112. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/reconciler.py +33 -0
  113. pyinkcli-0.1.0/src/pyinkcli/packages/react_reconciler/reflection.py +3 -0
  114. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/__init__.py +158 -0
  115. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/actions.py +113 -0
  116. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/components.py +317 -0
  117. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/context.py +114 -0
  118. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/errors.py +112 -0
  119. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/hooks.py +266 -0
  120. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/href.py +55 -0
  121. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/router/__init__.py +105 -0
  122. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/router/history.py +234 -0
  123. pyinkcli-0.1.0/src/pyinkcli/packages/react_router/router/utils.py +933 -0
  124. pyinkcli-0.1.0/src/pyinkcli/parse_keypress.py +499 -0
  125. pyinkcli-0.1.0/src/pyinkcli/patch_console.py +89 -0
  126. pyinkcli-0.1.0/src/pyinkcli/py.typed +0 -0
  127. pyinkcli-0.1.0/src/pyinkcli/reconciler.py +4 -0
  128. pyinkcli-0.1.0/src/pyinkcli/render.py +30 -0
  129. pyinkcli-0.1.0/src/pyinkcli/render_background.py +5 -0
  130. pyinkcli-0.1.0/src/pyinkcli/render_border.py +5 -0
  131. pyinkcli-0.1.0/src/pyinkcli/render_node_to_output.py +20 -0
  132. pyinkcli-0.1.0/src/pyinkcli/render_to_string.py +106 -0
  133. pyinkcli-0.1.0/src/pyinkcli/renderer.py +5 -0
  134. pyinkcli-0.1.0/src/pyinkcli/sanitize_ansi.py +44 -0
  135. pyinkcli-0.1.0/src/pyinkcli/squash_text_nodes.py +12 -0
  136. pyinkcli-0.1.0/src/pyinkcli/styles.py +5 -0
  137. pyinkcli-0.1.0/src/pyinkcli/suspense_runtime.py +21 -0
  138. pyinkcli-0.1.0/src/pyinkcli/utils/__init__.py +99 -0
  139. pyinkcli-0.1.0/src/pyinkcli/utils/ansi_escapes.py +227 -0
  140. pyinkcli-0.1.0/src/pyinkcli/utils/cli_boxes.py +135 -0
  141. pyinkcli-0.1.0/src/pyinkcli/utils/string_width.py +93 -0
  142. pyinkcli-0.1.0/src/pyinkcli/utils/wrap_ansi.py +338 -0
  143. pyinkcli-0.1.0/src/pyinkcli/utils.py +23 -0
  144. pyinkcli-0.1.0/src/pyinkcli/wrap_text.py +52 -0
  145. pyinkcli-0.1.0/src/pyinkcli/write_synchronized.py +23 -0
  146. pyinkcli-0.1.0/src/pyinkcli/yoga_compat.py +117 -0
@@ -0,0 +1,154 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+ .pytest_cache/
49
+ pytestdebug.log
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+ db.sqlite3
59
+ db.sqlite3-journal
60
+
61
+ # Flask stuff:
62
+ instance/
63
+ .webassets-cache
64
+
65
+ # Scrapy stuff:
66
+ .scrapy
67
+
68
+ # Sphinx documentation
69
+ docs/_build/
70
+
71
+ # PyBuilder
72
+ .pybuilder/
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # IPython
79
+ profile_default/
80
+ ipython_config.py
81
+
82
+ # pyenv
83
+ .python-version
84
+
85
+ # pipenv
86
+ Pipfile.lock
87
+
88
+ # poetry
89
+ poetry.lock
90
+
91
+ # pdm
92
+ .pdm.toml
93
+ .pdm-python
94
+ .pdm-build/
95
+
96
+ # PEP 582
97
+ __pypackages__/
98
+
99
+ # Celery stuff
100
+ celerybeat-schedule
101
+ celerybeat.pid
102
+
103
+ # SageMath parsed files
104
+ *.sage.py
105
+
106
+ # Environments
107
+ .env
108
+ .venv
109
+ env/
110
+ venv/
111
+ ENV/
112
+ env.bak/
113
+ venv.bak/
114
+
115
+ # Spyder project settings
116
+ .spyderproject
117
+ .spyproject
118
+
119
+ # Rope project settings
120
+ .ropeproject
121
+
122
+ # mkdocs documentation
123
+ /site
124
+
125
+ # mypy
126
+ .mypy_cache/
127
+ .dmypy.json
128
+ dmypy.json
129
+
130
+ # Pyre type checker
131
+ .pyre/
132
+
133
+ # pytype static type analyzer
134
+ .pytype/
135
+
136
+ # Cython debug symbols
137
+ cython_debug/
138
+
139
+ # IDE
140
+ .idea/
141
+ .vscode/
142
+ *.swp
143
+ *.swo
144
+ *~
145
+
146
+ # OS
147
+ .DS_Store
148
+ Thumbs.db
149
+
150
+ # Project specific
151
+ *.pyc
152
+ .pytest_cache/
153
+ .mypy_cache/
154
+ .ruff_cache/
pyinkcli-0.1.0/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ MIT License
2
+
3
+ Copyright (c) Vadym Demedes <vadimdemedes@hey.com> (https://github.com/vadimdemedes)
4
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyinkcli
3
+ Version: 0.1.0
4
+ Summary: Python fork and translation of Ink for building terminal UIs
5
+ Project-URL: Homepage, https://github.com/quantmew/pyinkcli
6
+ Project-URL: Documentation, https://github.com/quantmew/pyinkcli#readme
7
+ Project-URL: Repository, https://github.com/quantmew/pyinkcli
8
+ Project-URL: Issues, https://github.com/quantmew/pyinkcli/issues
9
+ Author: Quantmew Contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: cli,component,console,ink,react,terminal,ui
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: Terminals
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Requires-Dist: colorama>=0.4.0
28
+ Requires-Dist: wcwidth>=0.2.0
29
+ Requires-Dist: yoga-layout-python>=0.1.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
33
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # pyinkcli
38
+
39
+ <div align="center">
40
+ <br>
41
+ <img width="220" alt="pyinkcli" src="media/logo.png">
42
+ <br>
43
+ <br>
44
+ </div>
45
+
46
+ > A Python fork and translation project of [Ink](https://github.com/vadimdemedes/ink) for building terminal UIs with a React-like component model.
47
+
48
+ `pyinkcli` is a Python implementation inspired by and translated from Ink. This repository is a fork, not the official Node.js package, and the API is adapted for Python where needed.
49
+
50
+ <div align="center">
51
+ <img src="media/demo.svg" width="640" alt="Ink demo">
52
+ </div>
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ pip install pyinkcli
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```python
63
+ from pyinkcli import Box, Text, render
64
+
65
+
66
+ def Counter():
67
+ return Box(
68
+ Text("Hello from pyinkcli", color="green", bold=True),
69
+ flexDirection="column",
70
+ alignItems="center",
71
+ )
72
+
73
+
74
+ app = render(Counter)
75
+ app.wait_until_exit()
76
+ ```
77
+
78
+ ## What This Repo Is
79
+
80
+ - A Python fork of Ink focused on translating the terminal UI model into Python
81
+ - A repo that keeps the upstream JS implementation nearby for parity work and audits
82
+ - A place for Python-native examples and tests under `examples/` and `tests/`
83
+
84
+ ## Examples
85
+
86
+ - `examples/alternate-screen/`
87
+ - `examples/chat/`
88
+ - `examples/counter/`
89
+ - `examples/terminal-resize/`
90
+ - `examples/use-focus/`
91
+ - `examples/use-input/`
92
+
93
+ ## License
94
+
95
+ MIT. The repository includes the upstream Ink license text in [`LICENSE`](LICENSE).
@@ -0,0 +1,59 @@
1
+ # pyinkcli
2
+
3
+ <div align="center">
4
+ <br>
5
+ <img width="220" alt="pyinkcli" src="media/logo.png">
6
+ <br>
7
+ <br>
8
+ </div>
9
+
10
+ > A Python fork and translation project of [Ink](https://github.com/vadimdemedes/ink) for building terminal UIs with a React-like component model.
11
+
12
+ `pyinkcli` is a Python implementation inspired by and translated from Ink. This repository is a fork, not the official Node.js package, and the API is adapted for Python where needed.
13
+
14
+ <div align="center">
15
+ <img src="media/demo.svg" width="640" alt="Ink demo">
16
+ </div>
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pip install pyinkcli
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ```python
27
+ from pyinkcli import Box, Text, render
28
+
29
+
30
+ def Counter():
31
+ return Box(
32
+ Text("Hello from pyinkcli", color="green", bold=True),
33
+ flexDirection="column",
34
+ alignItems="center",
35
+ )
36
+
37
+
38
+ app = render(Counter)
39
+ app.wait_until_exit()
40
+ ```
41
+
42
+ ## What This Repo Is
43
+
44
+ - A Python fork of Ink focused on translating the terminal UI model into Python
45
+ - A repo that keeps the upstream JS implementation nearby for parity work and audits
46
+ - A place for Python-native examples and tests under `examples/` and `tests/`
47
+
48
+ ## Examples
49
+
50
+ - `examples/alternate-screen/`
51
+ - `examples/chat/`
52
+ - `examples/counter/`
53
+ - `examples/terminal-resize/`
54
+ - `examples/use-focus/`
55
+ - `examples/use-input/`
56
+
57
+ ## License
58
+
59
+ MIT. The repository includes the upstream Ink license text in [`LICENSE`](LICENSE).
@@ -0,0 +1,90 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pyinkcli"
7
+ dynamic = ["version"]
8
+ description = "Python fork and translation of Ink for building terminal UIs"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "Quantmew Contributors" }
14
+ ]
15
+ keywords = [
16
+ "cli",
17
+ "console",
18
+ "terminal",
19
+ "ui",
20
+ "react",
21
+ "ink",
22
+ "component",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Environment :: Console",
27
+ "Intended Audience :: Developers",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Topic :: Software Development :: Libraries :: Python Modules",
36
+ "Topic :: Terminals",
37
+ "Typing :: Typed",
38
+ ]
39
+ dependencies = [
40
+ "wcwidth>=0.2.0",
41
+ "colorama>=0.4.0",
42
+ "yoga-layout-python>=0.1.0",
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ dev = [
47
+ "pytest>=7.0.0",
48
+ "pytest-asyncio>=0.21.0",
49
+ "mypy>=1.0.0",
50
+ "ruff>=0.1.0",
51
+ ]
52
+
53
+ [project.urls]
54
+ Homepage = "https://github.com/quantmew/pyinkcli"
55
+ Documentation = "https://github.com/quantmew/pyinkcli#readme"
56
+ Repository = "https://github.com/quantmew/pyinkcli"
57
+ Issues = "https://github.com/quantmew/pyinkcli/issues"
58
+
59
+ [tool.hatch.build.targets.wheel]
60
+ packages = ["src/pyinkcli"]
61
+
62
+ [tool.hatch.build.targets.sdist]
63
+ include = [
64
+ "/src/pyinkcli",
65
+ "/README.md",
66
+ "/LICENSE",
67
+ ]
68
+
69
+ [tool.hatch.metadata]
70
+ allow-direct-references = true
71
+
72
+ [tool.hatch.version]
73
+ path = "src/pyinkcli/__init__.py"
74
+
75
+ [tool.ruff]
76
+ line-length = 100
77
+ target-version = "py310"
78
+
79
+ [tool.ruff.lint]
80
+ select = ["E", "F", "I", "N", "W", "UP", "B", "C4", "SIM"]
81
+
82
+ [tool.mypy]
83
+ python_version = "3.10"
84
+ strict = true
85
+ warn_return_any = true
86
+ warn_unused_ignores = true
87
+
88
+ [tool.pytest.ini_options]
89
+ asyncio_mode = "auto"
90
+ testpaths = ["tests"]
@@ -0,0 +1,59 @@
1
+ """pyinkcli public package surface."""
2
+
3
+ from pyinkcli.index import (
4
+ DOMElement,
5
+ Box,
6
+ Key,
7
+ Newline,
8
+ Spacer,
9
+ Static,
10
+ Text,
11
+ Transform,
12
+ kittyFlags,
13
+ kittyModifiers,
14
+ measureElement,
15
+ render,
16
+ renderToString,
17
+ useApp,
18
+ useBoxMetrics,
19
+ useCursor,
20
+ useFocus,
21
+ useFocusManager,
22
+ useInput,
23
+ useIsScreenReaderEnabled,
24
+ usePaste,
25
+ useStderr,
26
+ useStdin,
27
+ useStdout,
28
+ useWindowSize,
29
+ )
30
+
31
+ __version__ = "0.1.0"
32
+
33
+ __all__ = [
34
+ "render",
35
+ "renderToString",
36
+ "Box",
37
+ "Text",
38
+ "Static",
39
+ "Transform",
40
+ "Newline",
41
+ "Spacer",
42
+ "Key",
43
+ "useInput",
44
+ "usePaste",
45
+ "useApp",
46
+ "useStdin",
47
+ "useStdout",
48
+ "useStderr",
49
+ "useFocus",
50
+ "useFocusManager",
51
+ "useIsScreenReaderEnabled",
52
+ "useCursor",
53
+ "useWindowSize",
54
+ "useBoxMetrics",
55
+ "measureElement",
56
+ "DOMElement",
57
+ "kittyFlags",
58
+ "kittyModifiers",
59
+ ]