@charisol/plexo-sdk 1.4.41 → 1.4.42
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/components/SolMark.d.ts +8 -0
- package/dist/index.js +13247 -13237
- package/dist/utilities/aiHelper.d.ts +4 -0
- package/dist/utilities/playground.interfaces.d.ts +5 -0
- package/dist/v2/components/AskSolPanel.d.ts +8 -2
- package/dist/v2/components/V2Canvas.d.ts +4 -1
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2.js +78 -51
- package/package.json +1 -1
|
@@ -22,6 +22,10 @@ export interface AIActionResponse {
|
|
|
22
22
|
summary: string;
|
|
23
23
|
result: ElementJSON | TemplateJSON;
|
|
24
24
|
}
|
|
25
|
+
/** Thrown when the account has run out of AI credits for SOL (HTTP 402). */
|
|
26
|
+
export declare class AiCreditsExhaustedError extends Error {
|
|
27
|
+
}
|
|
28
|
+
export declare function setAiCreditsExhaustedHandler(handler: (() => void) | null): void;
|
|
25
29
|
/**
|
|
26
30
|
* All provider-specific logic (model resolution, structured-output handling, JSON
|
|
27
31
|
* validation) lives server-side now — this is a thin HTTP client. The raw provider key
|
|
@@ -166,6 +166,11 @@ export interface PlexoBuilderProps {
|
|
|
166
166
|
* this id to know whose account to check/charge. Ignored for System AI/BYOK keys.
|
|
167
167
|
*/
|
|
168
168
|
externalUserId?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Called when an AI action (SOL) is refused because the account is out of AI credits —
|
|
171
|
+
* lets the host show its own top-up right away. The action still reports the error inline.
|
|
172
|
+
*/
|
|
173
|
+
onAiCreditsExhausted?: () => void;
|
|
169
174
|
/**
|
|
170
175
|
* Subscription plan is resolved server-side from the apiKey.
|
|
171
176
|
* External consumers should NOT pass this prop — it will be ignored.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { PlexoNodeType } from '../store/types';
|
|
2
3
|
export interface AskSolMessage {
|
|
3
4
|
id: string;
|
|
4
5
|
from: 'user' | 'sol';
|
|
@@ -10,10 +11,15 @@ export interface AskSolMessage {
|
|
|
10
11
|
* a Back control that returns to the Content tab. History is host-persistable: pass
|
|
11
12
|
* `history`/`onMessage` (see V2CanvasProps) and a real backend (plexo-web) can save and
|
|
12
13
|
* restore the conversation per template; omit both and it's just in-memory for the
|
|
13
|
-
* session.
|
|
14
|
-
*
|
|
14
|
+
* session. With `onAsk` (see V2CanvasProps.onAskSol) replies come from the host's real SOL;
|
|
15
|
+
* without it they're honest canned pointers to the right control.
|
|
15
16
|
*/
|
|
17
|
+
export type AskSolContext = {
|
|
18
|
+
nodeId?: string;
|
|
19
|
+
nodeType?: PlexoNodeType;
|
|
20
|
+
};
|
|
16
21
|
export declare const AskSolPanel: React.FC<{
|
|
17
22
|
history?: AskSolMessage[];
|
|
18
23
|
onMessage?: (message: AskSolMessage) => void;
|
|
24
|
+
onAsk?: (question: string, context: AskSolContext) => Promise<string>;
|
|
19
25
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type SaveState } from './ContextualToolbar';
|
|
3
|
-
import type { AskSolMessage } from './AskSolPanel';
|
|
3
|
+
import type { AskSolContext, AskSolMessage } from './AskSolPanel';
|
|
4
4
|
/**
|
|
5
5
|
* Everything a host app (plexo-web in production, PlaygroundHost.tsx in dev) can hand
|
|
6
6
|
* in rather than the SDK hardcoding or faking it. Persistence, uploads, and Ask SOL
|
|
@@ -39,6 +39,9 @@ export interface V2CanvasProps {
|
|
|
39
39
|
* job. Omit both to get a normal in-memory-only conversation. */
|
|
40
40
|
askSolHistory?: AskSolMessage[];
|
|
41
41
|
onAskSolMessage?: (message: AskSolMessage) => void;
|
|
42
|
+
/** Answers Ask SOL questions with the host's real SOL (the question, plus the selected
|
|
43
|
+
* element if the question is scoped to it). Omitted, Ask SOL gives canned pointers. */
|
|
44
|
+
onAskSol?: (question: string, context: AskSolContext) => Promise<string>;
|
|
42
45
|
/** Left/right header slots — named to match V1's own `headerLeftContent`/
|
|
43
46
|
* `headerRightContent` props (PlexoBuilder.tsx) so a host already integrating V1
|
|
44
47
|
* can carry the same content over with no naming translation. The SDK renders each
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export { V2Canvas } from './components/V2Canvas';
|
|
|
8
8
|
export { useCanvasStore } from './store/createCanvasStore';
|
|
9
9
|
export { useBrandStore } from './store/createBrandStore';
|
|
10
10
|
export type { V2CanvasProps } from './components/V2Canvas';
|
|
11
|
+
export type { AskSolContext, AskSolMessage } from './components/AskSolPanel';
|
|
11
12
|
export type { PlexoNode, PlexoNodeType, CanvasState, CanvasStore, SectionNode, TextNode, ImageNode, ButtonNode, ContainerNode, } from './store/types';
|
|
12
13
|
export { compilePageToReact, componentNameFor, DESIGN_WIDTH, type CompileOptions, type TextStyleSlots } from "./compile/toReact";
|
package/dist/v2.js
CHANGED
|
@@ -3655,31 +3655,57 @@ var hr = {
|
|
|
3655
3655
|
background: B.bg,
|
|
3656
3656
|
color: B.text,
|
|
3657
3657
|
cursor: "pointer"
|
|
3658
|
-
}, _r = ({ history: e, onMessage: t }) => {
|
|
3659
|
-
let
|
|
3658
|
+
}, _r = ({ history: e, onMessage: t, onAsk: n }) => {
|
|
3659
|
+
let r = Yn(), { dark: i } = ur(), a = R((e) => e.selectedIds), o = R((e) => a.length === 1 ? e.nodes[a[0]]?.type : void 0), [s, c] = N(!0), [l, u] = N(e ?? []), [d, f] = N(""), p = s ? o : void 0, m = dr[p ?? "none"], h = (e) => {
|
|
3660
3660
|
if (!e.trim()) return;
|
|
3661
|
-
let
|
|
3661
|
+
let r = {
|
|
3662
3662
|
id: `u-${Date.now()}`,
|
|
3663
3663
|
from: "user",
|
|
3664
3664
|
text: e,
|
|
3665
3665
|
timestamp: Date.now()
|
|
3666
|
-
}, r = {
|
|
3667
|
-
id: `s-${Date.now() + 1}`,
|
|
3668
|
-
from: "sol",
|
|
3669
|
-
text: pr(e, f),
|
|
3670
|
-
timestamp: Date.now() + 1
|
|
3671
3666
|
};
|
|
3672
|
-
|
|
3667
|
+
if (f(""), t?.(r), !n) {
|
|
3668
|
+
let n = {
|
|
3669
|
+
id: `s-${Date.now() + 1}`,
|
|
3670
|
+
from: "sol",
|
|
3671
|
+
text: pr(e, p),
|
|
3672
|
+
timestamp: Date.now() + 1
|
|
3673
|
+
};
|
|
3674
|
+
u((e) => [
|
|
3675
|
+
...e,
|
|
3676
|
+
r,
|
|
3677
|
+
n
|
|
3678
|
+
]), t?.(n);
|
|
3679
|
+
return;
|
|
3680
|
+
}
|
|
3681
|
+
let i = `s-${Date.now() + 1}`;
|
|
3682
|
+
u((e) => [
|
|
3673
3683
|
...e,
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3684
|
+
r,
|
|
3685
|
+
{
|
|
3686
|
+
id: i,
|
|
3687
|
+
from: "sol",
|
|
3688
|
+
text: "Thinking…",
|
|
3689
|
+
timestamp: Date.now() + 1
|
|
3690
|
+
}
|
|
3691
|
+
]), n(e, p && a.length === 1 ? {
|
|
3692
|
+
nodeId: a[0],
|
|
3693
|
+
nodeType: p
|
|
3694
|
+
} : {}).then((e) => e, () => "SOL couldn't answer just now. Please try again.").then((e) => {
|
|
3695
|
+
let n = {
|
|
3696
|
+
id: i,
|
|
3697
|
+
from: "sol",
|
|
3698
|
+
text: e,
|
|
3699
|
+
timestamp: Date.now()
|
|
3700
|
+
};
|
|
3701
|
+
u((e) => e.map((e) => e.id === i ? n : e)), t?.(n);
|
|
3702
|
+
});
|
|
3677
3703
|
};
|
|
3678
3704
|
return /* @__PURE__ */ I("div", {
|
|
3679
3705
|
style: {
|
|
3680
3706
|
width: "100%",
|
|
3681
3707
|
height: "100%",
|
|
3682
|
-
background: mr(
|
|
3708
|
+
background: mr(i),
|
|
3683
3709
|
display: "flex",
|
|
3684
3710
|
flexDirection: "column",
|
|
3685
3711
|
position: "relative",
|
|
@@ -3694,7 +3720,7 @@ var hr = {
|
|
|
3694
3720
|
height: 200,
|
|
3695
3721
|
borderRadius: "50%",
|
|
3696
3722
|
background: B.accent,
|
|
3697
|
-
opacity:
|
|
3723
|
+
opacity: i ? .22 : .14,
|
|
3698
3724
|
filter: "blur(50px)",
|
|
3699
3725
|
pointerEvents: "none"
|
|
3700
3726
|
} }),
|
|
@@ -3706,7 +3732,7 @@ var hr = {
|
|
|
3706
3732
|
height: 180,
|
|
3707
3733
|
borderRadius: "50%",
|
|
3708
3734
|
background: "#c9f26c",
|
|
3709
|
-
opacity:
|
|
3735
|
+
opacity: i ? .12 : .18,
|
|
3710
3736
|
filter: "blur(55px)",
|
|
3711
3737
|
pointerEvents: "none"
|
|
3712
3738
|
} }),
|
|
@@ -3722,7 +3748,7 @@ var hr = {
|
|
|
3722
3748
|
},
|
|
3723
3749
|
children: [/* @__PURE__ */ I("button", {
|
|
3724
3750
|
type: "button",
|
|
3725
|
-
onClick: () =>
|
|
3751
|
+
onClick: () => r.openTab("content"),
|
|
3726
3752
|
style: {
|
|
3727
3753
|
display: "flex",
|
|
3728
3754
|
alignItems: "center",
|
|
@@ -3757,7 +3783,7 @@ var hr = {
|
|
|
3757
3783
|
display: "flex",
|
|
3758
3784
|
flexDirection: "column"
|
|
3759
3785
|
},
|
|
3760
|
-
children:
|
|
3786
|
+
children: l.length === 0 ? /* @__PURE__ */ I("div", {
|
|
3761
3787
|
style: {
|
|
3762
3788
|
display: "flex",
|
|
3763
3789
|
flexDirection: "column",
|
|
@@ -3808,7 +3834,7 @@ var hr = {
|
|
|
3808
3834
|
},
|
|
3809
3835
|
children: fr.map(({ icon: e, label: t, prompt: n }) => /* @__PURE__ */ I("button", {
|
|
3810
3836
|
type: "button",
|
|
3811
|
-
onClick: () =>
|
|
3837
|
+
onClick: () => h(n),
|
|
3812
3838
|
style: hr,
|
|
3813
3839
|
children: [
|
|
3814
3840
|
/* @__PURE__ */ F(e, {
|
|
@@ -3828,7 +3854,7 @@ var hr = {
|
|
|
3828
3854
|
gap: V.sm,
|
|
3829
3855
|
padding: `${V.md}px 0`
|
|
3830
3856
|
},
|
|
3831
|
-
children: [
|
|
3857
|
+
children: [l.map((e) => /* @__PURE__ */ F("div", {
|
|
3832
3858
|
style: {
|
|
3833
3859
|
alignSelf: e.from === "user" ? "flex-end" : "flex-start",
|
|
3834
3860
|
maxWidth: "85%",
|
|
@@ -3841,9 +3867,9 @@ var hr = {
|
|
|
3841
3867
|
boxShadow: e.from === "sol" ? B.shadow : void 0
|
|
3842
3868
|
},
|
|
3843
3869
|
children: e.text
|
|
3844
|
-
}, e.id)),
|
|
3870
|
+
}, e.id)), m.map((e) => /* @__PURE__ */ F("button", {
|
|
3845
3871
|
type: "button",
|
|
3846
|
-
onClick: () =>
|
|
3872
|
+
onClick: () => h(e),
|
|
3847
3873
|
style: gr,
|
|
3848
3874
|
children: e
|
|
3849
3875
|
}, e))]
|
|
@@ -3864,12 +3890,12 @@ var hr = {
|
|
|
3864
3890
|
padding: V.sm
|
|
3865
3891
|
},
|
|
3866
3892
|
children: [
|
|
3867
|
-
|
|
3893
|
+
o && /* @__PURE__ */ F("div", {
|
|
3868
3894
|
style: {
|
|
3869
3895
|
display: "flex",
|
|
3870
3896
|
marginBottom: V.sm
|
|
3871
3897
|
},
|
|
3872
|
-
children:
|
|
3898
|
+
children: s ? /* @__PURE__ */ I("span", {
|
|
3873
3899
|
style: {
|
|
3874
3900
|
display: "flex",
|
|
3875
3901
|
alignItems: "center",
|
|
@@ -3881,14 +3907,14 @@ var hr = {
|
|
|
3881
3907
|
borderRadius: H.pill,
|
|
3882
3908
|
padding: `${V.xxs}px ${V.sm}px`
|
|
3883
3909
|
},
|
|
3884
|
-
children: [
|
|
3910
|
+
children: [o, /* @__PURE__ */ F(Je, {
|
|
3885
3911
|
size: 11,
|
|
3886
3912
|
style: { cursor: "pointer" },
|
|
3887
|
-
onClick: () =>
|
|
3913
|
+
onClick: () => c(!1)
|
|
3888
3914
|
})]
|
|
3889
3915
|
}) : /* @__PURE__ */ I("button", {
|
|
3890
3916
|
type: "button",
|
|
3891
|
-
onClick: () =>
|
|
3917
|
+
onClick: () => c(!0),
|
|
3892
3918
|
style: {
|
|
3893
3919
|
fontSize: U.size.xs,
|
|
3894
3920
|
fontWeight: U.weight.semibold,
|
|
@@ -3899,13 +3925,13 @@ var hr = {
|
|
|
3899
3925
|
padding: `${V.xxs}px ${V.sm}px`,
|
|
3900
3926
|
cursor: "pointer"
|
|
3901
3927
|
},
|
|
3902
|
-
children: ["+ Scope to ",
|
|
3928
|
+
children: ["+ Scope to ", o]
|
|
3903
3929
|
})
|
|
3904
3930
|
}),
|
|
3905
3931
|
/* @__PURE__ */ F("input", {
|
|
3906
|
-
value:
|
|
3907
|
-
onChange: (e) =>
|
|
3908
|
-
onKeyDown: (e) => e.key === "Enter" &&
|
|
3932
|
+
value: d,
|
|
3933
|
+
onChange: (e) => f(e.target.value),
|
|
3934
|
+
onKeyDown: (e) => e.key === "Enter" && h(d),
|
|
3909
3935
|
placeholder: "I can design, add and regenerate",
|
|
3910
3936
|
style: {
|
|
3911
3937
|
width: "100%",
|
|
@@ -3966,16 +3992,16 @@ var hr = {
|
|
|
3966
3992
|
}), /* @__PURE__ */ F("button", {
|
|
3967
3993
|
type: "button",
|
|
3968
3994
|
title: "Send",
|
|
3969
|
-
onClick: () =>
|
|
3970
|
-
disabled: !
|
|
3995
|
+
onClick: () => h(d),
|
|
3996
|
+
disabled: !d.trim(),
|
|
3971
3997
|
style: {
|
|
3972
3998
|
width: 28,
|
|
3973
3999
|
height: 28,
|
|
3974
4000
|
border: "none",
|
|
3975
4001
|
borderRadius: H.pill,
|
|
3976
|
-
background:
|
|
3977
|
-
color:
|
|
3978
|
-
cursor:
|
|
4002
|
+
background: d.trim() ? B.accent : B.bgMuted,
|
|
4003
|
+
color: d.trim() ? "#ffffff" : B.textFaint,
|
|
4004
|
+
cursor: d.trim() ? "pointer" : "default",
|
|
3979
4005
|
display: "flex",
|
|
3980
4006
|
alignItems: "center",
|
|
3981
4007
|
justifyContent: "center"
|
|
@@ -4028,15 +4054,15 @@ var hr = {
|
|
|
4028
4054
|
label: "Brand",
|
|
4029
4055
|
icon: S
|
|
4030
4056
|
}
|
|
4031
|
-
], yr = ({ onUploadImage: e, askSolHistory: t, onAskSolMessage: n,
|
|
4032
|
-
let
|
|
4057
|
+
], yr = ({ onUploadImage: e, askSolHistory: t, onAskSolMessage: n, onAskSol: r, stockImageProviders: i, onSearchStockImages: a }) => {
|
|
4058
|
+
let o = Yn();
|
|
4033
4059
|
return /* @__PURE__ */ I("aside", {
|
|
4034
4060
|
style: {
|
|
4035
4061
|
display: "flex",
|
|
4036
4062
|
height: "100%",
|
|
4037
4063
|
flexShrink: 0
|
|
4038
4064
|
},
|
|
4039
|
-
children: [
|
|
4065
|
+
children: [o.activeTab && /* @__PURE__ */ I("div", {
|
|
4040
4066
|
style: {
|
|
4041
4067
|
width: 360,
|
|
4042
4068
|
flexShrink: 0,
|
|
@@ -4045,25 +4071,26 @@ var hr = {
|
|
|
4045
4071
|
overflow: "hidden"
|
|
4046
4072
|
},
|
|
4047
4073
|
children: [
|
|
4048
|
-
|
|
4049
|
-
|
|
4074
|
+
o.activeTab === "content" && /* @__PURE__ */ F(tr, {}),
|
|
4075
|
+
o.activeTab === "sol" && /* @__PURE__ */ F(_r, {
|
|
4050
4076
|
history: t,
|
|
4051
|
-
onMessage: n
|
|
4077
|
+
onMessage: n,
|
|
4078
|
+
onAsk: r
|
|
4052
4079
|
}),
|
|
4053
|
-
|
|
4080
|
+
o.activeTab === "images" && /* @__PURE__ */ F(sr, {
|
|
4054
4081
|
onUploadImage: e,
|
|
4055
|
-
stockImageProviders:
|
|
4056
|
-
onSearchStockImages:
|
|
4082
|
+
stockImageProviders: i,
|
|
4083
|
+
onSearchStockImages: a
|
|
4057
4084
|
}),
|
|
4058
|
-
|
|
4085
|
+
o.activeTab === "layers" && /* @__PURE__ */ F(Zt, {
|
|
4059
4086
|
docked: !0,
|
|
4060
|
-
onClose:
|
|
4087
|
+
onClose: o.closeTab
|
|
4061
4088
|
}),
|
|
4062
|
-
|
|
4089
|
+
o.activeTab === "guides" && /* @__PURE__ */ F(pn, {
|
|
4063
4090
|
docked: !0,
|
|
4064
|
-
onClose:
|
|
4091
|
+
onClose: o.closeTab
|
|
4065
4092
|
}),
|
|
4066
|
-
|
|
4093
|
+
o.activeTab === "brand" && /* @__PURE__ */ F("div", {
|
|
4067
4094
|
style: {
|
|
4068
4095
|
height: "100%",
|
|
4069
4096
|
overflowY: "auto"
|
|
@@ -4084,11 +4111,11 @@ var hr = {
|
|
|
4084
4111
|
padding: `${V.lg}px ${V.sm}px`
|
|
4085
4112
|
},
|
|
4086
4113
|
children: vr.map((e) => {
|
|
4087
|
-
let t = e.icon, n =
|
|
4114
|
+
let t = e.icon, n = o.activeTab === e.id;
|
|
4088
4115
|
return /* @__PURE__ */ I("button", {
|
|
4089
4116
|
type: "button",
|
|
4090
4117
|
title: e.label,
|
|
4091
|
-
onClick: () => n ?
|
|
4118
|
+
onClick: () => n ? o.closeTab() : o.openTab(e.id),
|
|
4092
4119
|
style: {
|
|
4093
4120
|
display: "flex",
|
|
4094
4121
|
flexDirection: "column",
|
package/package.json
CHANGED