pxengine 0.1.63 → 0.1.65
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/index.cjs +65 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +65 -16
- package/dist/index.mjs.map +1 -1
- package/dist/registry.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -37440,7 +37440,7 @@ import React96 from "react";
|
|
|
37440
37440
|
// src/molecules/creator-discovery/MCQCard/defaultFetchers.ts
|
|
37441
37441
|
function getBackendOrigin() {
|
|
37442
37442
|
if (typeof window === "undefined") return null;
|
|
37443
|
-
return window.__NEXT_DATA__?.runtimeConfig?.NEXT_PUBLIC_AGENT_BACKEND ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_AGENT_BACKEND : void 0) ??
|
|
37443
|
+
return window.__NEXT_DATA__?.runtimeConfig?.NEXT_PUBLIC_AGENT_BACKEND ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_AGENT_BACKEND : void 0) ?? null;
|
|
37444
37444
|
}
|
|
37445
37445
|
function getBaseUrl() {
|
|
37446
37446
|
const backend = getBackendOrigin();
|
|
@@ -37542,8 +37542,13 @@ var MCQCard = React96.memo(
|
|
|
37542
37542
|
sessionId,
|
|
37543
37543
|
sendMessage,
|
|
37544
37544
|
fetchSelections = defaultFetchSelections,
|
|
37545
|
-
persistSelection = defaultPersistSelection
|
|
37545
|
+
persistSelection = defaultPersistSelection,
|
|
37546
|
+
...allProps
|
|
37546
37547
|
}) => {
|
|
37548
|
+
const resolvedQuestion = question || allProps.Question || allProps.q || "";
|
|
37549
|
+
const resolvedOptions = options || allProps.Options || allProps.opts || {};
|
|
37550
|
+
const resolvedRecommended = recommended || allProps.Recommended || allProps.rec;
|
|
37551
|
+
console.log("[MCQCard] FULL PROPS:", { allProps, resolvedQuestion, resolvedOptions: Object.keys(resolvedOptions || {}), resolvedRecommended });
|
|
37547
37552
|
const [selectedOption, setSelectedOption] = React96.useState(propsSelectedOption);
|
|
37548
37553
|
const [isProceeded, setIsProceeded] = React96.useState(false);
|
|
37549
37554
|
const fetchedSessionRef = React96.useRef("");
|
|
@@ -37553,24 +37558,39 @@ var MCQCard = React96.memo(
|
|
|
37553
37558
|
setIsProceeded(true);
|
|
37554
37559
|
}
|
|
37555
37560
|
}, [propsSelectedOption]);
|
|
37561
|
+
const buildQuestionKey = React96.useCallback((sid, question2) => {
|
|
37562
|
+
let hash = 2166136261;
|
|
37563
|
+
for (let i = 0; i < question2.length; i++) {
|
|
37564
|
+
hash ^= question2.charCodeAt(i);
|
|
37565
|
+
hash = hash * 16777619 >>> 0;
|
|
37566
|
+
}
|
|
37567
|
+
return `mcq_${sid}_${hash.toString(36)}`;
|
|
37568
|
+
}, []);
|
|
37556
37569
|
React96.useEffect(() => {
|
|
37557
|
-
if (!sessionId ||
|
|
37570
|
+
if (!sessionId || !resolvedQuestion) return;
|
|
37571
|
+
const fetchKey = `${sessionId}::${resolvedQuestion}`;
|
|
37572
|
+
if (fetchedSessionRef.current === fetchKey) return;
|
|
37558
37573
|
if (propsSelectedOption) return;
|
|
37559
|
-
fetchedSessionRef.current =
|
|
37560
|
-
const questionKey =
|
|
37574
|
+
fetchedSessionRef.current = fetchKey;
|
|
37575
|
+
const questionKey = buildQuestionKey(sessionId, resolvedQuestion);
|
|
37576
|
+
console.log("[MCQCard] Fetching with key:", questionKey, "(question:", resolvedQuestion, ")");
|
|
37561
37577
|
fetchSelections(sessionId).then((selections) => {
|
|
37562
|
-
|
|
37578
|
+
console.log("[MCQCard] Got selections:", selections);
|
|
37579
|
+
const stored = selections[questionKey] || selections[resolvedQuestion] || selections[`mcq_${sessionId}`];
|
|
37563
37580
|
if (stored) {
|
|
37581
|
+
console.log("[MCQCard] Setting selected:", stored);
|
|
37564
37582
|
setSelectedOption(stored);
|
|
37565
37583
|
setIsProceeded(true);
|
|
37566
37584
|
}
|
|
37567
|
-
});
|
|
37568
|
-
}, [sessionId,
|
|
37585
|
+
}).catch((err) => console.error("[MCQCard] Fetch error:", err));
|
|
37586
|
+
}, [sessionId, propsSelectedOption, resolvedQuestion, buildQuestionKey]);
|
|
37569
37587
|
const isDiscovery = disableContinueInDiscovery !== void 0 ? disableContinueInDiscovery : typeof window !== "undefined" && window.location.pathname.includes("creator-discovery");
|
|
37570
37588
|
const handleOptionClick = (key, e) => {
|
|
37571
37589
|
e.preventDefault();
|
|
37572
37590
|
e.stopPropagation();
|
|
37591
|
+
console.log("[MCQCard] Option clicked:", key, "Can select:", isLatestMessage && !isLoading && !disabled && !isProceeded);
|
|
37573
37592
|
if (isLatestMessage && !isLoading && !disabled && !isProceeded) {
|
|
37593
|
+
console.log("[MCQCard] Setting selected to:", key);
|
|
37574
37594
|
setSelectedOption(key);
|
|
37575
37595
|
onSelect?.(key);
|
|
37576
37596
|
}
|
|
@@ -37583,8 +37603,9 @@ var MCQCard = React96.memo(
|
|
|
37583
37603
|
const rawLabel = options && options[result];
|
|
37584
37604
|
const label = typeof rawLabel === "string" ? rawLabel : typeof rawLabel === "object" && rawLabel !== null ? rawLabel.label || rawLabel.description || result : result;
|
|
37585
37605
|
setIsProceeded(true);
|
|
37586
|
-
if (sessionId) {
|
|
37587
|
-
const questionKey =
|
|
37606
|
+
if (sessionId && resolvedQuestion) {
|
|
37607
|
+
const questionKey = buildQuestionKey(sessionId, resolvedQuestion);
|
|
37608
|
+
console.log("[MCQCard] Persisting:", questionKey, result);
|
|
37588
37609
|
await persistSelection(sessionId, questionKey, result);
|
|
37589
37610
|
}
|
|
37590
37611
|
if (sendMessage) {
|
|
@@ -37600,7 +37621,7 @@ var MCQCard = React96.memo(
|
|
|
37600
37621
|
};
|
|
37601
37622
|
const isOptionsDisabled = disabled || !isLatestMessage || isProceeded && !disableContinueInDiscovery;
|
|
37602
37623
|
const isContinueDisabled = disabled || !isLatestMessage || isProceeded || isDiscovery;
|
|
37603
|
-
const optionsEntries =
|
|
37624
|
+
const optionsEntries = resolvedOptions && Object.keys(resolvedOptions).length > 0 ? Object.entries(resolvedOptions).map(([key, val]) => [
|
|
37604
37625
|
key,
|
|
37605
37626
|
typeof val === "string" ? val : typeof val === "object" && val !== null ? val.label || val.description || val.id || JSON.stringify(val) : String(val ?? "")
|
|
37606
37627
|
]) : [];
|
|
@@ -37612,7 +37633,7 @@ var MCQCard = React96.memo(
|
|
|
37612
37633
|
className
|
|
37613
37634
|
),
|
|
37614
37635
|
children: [
|
|
37615
|
-
/* @__PURE__ */ jsx125("div", { className: "mb-4", children: /* @__PURE__ */ jsx125("p", { className: "text-sm text-cardText", children:
|
|
37636
|
+
/* @__PURE__ */ jsx125("div", { className: "mb-4", children: /* @__PURE__ */ jsx125("p", { className: "text-sm text-cardText", children: resolvedQuestion || "Select an option:" }) }),
|
|
37616
37637
|
/* @__PURE__ */ jsx125("div", { className: "space-y-2.5 mb-4", children: optionsEntries.map(([key, label]) => {
|
|
37617
37638
|
const isSelected = selectedOption === key;
|
|
37618
37639
|
const isRecommended = key === recommended;
|
|
@@ -40437,6 +40458,37 @@ function CreatorDisplay({
|
|
|
40437
40458
|
] })
|
|
40438
40459
|
] });
|
|
40439
40460
|
}
|
|
40461
|
+
function CreatorCardSkeleton() {
|
|
40462
|
+
return /* @__PURE__ */ jsx148("div", { className: "bg-paperBackground rounded-[25px] py-5 pl-7 pr-7 border-2 border-gray300 shadow-sm", children: /* @__PURE__ */ jsxs106("div", { className: "flex flex-col gap-4 sm:grid sm:grid-cols-[1.3fr_1fr_2fr_120px] gap-8 items-start w-full", children: [
|
|
40463
|
+
/* @__PURE__ */ jsxs106("div", { className: "flex items-start gap-1 md:gap-6", children: [
|
|
40464
|
+
/* @__PURE__ */ jsx148("div", { className: "w-[5rem] h-[5rem] rounded-[10px] bg-gray200 animate-pulse" }),
|
|
40465
|
+
/* @__PURE__ */ jsxs106("div", { className: "flex flex-col gap-3", children: [
|
|
40466
|
+
/* @__PURE__ */ jsx148("div", { className: "h-5 w-36 rounded bg-gray200 animate-pulse" }),
|
|
40467
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-24 rounded bg-gray200 animate-pulse" }),
|
|
40468
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-32 rounded bg-gray200 animate-pulse" }),
|
|
40469
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-44 rounded bg-gray200 animate-pulse" })
|
|
40470
|
+
] })
|
|
40471
|
+
] }),
|
|
40472
|
+
/* @__PURE__ */ jsxs106("div", { className: "space-y-3 w-full", children: [
|
|
40473
|
+
/* @__PURE__ */ jsx148("div", { className: "h-4 w-32 rounded bg-gray200 animate-pulse" }),
|
|
40474
|
+
/* @__PURE__ */ jsx148("div", { className: "h-4 w-28 rounded bg-gray200 animate-pulse" }),
|
|
40475
|
+
/* @__PURE__ */ jsx148("div", { className: "h-4 w-24 rounded bg-gray200 animate-pulse" })
|
|
40476
|
+
] }),
|
|
40477
|
+
/* @__PURE__ */ jsxs106("div", { className: "space-y-3 w-full", children: [
|
|
40478
|
+
/* @__PURE__ */ jsx148("div", { className: "h-4 w-40 rounded bg-gray200 animate-pulse" }),
|
|
40479
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-full rounded bg-gray200 animate-pulse" }),
|
|
40480
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-[90%] rounded bg-gray200 animate-pulse" }),
|
|
40481
|
+
/* @__PURE__ */ jsx148("div", { className: "h-3 w-[75%] rounded bg-gray200 animate-pulse" })
|
|
40482
|
+
] }),
|
|
40483
|
+
/* @__PURE__ */ jsxs106("div", { className: "hidden md:flex flex-col items-center justify-center gap-3", children: [
|
|
40484
|
+
/* @__PURE__ */ jsx148("div", { className: "h-6 w-16 rounded bg-gray200 animate-pulse" }),
|
|
40485
|
+
/* @__PURE__ */ jsx148("div", { className: "h-4 w-20 rounded bg-gray200 animate-pulse" })
|
|
40486
|
+
] })
|
|
40487
|
+
] }) });
|
|
40488
|
+
}
|
|
40489
|
+
function CreatorDisplaySkeleton() {
|
|
40490
|
+
return /* @__PURE__ */ jsx148("div", { className: "px-4 py-4 space-y-4", children: Array.from({ length: 3 }).map((_, idx) => /* @__PURE__ */ jsx148(CreatorCardSkeleton, {}, idx)) });
|
|
40491
|
+
}
|
|
40440
40492
|
function CreatorExpandedPanel({
|
|
40441
40493
|
isOpen,
|
|
40442
40494
|
onClose,
|
|
@@ -40504,10 +40556,7 @@ function CreatorExpandedPanel({
|
|
|
40504
40556
|
] })
|
|
40505
40557
|
] }),
|
|
40506
40558
|
/* @__PURE__ */ jsx148("div", { className: "border-b border-gray300" }),
|
|
40507
|
-
loading ? /* @__PURE__ */
|
|
40508
|
-
/* @__PURE__ */ jsx148("div", { className: "w-8 h-8 border-3 border-purple100 border-t-transparent rounded-full animate-spin" }),
|
|
40509
|
-
/* @__PURE__ */ jsx148("p", { className: "text-sm text-gray600", children: "Fetching Creators" })
|
|
40510
|
-
] }) : /* @__PURE__ */ jsx148(CreatorDisplay, { creators, isValidationComplete: version !== void 0 })
|
|
40559
|
+
loading ? /* @__PURE__ */ jsx148(CreatorDisplaySkeleton, {}) : /* @__PURE__ */ jsx148(CreatorDisplay, { creators, isValidationComplete: version !== void 0 })
|
|
40511
40560
|
] })
|
|
40512
40561
|
},
|
|
40513
40562
|
"creator-panel"
|