Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/react-lang/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openuidev/react-lang",
"version": "0.2.14",
"version": "0.2.15",
"description": "Define component libraries, generate LLM system prompts, and render streaming OpenUI Lang output in React — the core runtime for OpenUI generative UI",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -82,7 +82,6 @@
},
"author": "engineering@thesys.dev",
"dependencies": {
"@openuidev/devtools": "workspace:^",
"@openuidev/lang-core": "workspace:^",
"@openuidev/observability": "workspace:^"
},
Expand Down
37 changes: 26 additions & 11 deletions packages/react-lang/src/devtoolsBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*
* This module runs as a top-level side effect when the web entry is loaded in
* a browser. In production builds the whole block is dead-code-eliminated by
* the consumer's bundler (the NODE_ENV condition folds to false), so neither
* `@openuidev/devtools` nor `react-dom/client` enters the production graph.
* The React Native entry (index.native.ts) never imports this module.
* the consumer's bundler (the NODE_ENV condition folds to false), so
* `react-dom` / `react-dom/client` never enter the production graph, and
* nothing is fetched. The React Native entry (index.native.ts) never imports
* this module.
*
* This module is inlined into the web entry (dist/index.*), which is listed
* in package.json's `sideEffects` so bundlers preserve the side effect while
Expand All @@ -21,15 +22,29 @@ if (process.env.NODE_ENV === "development" && typeof document !== "undefined") {
// (ESM/CJS dual build, multiple package versions).
if (!flags[AUTO_MOUNT_FLAG]) {
flags[AUTO_MOUNT_FLAG] = true;
Promise.all([import("@openuidev/devtools"), import("react"), import("react-dom/client")])
.then(([devtools, react, reactDomClient]) => {

// Pinned to the protocol major, not @latest: cached for days, and a
// protocol-breaking release (mount() args, Symbol keys, event kinds)
// would otherwise take down every app that hasn't bumped.
const url = "https://cdn.jsdelivr.net/npm/@openuidev/devtools@0/dist/devtools.browser.js";

Promise.all([
import(/* webpackIgnore: true */ /* @vite-ignore */ url),
import("react"),
import("react-dom"),
import("react-dom/client"),
])
.then(([devtools, react, reactDom, reactDomClient]) => {
const mount = () => {
const host = document.createElement("div");
host.setAttribute("data-openui-devtools-root", "");
document.body.appendChild(host);
reactDomClient
.createRoot(host)
.render(react.createElement(devtools.OpenUIDevtools, { __autoMounted: true }));
devtools.mountOpenUIDevtools({
React: react,
ReactDOM: reactDom,
ReactDOMClient: reactDomClient,
// Closed over this module's graph so the bundler resolves it —
// the CDN file never imports "@openuidev/react-lang" itself.
loadReactLang: () => import("@openuidev/react-lang"),
__autoMounted: true,
});
};
// Module evaluation can happen before <body> exists (script in <head>).
if (document.body) mount();
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading