From 0a14270aaa3692d89da001842864e8f34574c95a Mon Sep 17 00:00:00 2001 From: Mohamadzadeh <7796733@gmail.com> Date: Mon, 13 Jul 2026 15:07:58 +0330 Subject: [PATCH] fix --- dist/remote-ui.js | 56 +++++++++++++++++++++-------------------- src/remote/ui/index.jsx | 9 ++++++- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/dist/remote-ui.js b/dist/remote-ui.js index 620a1ef..4ae70b7 100644 --- a/dist/remote-ui.js +++ b/dist/remote-ui.js @@ -1,15 +1,15 @@ -import { jsx as _ } from "react/jsx-runtime"; -import g, { useRef as u, useEffect as m } from "react"; -import { createRoot as h } from "react-dom/client"; +import { jsx as g } from "react/jsx-runtime"; +import h, { useRef as u, useEffect as m } from "react"; +import { createRoot as _ } from "react-dom/client"; import { Badge as E, ChakraProvider as P } from "@chakra-ui/react"; -const p = "https://uikit.d.aiengines.ir/GBadge.js", d = "__UIKIT_REMOTE_DEPS__", s = "__UIKIT_REMOTE_CONFIG__", i = /* @__PURE__ */ new Map(); +const R = "https://uikit.d.aiengines.ir/GBadge.js", d = "__UIKIT_REMOTE_DEPS__", f = "__UIKIT_REMOTE_CONFIG__", i = /* @__PURE__ */ new Map(); function w(e = {}) { if (typeof window > "u") return; - const r = window[d] || {}, o = window[s] || {}; + const r = window[d] || {}, n = window[f] || {}; window[d] = { ...r, - React: e.React || r.React || g, - createRoot: e.createRoot || r.createRoot || h, + React: e.React || r.React || h, + createRoot: e.createRoot || r.createRoot || _, ChakraProvider: e.ChakraProvider || r.ChakraProvider || P, Badge: e.Badge || r.Badge || E, theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : r.theme, @@ -17,17 +17,19 @@ function w(e = {}) { ...r.chakraProviderProps || {}, ...e.chakraProviderProps || {} } - }, window[s] = { - ...o, + }, window[f] = { + ...n, ...e.remoteUrl ? { GBadgeUrl: e.remoteUrl } : {} }; } function v() { - typeof window > "u" || window[d] || w(); + if (typeof window > "u") return; + const e = window[d]; + (!(e != null && e.React) || !(e != null && e.createRoot) || !(e != null && e.ChakraProvider) || !(e != null && e.Badge)) && w(); } function k() { var e; - return typeof window > "u" ? p : ((e = window[s]) == null ? void 0 : e.GBadgeUrl) || p; + return typeof window > "u" ? R : ((e = window[f]) == null ? void 0 : e.GBadgeUrl) || R; } function y() { const e = k(); @@ -52,33 +54,33 @@ function B(e) { const T = ({ children: e, remoteUrl: r, - theme: o, - chakraProviderProps: f, - ...R + theme: n, + chakraProviderProps: s, + ...p }) => { - const c = u(null), t = u(null), a = u(null); - return a.current = { - ...R, + const a = u(null), t = u(null), c = u(null); + return c.current = { + ...p, children: B(e), - ...o !== void 0 ? { theme: o } : {}, - ...f ? { chakraProviderProps: f } : {} + ...n !== void 0 ? { theme: n } : {}, + ...s ? { chakraProviderProps: s } : {} }, m(() => { let l = !0; return v(), r && w({ remoteUrl: r }), y().then(() => { - if (!l || !c.current) return; - const n = document.createElement("uikit-g-badge"); - n.componentProps = a.current, c.current.appendChild(n), t.current = n; - }).catch((n) => { - console.error("[uikit/remote/ui] Failed to load GBadge:", n); + if (!l || !a.current) return; + const o = document.createElement("uikit-g-badge"); + o.componentProps = c.current, a.current.appendChild(o), t.current = o; + }).catch((o) => { + console.error("[uikit/remote/ui] Failed to load GBadge:", o); }), () => { l = !1, t.current && (t.current.remove(), t.current = null); }; }, [r]), m(() => { - t.current && (t.current.componentProps = a.current); - }), /* @__PURE__ */ _( + t.current && (t.current.componentProps = c.current); + }), /* @__PURE__ */ g( "span", { - ref: c, + ref: a, style: { display: "contents" } diff --git a/src/remote/ui/index.jsx b/src/remote/ui/index.jsx index b6d084a..dd7a2ac 100644 --- a/src/remote/ui/index.jsx +++ b/src/remote/ui/index.jsx @@ -41,7 +41,14 @@ export function setupUikitRemoteDeps(options = {}) { function ensureRemoteDeps() { if (typeof window === "undefined") return; - if (!window[REMOTE_DEPS_KEY]) { + const deps = window[REMOTE_DEPS_KEY]; + + if ( + !deps?.React || + !deps?.createRoot || + !deps?.ChakraProvider || + !deps?.Badge + ) { setupUikitRemoteDeps(); } }