Better compatibility with ReactJS Packages
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 22/100
调研方向
Start by reading the current component_from_npm interface and the re-engineered JavaScript API issue #1001, then map the proposed build, install, uninstall, download-bun, and upgrade-bun commands. Done would require a decided design covering package generation, Bun handling, Python interfaces, and ReactJS compatibility, but this issue names no files or tests.
由索引模型根据 Issue 内容生成。
描述
TLDR
We want users to be able to use ReactJS components from NPM in a similar level of complexity to a pip install. This will require developing ReactPy Package Manager. This tool will pull packages down using Bun, statically build/analyze them, then auto-generate a Python file containing the usable interface.
The alternative option for power users is using the re-engineered the JavaScript API to leverage any standard JavaScript tooling.
Current Situation
It's not reasonable manually translate every ReactJS component to a Python, and the current component_from_npm interface is not able to give Python type hints for functions (technological limitation). This ultimately necessitates automating the generation of ReactPy JavaScript component APIs.
Design Concept
Create a ReactPy build step can automatically generate Python wrappers of JavaScript functionality. Ideally, this machine generated Python would also include type hints that are automatically inferred from the JavaScript code. We will need some method of determining variable names from the JavaScript source. This likely will involve using a JavaScript AST parser (or TypeScript AST parser).
A generated Python file for a react-bootstrap Card could potentially look something like this:
_Card = component_from_file(file=Path(__file__).parent / "dist" / "react-bootstrap.js", import_names=["Card"])
def Card(bsPrefix=None, className=None, bg=None, text=None, border=None, body=None, children=None, as='div', body=False):
return _Card(bsPrefix, className, bg, text, border, body, children, as, body)
How to handle JavaScript
Automatic type hints are only half the battle for ReactJS package compatibility.
A bigger question is, how do we make sure things written for ReactJS are compatible with ReactPy? As a goal, we should investigate how to best fully interface with the top 100 React libraries on NPM.
This might necessitate rethinking our JavaScript API layer in order to access JavaScript data/attributes/modules/hooks/etc. We should consider rewriting our client using an proxy object system. The end goal is to have compatibility for all the potential pieces within a ReactJS module, such as:
- Hooks
- Events
- Components
- Variables
- Props
- Child Elements
refvalues within props
Command Line Interface
The CLI should be accessible within the reactpy <command> namespace.
We should probably follow the same precedence as Playwright/Selenium. If the user tries to use a command, we should first check if bun has been installed. If it hasn't, we will tell the user to run reactpy download-bun.
build command
- User generated packages will need a
package.jsonusing the standard format - Users must declare their own
dependencieswithin apackage.json reactpy build <DIR>will build a single package.- We will output the Python code (and JavaScript source) into
reactpy.reactjs.<pkg_name>, unless a different output file is specified via--outdir. - Automatically create a
.gitignorecontaining*within the output dir, as this built code should be assumed as ephemeral.
install command
- Should have a
--outdiroption - Should have a
--exports=...option to limit what gets built - Installed modules are accessible within Python via
reactpy.reactjs.<pkg_name>
uninstall command
uninstallcommand should have an--alloption
download-bun command
- Downloads
bunto the current environment, similar to howseleniumorplaywrightcan download Chromium via command line. - Ignores subsequent requests to download bun, if it already exists.
upgrade-bun command
- Runs
bun upgradeto put the user on the latest version of bun
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 332
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reactive-python/reactpy 的其他 Issue
-
priority-3-low type-docs
难度 2/5 1-3 小时 新手友好度 65/100
reactive-python/reactpy#1034 ·
-
priority-2-moderate type-revision
难度 5/5 一周以上 新手友好度 25/100
reactive-python/reactpy#1319 ·
-
priority-1-high
难度 5/5 一周以上 新手友好度 25/100
reactive-python/reactpy#1277 ·
-
priority-3-low
难度 5/5 一周以上 新手友好度 35/100
reactive-python/reactpy#1273 · 1 个 reaction ·
-
priority-2-moderate
难度 5/5 一周以上 新手友好度 30/100
reactive-python/reactpy#1272 · 2 个 reaction ·
查看 reactive-python/reactpy 的全部 Issue
相似的 Issue
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
bancolombia/sentinel#23 ·
-
test md 未关闭CI
难度 2/5 1-3 小时 新手友好度 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
难度 2/5 1-3 小时 新手友好度 74/100
langchain-ai/deepagents#6450 ·
-
bug client
难度 2/5 1-3 小时 新手友好度 88/100