|
| 1 | +# JS-to-Python Translation Map |
| 2 | + |
| 3 | +This repository keeps the upstream JS sources in `js_source/` and targets a |
| 4 | +Python source tree at `src/pyinkcli/`. |
| 5 | + |
| 6 | +## Ground Rules |
| 7 | + |
| 8 | +- Translation source of truth is upstream JS only. |
| 9 | +- No `git`-based inspection of any previous Python implementation is allowed. |
| 10 | +- Public names should stay as close as possible to upstream Ink/React export |
| 11 | + names, while Python files keep the package layout expected by this repo. |
| 12 | + |
| 13 | +## Ink Core |
| 14 | + |
| 15 | +The critical Ink execution chain in `js_source/ink/src` is: |
| 16 | + |
| 17 | +`index.ts` -> `render.ts` -> `ink.tsx` -> `components/App.tsx` + |
| 18 | +`reconciler.ts` + `renderer.ts` -> `render-node-to-output.ts` / `dom.ts` / |
| 19 | +`output.ts` |
| 20 | + |
| 21 | +Recommended translation priority: |
| 22 | + |
| 23 | +1. Runtime core |
| 24 | +2. Rendering/layout helpers |
| 25 | +3. Public components |
| 26 | +4. Public hooks |
| 27 | + |
| 28 | +## Runtime Core Mapping |
| 29 | + |
| 30 | +| JS source | Python target | Role | |
| 31 | +| --- | --- | --- | |
| 32 | +| `js_source/ink/src/index.ts` | `src/pyinkcli/index.py` | Public entrypoint and export surface | |
| 33 | +| `js_source/ink/src/render.ts` | `src/pyinkcli/render.py` | Render API and instance lifecycle | |
| 34 | +| `js_source/ink/src/ink.tsx` | `src/pyinkcli/ink.py` | Runtime coordinator | |
| 35 | +| `js_source/ink/src/reconciler.ts` | `src/pyinkcli/reconciler.py` | Host reconciler bridge | |
| 36 | +| `js_source/ink/src/dom.ts` | `src/pyinkcli/dom.py` | Ink DOM and layout nodes | |
| 37 | +| `js_source/ink/src/renderer.ts` | `src/pyinkcli/renderer.py` | DOM-to-output adapter | |
| 38 | +| `js_source/ink/src/output.ts` | `src/pyinkcli/output.py` | Buffered output model | |
| 39 | +| `js_source/ink/src/styles.ts` | `src/pyinkcli/styles.py` | Public style type surface | |
| 40 | + |
| 41 | +## Rendering/Layout Mapping |
| 42 | + |
| 43 | +| JS source | Python target | |
| 44 | +| --- | --- | |
| 45 | +| `js_source/ink/src/render-node-to-output.ts` | `src/pyinkcli/render_node_to_output.py` | |
| 46 | +| `js_source/ink/src/render-to-string.ts` | `src/pyinkcli/render_to_string.py` | |
| 47 | +| `js_source/ink/src/render-border.ts` | `src/pyinkcli/render_border.py` | |
| 48 | +| `js_source/ink/src/render-background.ts` | `src/pyinkcli/render_background.py` | |
| 49 | +| `js_source/ink/src/measure-text.ts` | `src/pyinkcli/measure_text.py` | |
| 50 | +| `js_source/ink/src/measure-element.ts` | `src/pyinkcli/measure_element.py` | |
| 51 | +| `js_source/ink/src/wrap-text.ts` | `src/pyinkcli/wrap_text.py` | |
| 52 | +| `js_source/ink/src/get-max-width.ts` | `src/pyinkcli/get_max_width.py` | |
| 53 | +| `js_source/ink/src/ansi-tokenizer.ts` | `src/pyinkcli/ansi_tokenizer.py` | |
| 54 | +| `js_source/ink/src/sanitize-ansi.ts` | `src/pyinkcli/sanitize_ansi.py` | |
| 55 | +| `js_source/ink/src/squash-text-nodes.ts` | `src/pyinkcli/squash_text_nodes.py` | |
| 56 | +| `js_source/ink/src/colorize.ts` | `src/pyinkcli/colorize.py` | |
| 57 | + |
| 58 | +## Components Mapping |
| 59 | + |
| 60 | +| JS source | Python target | |
| 61 | +| --- | --- | |
| 62 | +| `js_source/ink/src/components/Box.tsx` | `src/pyinkcli/components/Box.py` | |
| 63 | +| `js_source/ink/src/components/Text.tsx` | `src/pyinkcli/components/Text.py` | |
| 64 | +| `js_source/ink/src/components/Static.tsx` | `src/pyinkcli/components/Static.py` | |
| 65 | +| `js_source/ink/src/components/Transform.tsx` | `src/pyinkcli/components/Transform.py` | |
| 66 | +| `js_source/ink/src/components/Newline.tsx` | `src/pyinkcli/components/Newline.py` | |
| 67 | +| `js_source/ink/src/components/Spacer.tsx` | `src/pyinkcli/components/Spacer.py` | |
| 68 | +| `js_source/ink/src/components/App.tsx` | `src/pyinkcli/components/App.py` | |
| 69 | +| `js_source/ink/src/components/ErrorBoundary.tsx` | `src/pyinkcli/components/ErrorBoundary.py` | |
| 70 | +| `js_source/ink/src/components/ErrorOverview.tsx` | `src/pyinkcli/components/ErrorOverview.py` | |
| 71 | + |
| 72 | +## Context Mapping |
| 73 | + |
| 74 | +| JS source | Python target | |
| 75 | +| --- | --- | |
| 76 | +| `js_source/ink/src/components/AccessibilityContext.ts` | `src/pyinkcli/components/AccessibilityContext.py` | |
| 77 | +| `js_source/ink/src/components/AppContext.ts` | `src/pyinkcli/components/AppContext.py` | |
| 78 | +| `js_source/ink/src/components/BackgroundContext.ts` | `src/pyinkcli/components/BackgroundContext.py` | |
| 79 | +| `js_source/ink/src/components/CursorContext.ts` | `src/pyinkcli/components/CursorContext.py` | |
| 80 | +| `js_source/ink/src/components/FocusContext.ts` | `src/pyinkcli/components/FocusContext.py` | |
| 81 | +| `js_source/ink/src/components/StderrContext.ts` | `src/pyinkcli/components/StderrContext.py` | |
| 82 | +| `js_source/ink/src/components/StdinContext.ts` | `src/pyinkcli/components/StdinContext.py` | |
| 83 | +| `js_source/ink/src/components/StdoutContext.ts` | `src/pyinkcli/components/StdoutContext.py` | |
| 84 | + |
| 85 | +## Hooks Mapping |
| 86 | + |
| 87 | +| JS source | Python target | |
| 88 | +| --- | --- | |
| 89 | +| `js_source/ink/src/hooks/use-app.ts` | `src/pyinkcli/hooks/use_app.py` | |
| 90 | +| `js_source/ink/src/hooks/use-box-metrics.ts` | `src/pyinkcli/hooks/use_box_metrics.py` | |
| 91 | +| `js_source/ink/src/hooks/use-cursor.ts` | `src/pyinkcli/hooks/use_cursor.py` | |
| 92 | +| `js_source/ink/src/hooks/use-focus-manager.ts` | `src/pyinkcli/hooks/use_focus_manager.py` | |
| 93 | +| `js_source/ink/src/hooks/use-focus.ts` | `src/pyinkcli/hooks/use_focus.py` | |
| 94 | +| `js_source/ink/src/hooks/use-input.ts` | `src/pyinkcli/hooks/use_input.py` | |
| 95 | +| `js_source/ink/src/hooks/use-is-screen-reader-enabled.ts` | `src/pyinkcli/hooks/use_is_screen_reader_enabled.py` | |
| 96 | +| `js_source/ink/src/hooks/use-paste.ts` | `src/pyinkcli/hooks/use_paste.py` | |
| 97 | +| `js_source/ink/src/hooks/use-stderr.ts` | `src/pyinkcli/hooks/use_stderr.py` | |
| 98 | +| `js_source/ink/src/hooks/use-stdin.ts` | `src/pyinkcli/hooks/use_stdin.py` | |
| 99 | +| `js_source/ink/src/hooks/use-stdout.ts` | `src/pyinkcli/hooks/use_stdout.py` | |
| 100 | +| `js_source/ink/src/hooks/use-window-size.ts` | `src/pyinkcli/hooks/use_window_size.py` | |
| 101 | + |
| 102 | +## React-family Test Surface |
| 103 | + |
| 104 | +Tests in `tests/` currently pin these Python-side package families: |
| 105 | + |
| 106 | +- `pyinkcli.packages.react` |
| 107 | +- `pyinkcli.packages.react_reconciler` |
| 108 | +- `pyinkcli.packages.react_devtools_core` |
| 109 | +- `pyinkcli.packages.react_router` |
| 110 | + |
| 111 | +These packages need to preserve JS-like symbol names even when the Python |
| 112 | +implementation uses snake_case internally. |
0 commit comments