pxengine 0.1.48 → 0.1.50
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 +49 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.mjs +48 -6
- package/dist/index.mjs.map +1 -1
- package/dist/registry.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -234,6 +234,7 @@ __export(index_exports, {
|
|
|
234
234
|
PopoverTrigger: () => PopoverTrigger,
|
|
235
235
|
Progress: () => Progress,
|
|
236
236
|
ProgressAtom: () => ProgressAtom,
|
|
237
|
+
REGISTERED_COMPONENTS: () => REGISTERED_COMPONENTS,
|
|
237
238
|
RadioAtom: () => RadioAtom,
|
|
238
239
|
RadioGroup: () => RadioGroup,
|
|
239
240
|
RadioGroupAtom: () => RadioGroupAtom,
|
|
@@ -35920,7 +35921,26 @@ SearchSpecCard.displayName = "SearchSpecCard";
|
|
|
35920
35921
|
var import_react62 = __toESM(require("react"), 1);
|
|
35921
35922
|
|
|
35922
35923
|
// src/molecules/creator-discovery/MCQCard/defaultFetchers.ts
|
|
35924
|
+
var STORAGE_KEY = (sessionId) => `mcq_selections_${sessionId}`;
|
|
35925
|
+
function getLocalSelections(sessionId) {
|
|
35926
|
+
try {
|
|
35927
|
+
const raw = localStorage.getItem(STORAGE_KEY(sessionId));
|
|
35928
|
+
return raw ? JSON.parse(raw) : {};
|
|
35929
|
+
} catch {
|
|
35930
|
+
return {};
|
|
35931
|
+
}
|
|
35932
|
+
}
|
|
35933
|
+
function setLocalSelection(sessionId, questionKey, value) {
|
|
35934
|
+
try {
|
|
35935
|
+
const existing = getLocalSelections(sessionId);
|
|
35936
|
+
existing[questionKey] = value;
|
|
35937
|
+
localStorage.setItem(STORAGE_KEY(sessionId), JSON.stringify(existing));
|
|
35938
|
+
} catch {
|
|
35939
|
+
}
|
|
35940
|
+
}
|
|
35923
35941
|
async function defaultFetchSelections(sessionId) {
|
|
35942
|
+
const local = getLocalSelections(sessionId);
|
|
35943
|
+
if (Object.keys(local).length > 0) return local;
|
|
35924
35944
|
try {
|
|
35925
35945
|
const res = await fetch(
|
|
35926
35946
|
`/api/agents-proxy/custom-agents/sessions/${sessionId}/mcq-selections/get`,
|
|
@@ -35932,12 +35952,20 @@ async function defaultFetchSelections(sessionId) {
|
|
|
35932
35952
|
);
|
|
35933
35953
|
if (!res.ok) return {};
|
|
35934
35954
|
const data = await res.json();
|
|
35935
|
-
|
|
35955
|
+
const selections = data.selections || {};
|
|
35956
|
+
if (Object.keys(selections).length > 0) {
|
|
35957
|
+
try {
|
|
35958
|
+
localStorage.setItem(STORAGE_KEY(sessionId), JSON.stringify(selections));
|
|
35959
|
+
} catch {
|
|
35960
|
+
}
|
|
35961
|
+
}
|
|
35962
|
+
return selections;
|
|
35936
35963
|
} catch {
|
|
35937
35964
|
return {};
|
|
35938
35965
|
}
|
|
35939
35966
|
}
|
|
35940
35967
|
async function defaultPersistSelection(sessionId, questionKey, value) {
|
|
35968
|
+
setLocalSelection(sessionId, questionKey, value);
|
|
35941
35969
|
try {
|
|
35942
35970
|
await fetch(
|
|
35943
35971
|
`/api/agents-proxy/custom-agents/sessions/${sessionId}/mcq-selections`,
|
|
@@ -35974,9 +36002,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
35974
36002
|
fetchSelections = defaultFetchSelections,
|
|
35975
36003
|
persistSelection = defaultPersistSelection
|
|
35976
36004
|
}) => {
|
|
35977
|
-
const [selectedOption, setSelectedOption] = import_react62.default.useState(
|
|
35978
|
-
propsSelectedOption
|
|
35979
|
-
);
|
|
36005
|
+
const [selectedOption, setSelectedOption] = import_react62.default.useState(propsSelectedOption);
|
|
35980
36006
|
const [isProceeded, setIsProceeded] = import_react62.default.useState(false);
|
|
35981
36007
|
const fetchedSessionRef = import_react62.default.useRef("");
|
|
35982
36008
|
import_react62.default.useEffect(() => {
|
|
@@ -36007,7 +36033,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
36007
36033
|
onSelect?.(key);
|
|
36008
36034
|
}
|
|
36009
36035
|
};
|
|
36010
|
-
const handleProceed = (e) => {
|
|
36036
|
+
const handleProceed = async (e) => {
|
|
36011
36037
|
e.preventDefault();
|
|
36012
36038
|
e.stopPropagation();
|
|
36013
36039
|
if ((selectedOption || recommended) && !disabled && !isProceeded) {
|
|
@@ -36016,7 +36042,7 @@ var MCQCard = import_react62.default.memo(
|
|
|
36016
36042
|
setIsProceeded(true);
|
|
36017
36043
|
if (sessionId) {
|
|
36018
36044
|
const questionKey = question || "unknown";
|
|
36019
|
-
persistSelection(sessionId, questionKey, result);
|
|
36045
|
+
await persistSelection(sessionId, questionKey, result);
|
|
36020
36046
|
}
|
|
36021
36047
|
if (sendMessage) {
|
|
36022
36048
|
sendMessage(`Selected: ${label}`);
|
|
@@ -42279,6 +42305,19 @@ var COMPONENT_SUGGESTIONS = {
|
|
|
42279
42305
|
Icon: "IconAtom",
|
|
42280
42306
|
ArrowToggle: "ArrowToggleAtom"
|
|
42281
42307
|
};
|
|
42308
|
+
var REGISTERED_COMPONENTS = /* @__PURE__ */ new Set([
|
|
42309
|
+
...Object.keys(atoms_exports),
|
|
42310
|
+
...Object.keys(molecules_exports),
|
|
42311
|
+
...Object.keys(ui_exports),
|
|
42312
|
+
// Additional common aliases/normalizations
|
|
42313
|
+
"MCQCard",
|
|
42314
|
+
"SearchSpecCard",
|
|
42315
|
+
"CampaignSeedCard",
|
|
42316
|
+
"CampaignConceptCard",
|
|
42317
|
+
"CreatorWidget",
|
|
42318
|
+
"Layout",
|
|
42319
|
+
"Text"
|
|
42320
|
+
]);
|
|
42282
42321
|
var renderContextDependentError = (componentName, normalizedName, key) => {
|
|
42283
42322
|
const suggestion = COMPONENT_SUGGESTIONS[normalizedName] || `${componentName}Atom (if available)`;
|
|
42284
42323
|
return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
|
|
@@ -42375,6 +42414,9 @@ var PXEngineRenderer = ({
|
|
|
42375
42414
|
if (!schema) return null;
|
|
42376
42415
|
const root = schema.root || schema;
|
|
42377
42416
|
const renderRecursive = (component, index) => {
|
|
42417
|
+
if (Array.isArray(component)) {
|
|
42418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_react79.default.Fragment, { children: component.map((child, idx) => renderRecursive(child, idx)) }, index !== void 0 ? `array-${index}` : "array-root");
|
|
42419
|
+
}
|
|
42378
42420
|
if (typeof component === "string" || typeof component === "number") {
|
|
42379
42421
|
return component;
|
|
42380
42422
|
}
|
|
@@ -42689,6 +42731,7 @@ var PXEngineRenderer = ({
|
|
|
42689
42731
|
PopoverTrigger,
|
|
42690
42732
|
Progress,
|
|
42691
42733
|
ProgressAtom,
|
|
42734
|
+
REGISTERED_COMPONENTS,
|
|
42692
42735
|
RadioAtom,
|
|
42693
42736
|
RadioGroup,
|
|
42694
42737
|
RadioGroupAtom,
|