Skip to content

React client - #8

Open
jlee-kitware wants to merge 2 commits into
masterfrom
react-client
Open

jlee-kitware wants to merge 2 commits into
masterfrom
react-client

Conversation

@jlee-kitware

Copy link
Copy Markdown
Collaborator

The editor only worked under the Vue client, so apps running with
client_type="react" had no code editor.

Adds a React bundle alongside the Vue one. setup() serves whichever matches the
server's client type. The widget branches as well, since the editor is v-model
based and the two clients spell that binding differently: React declares value
and onChange through self.props/self.events, Vue keeps modelValue and
input. Same shape as trame-vtklocal. Completion and hover still go through
window.trame.trigger, so the Python side is unchanged. The component is TSX
built against React 19, the version trame-client ships.

For review:

  • The Monaco worker URL now matches .umd.cjs as well as .umd.js, since that
    is what the React bundle builds as. Without it, workers fall back to the old
    unversioned path and 404.
  • react-components stays on Vite 4: vite-plugin-monaco-editor needs esbuild,
    which the rolldown based Vite 8 dropped.
  • CI builds the React bundle after the Vue one, which runs --emptyOutDir on the
    shared serve directory.
  • @shared aliases to vue-components/src so utils/ and themes/ exist once.
    trame-rca keeps parallel copies instead; happy to match that if preferred.

Verified against the example and a real app: editor mounts and binds, edits round
trip, completion and hover populate from Python, workers load from the versioned
directory.

Adds react-components/ mirroring vue-components/: the Monaco editor as a
React component, with utils/ and themes/ shared by alias rather than
copied. The module descriptor picks the bundle from server.client_type,
and the widget declares value/onChange for react instead of v-model,
since react has no two-way binding directive.

The completion/hover callbacks keep the same trigger contract, so python
consumers are unchanged.

Also fixes the monaco worker URL: the module serves its assets from a
versioned directory but the bundle asked for the unversioned path, so
worker creation failed and monaco fell back to the main thread. The base
is now derived from the script tag that loaded the bundle.
Aligns with trame-vtklocal and trame-rca: the widget declares react props
and events through self.props/self.events rather than _attr_names, which
is the documented surface and the only one that routes events correctly.

react-components is TypeScript now, built against react 19 to match the
version trame-client ships. That removes two workarounds: the classic jsx
runtime (needed only because react 18's jsx-runtime reaches into internals
react 19 dropped) and a global process shim.

Vite stays on 4 here rather than 8, since vite-plugin-monaco-editor needs
esbuild and the rolldown-based vite 8 no longer provides it.

CI builds the react bundle after the vue one in both the test and release
jobs; the vue build empties the shared serve directory, so order matters.
@jlee-kitware
jlee-kitware requested a review from jourdain October 18, 2026 13:33
@jlee-kitware jlee-kitware self-assigned this Oct 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant