uikit/dist/remote-ui.js
Mohamadzadeh 414a95a3bb
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 50s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
fix
2026-07-13 15:03:25 +03:30

92 lines
2.5 KiB
JavaScript

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 { 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();
function w(e = {}) {
if (typeof window > "u") return;
const r = window[d] || {}, o = window[s] || {};
window[d] = {
...r,
React: e.React || r.React || g,
createRoot: e.createRoot || r.createRoot || h,
ChakraProvider: e.ChakraProvider || r.ChakraProvider || P,
Badge: e.Badge || r.Badge || E,
theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : r.theme,
chakraProviderProps: {
...r.chakraProviderProps || {},
...e.chakraProviderProps || {}
}
}, window[s] = {
...o,
...e.remoteUrl ? { GBadgeUrl: e.remoteUrl } : {}
};
}
function v() {
typeof window > "u" || window[d] || w();
}
function k() {
var e;
return typeof window > "u" ? p : ((e = window[s]) == null ? void 0 : e.GBadgeUrl) || p;
}
function y() {
const e = k();
return i.has(e) || i.set(
e,
import(
/* webpackIgnore: true */
/* @vite-ignore */
e
).catch((r) => {
throw i.delete(e), r;
})
), i.get(e);
}
function B(e) {
if (typeof e == "string" || typeof e == "number")
return e;
e != null && console.warn(
"[uikit/remote/ui] GBadge only accepts text/number children across the remote boundary."
);
}
const T = ({
children: e,
remoteUrl: r,
theme: o,
chakraProviderProps: f,
...R
}) => {
const c = u(null), t = u(null), a = u(null);
return a.current = {
...R,
children: B(e),
...o !== void 0 ? { theme: o } : {},
...f ? { chakraProviderProps: f } : {}
}, 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);
}), () => {
l = !1, t.current && (t.current.remove(), t.current = null);
};
}, [r]), m(() => {
t.current && (t.current.componentProps = a.current);
}), /* @__PURE__ */ _(
"span",
{
ref: c,
style: {
display: "contents"
}
}
);
};
export {
T as GBadge,
w as setupUikitRemoteDeps
};