pxengine 0.1.48 → 0.1.49
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 +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/dist/registry.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35920,7 +35920,26 @@ SearchSpecCard.displayName = "SearchSpecCard";
|
|
|
35920
35920
|
var import_react62 = __toESM(require("react"), 1);
|
|
35921
35921
|
|
|
35922
35922
|
// src/molecules/creator-discovery/MCQCard/defaultFetchers.ts
|
|
35923
|
+
var STORAGE_KEY = (sessionId) => `mcq_selections_${sessionId}`;
|
|
35924
|
+
function getLocalSelections(sessionId) {
|
|
35925
|
+
try {
|
|
35926
|
+
const raw = localStorage.getItem(STORAGE_KEY(sessionId));
|
|
35927
|
+
return raw ? JSON.parse(raw) : {};
|
|
35928
|
+
} catch {
|
|
35929
|
+
return {};
|
|
35930
|
+
}
|
|
35931
|
+
}
|
|
35932
|
+
function setLocalSelection(sessionId, questionKey, value) {
|
|
35933
|
+
try {
|
|
35934
|
+
const existing = getLocalSelections(sessionId);
|
|
35935
|
+
existing[questionKey] = value;
|
|
35936
|
+
localStorage.setItem(STORAGE_KEY(sessionId), JSON.stringify(existing));
|
|
35937
|
+
} catch {
|
|
35938
|
+
}
|
|
35939
|
+
}
|
|
35923
35940
|
async function defaultFetchSelections(sessionId) {
|
|
35941
|
+
const local = getLocalSelections(sessionId);
|
|
35942
|
+
if (Object.keys(local).length > 0) return local;
|
|
35924
35943
|
try {
|
|
35925
35944
|
const res = await fetch(
|
|
35926
35945
|
`/api/agents-proxy/custom-agents/sessions/${sessionId}/mcq-selections/get`,
|
|
@@ -35932,12 +35951,20 @@ async function defaultFetchSelections(sessionId) {
|
|
|
35932
35951
|
);
|
|
35933
35952
|
if (!res.ok) return {};
|
|
35934
35953
|
const data = await res.json();
|
|
35935
|
-
|
|
35954
|
+
const selections = data.selections || {};
|
|
35955
|
+
if (Object.keys(selections).length > 0) {
|
|
35956
|
+
try {
|
|
35957
|
+
localStorage.setItem(STORAGE_KEY(sessionId), JSON.stringify(selections));
|
|
35958
|
+
} catch {
|
|
35959
|
+
}
|
|
35960
|
+
}
|
|
35961
|
+
return selections;
|
|
35936
35962
|
} catch {
|
|
35937
35963
|
return {};
|
|
35938
35964
|
}
|
|
35939
35965
|
}
|
|
35940
35966
|
async function defaultPersistSelection(sessionId, questionKey, value) {
|
|
35967
|
+
setLocalSelection(sessionId, questionKey, value);
|
|
35941
35968
|
try {
|
|
35942
35969
|
await fetch(
|
|
35943
35970
|
`/api/agents-proxy/custom-agents/sessions/${sessionId}/mcq-selections`,
|
|
@@ -35974,9 +36001,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
35974
36001
|
fetchSelections = defaultFetchSelections,
|
|
35975
36002
|
persistSelection = defaultPersistSelection
|
|
35976
36003
|
}) => {
|
|
35977
|
-
const [selectedOption, setSelectedOption] = import_react62.default.useState(
|
|
35978
|
-
propsSelectedOption
|
|
35979
|
-
);
|
|
36004
|
+
const [selectedOption, setSelectedOption] = import_react62.default.useState(propsSelectedOption);
|
|
35980
36005
|
const [isProceeded, setIsProceeded] = import_react62.default.useState(false);
|
|
35981
36006
|
const fetchedSessionRef = import_react62.default.useRef("");
|
|
35982
36007
|
import_react62.default.useEffect(() => {
|
|
@@ -36007,7 +36032,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
36007
36032
|
onSelect?.(key);
|
|
36008
36033
|
}
|
|
36009
36034
|
};
|
|
36010
|
-
const handleProceed = (e) => {
|
|
36035
|
+
const handleProceed = async (e) => {
|
|
36011
36036
|
e.preventDefault();
|
|
36012
36037
|
e.stopPropagation();
|
|
36013
36038
|
if ((selectedOption || recommended) && !disabled && !isProceeded) {
|
|
@@ -36016,7 +36041,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
36016
36041
|
setIsProceeded(true);
|
|
36017
36042
|
if (sessionId) {
|
|
36018
36043
|
const questionKey = question || "unknown";
|
|
36019
|
-
persistSelection(sessionId, questionKey, result);
|
|
36044
|
+
await persistSelection(sessionId, questionKey, result);
|
|
36020
36045
|
}
|
|
36021
36046
|
if (sendMessage) {
|
|
36022
36047
|
sendMessage(`Selected: ${label}`);
|