randmarcomps 1.154.0 → 1.156.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/randmarcomps.d.ts +2 -2
- package/dist/randmarcomps.js +15 -15
- package/dist/randmarcomps.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/randmarcomps.d.ts
CHANGED
|
@@ -50,10 +50,10 @@ export declare interface AiGeneratedContentProps {
|
|
|
50
50
|
|
|
51
51
|
declare interface ApiKeyContextType {
|
|
52
52
|
apiKey: string | null;
|
|
53
|
-
setApiKey: (key: string) => void;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
export declare const ApiKeyProvider: ({ children }: {
|
|
55
|
+
export declare const ApiKeyProvider: ({ apiKey, children, }: {
|
|
56
|
+
apiKey?: string | null;
|
|
57
57
|
children: ReactNode;
|
|
58
58
|
}) => JSX.Element;
|
|
59
59
|
|
package/dist/randmarcomps.js
CHANGED
|
@@ -9476,10 +9476,10 @@ function Toaster() {
|
|
|
9476
9476
|
/* @__PURE__ */ jsx(ToastViewport, {})
|
|
9477
9477
|
] });
|
|
9478
9478
|
}
|
|
9479
|
-
const ApiKeyContext = createContext(void 0), ApiKeyProvider = ({
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
}, useApiKey = () => {
|
|
9479
|
+
const ApiKeyContext = createContext(void 0), ApiKeyProvider = ({
|
|
9480
|
+
apiKey: e = null,
|
|
9481
|
+
children: t
|
|
9482
|
+
}) => /* @__PURE__ */ jsx(ApiKeyContext.Provider, { value: { apiKey: e }, children: t }), useApiKey = () => {
|
|
9483
9483
|
const e = useContext(ApiKeyContext);
|
|
9484
9484
|
if (!e)
|
|
9485
9485
|
throw new Error("useApiKey must be used within an ApiKeyProvider");
|
|
@@ -58864,7 +58864,7 @@ Dt = new WeakMap(), je = new WeakMap(), Ft = new WeakMap(), qt = new WeakMap(),
|
|
|
58864
58864
|
});
|
|
58865
58865
|
var source_default = JsxParser;
|
|
58866
58866
|
const GetJSXFromAI = async (e, t, n, o = 3) => {
|
|
58867
|
-
const l = "In addition to basic html tags, You have access to these beautiful Handmade Components: Button.", u = "Here is the data to display to the user (If a Handmade Component is a perfect fit for the data, use it. Otherwise, use regular html tags):", d = "Only output a single JSX code snippet. Start with <> and end with </>. All other code will be ignored, so make sure to place all CSS styles inline. Use CSS flex layouts when there is a lot of stuff to display.", f = JSON.stringify(n), p = [t, l, d, u, f, d].join(`\r
|
|
58867
|
+
const l = "In addition to basic html tags, You have access to these beautiful Handmade Components: Button.", u = "Here is the data to display to the user (If a Handmade Component is a perfect fit for the data, use it. Otherwise, use regular html tags) (You have access to this data object in React via the data variable):", d = "Only output a single JSX code snippet. Start with <> and end with </>. All other code will be ignored, so make sure to place all CSS styles inline. Use CSS flex layouts when there is a lot of stuff to display.", f = JSON.stringify(n), p = [t, l, d, u, f, d].join(`\r
|
|
58868
58868
|
`), b = await new GoogleGenAI({ apiKey: e }).chats.create({
|
|
58869
58869
|
model: "gemini-2.0-flash-lite"
|
|
58870
58870
|
}).sendMessage({ message: p }), _ = trimJSXString(b.text ?? "");
|
|
@@ -58875,24 +58875,24 @@ function trimJSXString(e) {
|
|
|
58875
58875
|
return t === -1 || n === -1 ? "" : e.slice(t, e.indexOf(">", n) + 1);
|
|
58876
58876
|
}
|
|
58877
58877
|
function AiGeneratedContent(e) {
|
|
58878
|
-
const
|
|
58878
|
+
const [t, n] = useState(""), { apiKey: o } = useApiKey();
|
|
58879
58879
|
return useEffect(() => {
|
|
58880
|
-
if (!
|
|
58881
|
-
|
|
58882
|
-
let
|
|
58883
|
-
return GetJSXFromAI(
|
|
58884
|
-
|
|
58880
|
+
if (!o || !e.prompt || !e.data) return;
|
|
58881
|
+
n("");
|
|
58882
|
+
let l = !1;
|
|
58883
|
+
return GetJSXFromAI(o, e.prompt, e.data).then((u) => {
|
|
58884
|
+
l || n(u);
|
|
58885
58885
|
}), () => {
|
|
58886
|
-
|
|
58886
|
+
l = !0;
|
|
58887
58887
|
};
|
|
58888
|
-
}, [e.prompt, e.data,
|
|
58888
|
+
}, [e.prompt, e.data, n, o]), t ? /* @__PURE__ */ jsx(
|
|
58889
58889
|
source_default,
|
|
58890
58890
|
{
|
|
58891
58891
|
bindings: {
|
|
58892
|
-
|
|
58892
|
+
data: e.data
|
|
58893
58893
|
},
|
|
58894
58894
|
components: { Button },
|
|
58895
|
-
jsx:
|
|
58895
|
+
jsx: t
|
|
58896
58896
|
}
|
|
58897
58897
|
) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-32", children: /* @__PURE__ */ jsx(Bot, { className: "m-auto align-middle h-full" }) }) });
|
|
58898
58898
|
}
|