Skip to content

The Open Standard for Generative UI

Update JSXS implementation & Timestamp for client-side cache busting (#1082)

ABfa6657209110
diff --git a/packages/devtools/package.json b/packages/devtools/package.json
index 39463f0cd..a5b2785b6 100644
--- a/packages/devtools/package.json
+++ b/packages/devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/devtools",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Development-only UI widget for OpenUI apps: surfaces errors captured by @openuidev/observability",
"license": "MIT",
"type": "module",
diff --git a/packages/devtools/src/OpenUIDevtoolsWidget.tsx b/packages/devtools/src/OpenUIDevtoolsWidget.tsx
index 2ccc902c2..5145126eb 100644
--- a/packages/devtools/src/OpenUIDevtoolsWidget.tsx
+++ b/packages/devtools/src/OpenUIDevtoolsWidget.tsx
@@ -27,7 +27,7 @@ import {
useStyles,
type ThemeTokens,
} from "./theme";
-import type { OpenUIDevtoolsWidgetProps } from "./types";
+import type { DevtoolsPosition, OpenUIDevtoolsWidgetProps } from "./types";
import { ErrorBoundary, IconButton, ShiroLogo, ThemeSegmented } from "./ui";
import ReliabilityBanner from "./ui/ReliabilityBanner";
diff --git a/packages/devtools/src/browser-shims/jsx-runtime.ts b/packages/devtools/src/browser-shims/jsx-runtime.ts
index ae45ee19a..3767a6ab2 100644
--- a/packages/devtools/src/browser-shims/jsx-runtime.ts
+++ b/packages/devtools/src/browser-shims/jsx-runtime.ts
@@ -5,8 +5,32 @@ const react = requireReact();
export const Fragment = react.Fragment;
-export function jsx(type: unknown, props: Record<string, unknown>, key?: string) {
- return react.createElement(type as never, key === undefined ? props : { ...props, key });
+/**
+ * `createElement` key-validates any array found in `props.children`, so
+ * children must be lifted out of props and passed positionally. `jsx` keeps
+ * its single child as one argument (a dynamic array still warns, as it
+ * should); `jsxs` spreads its compiler-proven-static list into varargs,
+ * which createElement treats as pre-validated — matching the real
+ * `react/jsx-runtime` semantics the browser build cannot import.
+ */
+function split(props: Record<string, unknown>, key?: string) {
+ const { children, ...rest } = props;
+ return { children, props: key === undefined ? rest : { ...rest, key } };
}
-export const jsxs = jsx;
+export function jsx(type: unknown, allProps: Record<string, unknown>, key?: string) {
+ const { children, props } = split(allProps, key);
+ return children === undefined
+ ? react.createElement(type as never, props)
+ : react.createElement(type as never, props, children as never);
+}
+
+export function jsxs(type: unknown, allProps: Record<string, unknown>, key?: string) {
+ const { children, props } = split(allProps, key);
+ if (Array.isArray(children)) {
+ return react.createElement(type as never, props, ...(children as never[]));
+ }
+ return children === undefined
+ ? react.createElement(type as never, props)
+ : react.createElement(type as never, props, children as never);
+}
diff --git a/packages/devtools/src/cdn.ts b/packages/devtools/src/cdn.ts
index 3395c4b0b..dbd807d9d 100644
--- a/packages/devtools/src/cdn.ts
+++ b/packages/devtools/src/cdn.ts
@@ -18,10 +18,14 @@ export function normalizeCdnVersion(version?: string): string | null {
* Omit `version` → `@latest`. Otherwise major (`"0"`), minor (`"0.1"`),
* or exact (`"0.1.0"`) npm tags.
*/
+const ALIAS_CACHE_MS = 5 * 60 * 1000;
+
export function browserBundleUrl(version?: string): string | null {
const tag = normalizeCdnVersion(version);
if (tag === null) return null;
- return `https://cdn.jsdelivr.net/npm/@openuidev/devtools@${tag}/dist/devtools.browser.js`;
+ const url = `https://cdn.jsdelivr.net/npm/@openuidev/devtools@${tag}/dist/devtools.browser.js`;
+ if (/^\d+\.\d+\.\d+$/.test(tag)) return url;
+ return `${url}?t=${Math.floor(Date.now() / ALIAS_CACHE_MS)}`;
}
export type MountFromCdnOptions = OpenUIDevtoolsProps;
diff --git a/packages/devtools/src/theme.ts b/packages/devtools/src/theme.ts
index a3b3b72a7..68b842a3f 100644
--- a/packages/devtools/src/theme.ts
+++ b/packages/devtools/src/theme.ts
@@ -178,7 +178,7 @@ export function rootStyle(mode: ColorMode): { colorScheme: ColorMode } {
const ModeContext = createContext<ColorMode>(DEFAULT_COLOR_MODE);
export function DevtoolsModeProvider({ mode, children }: { mode: ColorMode; children: ReactNode }) {
- return createElement(ModeContext.Provider, { value: mode }, children);
+ return createElement(ModeContext.Provider, { value: mode, children });
}
/** The mode chosen in Settings, shared with the Debug tray and popup. */