@charisol/plexo-sdk 2.0.18 → 2.0.20
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/README.md +2 -0
- package/dist/plexo-sdk.css +1 -1
- package/dist/{v1-BVrQQ-IP.js → v1-DQojvrOj.js} +1587 -1478
- package/dist/v2/context/EditorContext.d.ts +11 -0
- package/dist/v2/host/HostContext.d.ts +20 -1
- package/dist/v2/index.d.ts +2 -2
- package/dist/v2/sections/heal.d.ts +7 -0
- package/dist/v2/sections/materialize.d.ts +8 -0
- package/dist/v2/sol/index.d.ts +1 -1
- package/dist/v2/sol/parse.d.ts +13 -0
- package/dist/v2-compile.js +6 -6
- package/dist/v2.js +3570 -3449
- package/package.json +1 -1
|
@@ -165,6 +165,11 @@ interface EditorContextType {
|
|
|
165
165
|
resetSectionTweaks: (sectionId: string, nodeId?: string) => void;
|
|
166
166
|
/** Applies changes SOL suggested (sections, pages, brand) as one undoable step, and reports what worked. */
|
|
167
167
|
applySolCommands: (commands: unknown[]) => CommandResult[];
|
|
168
|
+
/**
|
|
169
|
+
* Starts a live SOL run: changes are applied one batch at a time as SOL writes them (the page changes while it is still
|
|
170
|
+
* answering) and the whole run is still ONE undo step. Call `end()` when SOL has finished.
|
|
171
|
+
*/
|
|
172
|
+
beginSolRun: () => SolRun;
|
|
168
173
|
/** Scales the desktop layout onto a tablet/mobile screen (keeping anything already placed by hand there). One undo step. */
|
|
169
174
|
adaptToScreen: (screen: 'tablet' | 'mobile') => void;
|
|
170
175
|
addSection: (name?: string) => void;
|
|
@@ -209,6 +214,12 @@ export declare function isDescendant(root: DocumentNode, ancestorId: string, tes
|
|
|
209
214
|
export declare function resolveNodeStyles(node: DocumentNode, viewport: ViewportMode): ElementStyles;
|
|
210
215
|
export declare function checkIsOverridden(node: DocumentNode, viewport: ViewportMode, propKey: keyof ElementStyles): boolean;
|
|
211
216
|
export declare function getInheritedValue(node: DocumentNode, viewport: ViewportMode, propKey: keyof ElementStyles): any;
|
|
217
|
+
export interface SolRun {
|
|
218
|
+
/** Applies a batch of commands to the page as it is right now, and reports what worked. */
|
|
219
|
+
apply: (commands: unknown[]) => CommandResult[];
|
|
220
|
+
/** Closes the run: one Undo now takes back everything it changed. */
|
|
221
|
+
end: () => void;
|
|
222
|
+
}
|
|
212
223
|
export interface EditorProviderProps {
|
|
213
224
|
children: React.ReactNode;
|
|
214
225
|
/** The design to edit. Read once on mount; the editor owns the live copy after that. */
|
|
@@ -51,12 +51,26 @@ export interface CommentTarget {
|
|
|
51
51
|
export interface AskSolContext {
|
|
52
52
|
nodeId?: string;
|
|
53
53
|
nodeType?: string;
|
|
54
|
+
/** The selected element's name as the owner sees it in the layers ("Headline"). */
|
|
55
|
+
nodeName?: string;
|
|
56
|
+
/** The conversation so far in this panel (oldest first, the question just asked is not in it), so a follow-up like "make it shorter" makes sense. */
|
|
57
|
+
history?: Array<{
|
|
58
|
+
role: 'you' | 'sol';
|
|
59
|
+
text: string;
|
|
60
|
+
}>;
|
|
54
61
|
pageId: string;
|
|
55
62
|
/** The site as it is right now (pages, sections in order, brand): hand it to the AI with `SOL_SYSTEM_PROMPT`. */
|
|
56
63
|
design?: import('../sol/describe').SolDesignSummary;
|
|
57
64
|
/** Every kind of section the AI can add or change, with layouts and fields. */
|
|
58
65
|
catalog?: import('../sol/catalogSchema').SolCatalog;
|
|
59
66
|
}
|
|
67
|
+
/** Lets a host stream its answer into the SOL panel and stop it. */
|
|
68
|
+
export interface AskSolIo {
|
|
69
|
+
/** Call with the WHOLE reply so far each time more of it arrives. The panel shows it as it grows (and, with `solAutoApply`, applies changes as they complete). */
|
|
70
|
+
onText: (replySoFar: string) => void;
|
|
71
|
+
/** Aborted when the owner presses Stop. */
|
|
72
|
+
signal: AbortSignal;
|
|
73
|
+
}
|
|
60
74
|
/** A page as the host knows it. */
|
|
61
75
|
export interface HostPage {
|
|
62
76
|
id: string;
|
|
@@ -146,7 +160,12 @@ export interface V2HostConfig {
|
|
|
146
160
|
/** Loads the project's uploaded images when the Images panel opens (use instead of, or alongside, `media`, so the list is always fresh). */
|
|
147
161
|
loadMedia?: () => Promise<MediaAsset[]>;
|
|
148
162
|
/** Powers SOL / Ask-AI. Absent → the SOL tab is hidden (no AI, no credits, nothing fake). */
|
|
149
|
-
onAskSol?: (question: string, context: AskSolContext) => Promise<string>;
|
|
163
|
+
onAskSol?: (question: string, context: AskSolContext, io: AskSolIo) => Promise<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Apply SOL's changes to the page as it writes them (one Undo takes back the whole answer) instead of waiting for the owner to
|
|
166
|
+
* press Apply. Default off. Best with a host that streams (`io.onText`), where the page visibly changes while SOL answers.
|
|
167
|
+
*/
|
|
168
|
+
solAutoApply?: boolean;
|
|
150
169
|
/**
|
|
151
170
|
* Keeps the site's design system in step with Strata (signing in, choosing or creating a project, getting updates, sending
|
|
152
171
|
* changes). Absent → the design system lives only in this editor, and the Strata card isn't shown.
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export { V2Editor } from './V2Editor';
|
|
10
10
|
export type { V2EditorProps, V2EditorRef } from './V2Editor';
|
|
11
11
|
export type { V2Theme } from './theme/theme';
|
|
12
|
-
export type { V2HostConfig, SaveState, StockImageProvider, StockImageResult, LibrarySection, MediaAsset, LinkTarget, CommentTarget, AskSolContext, PageSource, HostPage, HostShell, } from './host/HostContext';
|
|
12
|
+
export type { V2HostConfig, SaveState, StockImageProvider, StockImageResult, LibrarySection, MediaAsset, LinkTarget, CommentTarget, AskSolContext, AskSolIo, PageSource, HostPage, HostShell, } from './host/HostContext';
|
|
13
13
|
export type { DocumentNode, PageDefinition, NodeType, ElementStyles, ViewportMode, } from './types/editor';
|
|
14
14
|
export { convertLegacyDesign, isLegacyDesign } from './migrate/legacy';
|
|
15
15
|
export type { LegacyDesign } from './migrate/legacy';
|
|
@@ -19,7 +19,7 @@ export { blankPages } from './data/blankPage';
|
|
|
19
19
|
export { stripWorkspace, pageChildren, isWorkspaceNode, workspaceOf, ensureWorkspace, WORKSPACE_ID } from './workspace';
|
|
20
20
|
export { PAGE_TEMPLATES, listPageTemplates, buildPageFromTemplate, buildTemplateSections, templateSeed, getPageTemplate, isPageEmpty } from './sections/pageTemplates';
|
|
21
21
|
export type { PageTemplate, PageTemplateSection, PageTemplateSummary } from './sections/pageTemplates';
|
|
22
|
-
export { catalogSchema, describeDesign, applyCommands, parseSolReply, describeCommand, setPageTemplateResolver, SOL_SYSTEM_PROMPT, solCommandSchema } from './sol';
|
|
22
|
+
export { catalogSchema, describeDesign, applyCommands, parseSolReply, readStreamingSolReply, describeCommand, setPageTemplateResolver, SOL_SYSTEM_PROMPT, solCommandSchema } from './sol';
|
|
23
23
|
export type { SolCatalog, SolKind, SolField, SolVariant, SolDesignSummary, SolSectionSummary, SolCommand, SolCommandOp, CommandResult, ParsedSolReply, ApplyOptions, ApplyResult, PageTemplateResolver } from './sol';
|
|
24
24
|
export { sanitizeV2Html, sanitizeCss } from './compile/sanitizeHtml';
|
|
25
25
|
export type { SanitizeV2Options } from './compile/sanitizeHtml';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PageDefinition } from '../types/editor';
|
|
2
|
+
/**
|
|
3
|
+
* Pages saved by an earlier version could hold a ready-made section that went from the empty canvas back onto the page still carrying its
|
|
4
|
+
* canvas position, which pulled it out of the page's flow (it showed in the layers but not on the page). This puts such a section back in
|
|
5
|
+
* the flow. Returns the same page when nothing needed fixing, so it is free to call on every load.
|
|
6
|
+
*/
|
|
7
|
+
export declare function healPage(page: PageDefinition): PageDefinition;
|
|
@@ -77,3 +77,11 @@ export declare function replaceNodeById(root: DocumentNode, id: string, next: Do
|
|
|
77
77
|
* Returns the new tree (the same one if nothing changes).
|
|
78
78
|
*/
|
|
79
79
|
export declare function setHeadingLevel(root: DocumentNode, nodeId: string, level: number): DocumentNode;
|
|
80
|
+
/** True when a ready-made section carries a canvas position (x/y, absolute) as a tweak of itself. */
|
|
81
|
+
export declare const hasCanvasPosition: (section: DocumentNode) => boolean;
|
|
82
|
+
/**
|
|
83
|
+
* A ready-made section back in the page's flow: the position it was given on the canvas (kept as a tweak of the section so it
|
|
84
|
+
* survives editing there) is forgotten, and it is rebuilt full width. Without this the next change to the section would put it back
|
|
85
|
+
* where the canvas had it, out of the flow, and it would seem to vanish from the page.
|
|
86
|
+
*/
|
|
87
|
+
export declare function releaseSectionToFlow(section: DocumentNode): DocumentNode;
|
package/dist/v2/sol/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { catalogSchema, type SolCatalog, type SolKind, type SolField, type SolVa
|
|
|
2
2
|
export { describeDesign, describeSection, type SolDesignSummary, type SolSectionSummary } from './describe';
|
|
3
3
|
export { applyCommands, setPageTemplateResolver, type ApplyOptions, type ApplyResult, type PageTemplateResolver } from './commands';
|
|
4
4
|
export { solCommandSchema, type SolCommand, type SolCommandOp, type CommandResult } from './schema';
|
|
5
|
-
export { parseSolReply, type ParsedSolReply } from './parse';
|
|
5
|
+
export { parseSolReply, readStreamingSolReply, type ParsedSolReply, type StreamingSolReply } from './parse';
|
|
6
6
|
export { describeCommand } from './summarize';
|
|
7
7
|
export { SOL_SYSTEM_PROMPT } from './prompt';
|
package/dist/v2/sol/parse.d.ts
CHANGED
|
@@ -8,3 +8,16 @@ export interface ParsedSolReply {
|
|
|
8
8
|
}
|
|
9
9
|
/** Pulls a fenced `plexo-commands` block out of a reply. Tolerates trailing commas and a reply cut off before the closing fence. */
|
|
10
10
|
export declare function parseSolReply(reply: string): ParsedSolReply;
|
|
11
|
+
export interface StreamingSolReply {
|
|
12
|
+
/** What SOL has said so far, without the commands block (or the start of one still arriving). */
|
|
13
|
+
text: string;
|
|
14
|
+
/** Every change in the block that has fully arrived so far, in order — including ones that could not be read (as `null`). */
|
|
15
|
+
commands: Array<SolCommand | null>;
|
|
16
|
+
/** True while the commands block is still being written. */
|
|
17
|
+
writing: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reads a reply that is still arriving. The commands block is a JSON list; each change is handed back the moment its closing
|
|
21
|
+
* brace has arrived, so the host can apply it while SOL is still writing the next one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readStreamingSolReply(partial: string): StreamingSolReply;
|
package/dist/v2-compile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, An as t, At as n, C as r,
|
|
1
|
+
import { A as e, An as t, At as n, C as r, Dn as i, E as a, Fn as o, Ft as ee, Ln as te, Mn as s, Mt as c, N as l, Nn as u, Nt as d, On as f, Ot as p, P as m, Pn as h, Pt as g, Tn as _, _ as v, a as y, c as b, ct as x, d as S, dt as C, f as w, g as T, gn as E, h as D, hn as O, i as k, it as A, j as ne, jn as j, jt as M, kt as N, l as P, lt as F, m as I, n as L, nt as R, o as z, ot as B, p as V, r as H, rt as U, s as W, st as G, t as K, u as q, ut as J, v as Y } from "./v1-DQojvrOj.js";
|
|
2
2
|
import { n as X, t as Z } from "./lint-CV3DmM0X.js";
|
|
3
3
|
//#region src/v2/compile/react.ts
|
|
4
4
|
var re = /^[A-Z][A-Za-z0-9]*$/, Q = (e) => JSON.stringify(e);
|
|
@@ -6,7 +6,7 @@ function ie(e) {
|
|
|
6
6
|
let t = "";
|
|
7
7
|
for (let [n, r] of Object.entries(e.attrs ?? {})) {
|
|
8
8
|
if (r === void 0 || r === !1) continue;
|
|
9
|
-
let e =
|
|
9
|
+
let e = E(n);
|
|
10
10
|
r === !0 ? t += ` ${e}` : typeof r == "number" ? t += ` ${e}={${r}}` : t += ` ${e}={${Q(String(r))}}`;
|
|
11
11
|
}
|
|
12
12
|
return e.style && (t += ` style={${JSON.stringify(e.style)}}`), t;
|
|
@@ -15,7 +15,7 @@ function $(e, t) {
|
|
|
15
15
|
let n = " ".repeat(t);
|
|
16
16
|
if (typeof e == "string") return `${n}{${Q(e)}}`;
|
|
17
17
|
let r = ie(e);
|
|
18
|
-
return
|
|
18
|
+
return O.has(e.tag) || !e.children?.length ? `${n}<${e.tag}${r} />` : `${n}<${e.tag}${r}>\n${e.children.map((e) => $(e, t + 1)).join("\n")}\n${n}</${e.tag}>`;
|
|
19
19
|
}
|
|
20
20
|
function ae(e) {
|
|
21
21
|
let t = e.replace(/[^A-Za-z0-9]+/g, " ").trim().split(" ").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join("");
|
|
@@ -23,14 +23,14 @@ function ae(e) {
|
|
|
23
23
|
}
|
|
24
24
|
function oe(e, t) {
|
|
25
25
|
if (!re.test(t.componentName)) throw Error(`"${t.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
|
|
26
|
-
let n =
|
|
26
|
+
let n = Y(e, t), r = t.runtime !== "none" && n.usesRuntime, i = n.fontLinks, a = "`" + n.css.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${") + "`";
|
|
27
27
|
return {
|
|
28
28
|
code: `// Generated by Plexo from a visual design. Edit it visually in the app editor's Design view
|
|
29
29
|
// (which regenerates this file), or turn it into regular code by editing here.
|
|
30
30
|
${r ? "// @ts-nocheck — the small runtime below is plain JavaScript.\nimport { useEffect, useRef } from \"react\";" : "import type { ReactElement } from \"react\";"}
|
|
31
31
|
|
|
32
32
|
const CSS = ${a};
|
|
33
|
-
${i.length ? `const FONTS: string[] = ${JSON.stringify(i)};\n` : ""}${r ? `\n/** Carousel autoplay, the live timer and in-page form sending. */\nconst plexoInit = ${
|
|
33
|
+
${i.length ? `const FONTS: string[] = ${JSON.stringify(i)};\n` : ""}${r ? `\n/** Carousel autoplay, the live timer and in-page form sending. */\nconst plexoInit = ${m};\n` : ""}
|
|
34
34
|
export default function ${t.componentName}()${r ? "" : ": ReactElement"} {
|
|
35
35
|
${r ? " const root = useRef<HTMLDivElement>(null);\n useEffect(() => (root.current ? plexoInit(root.current) : undefined), []);\n" : ""} return (
|
|
36
36
|
<>
|
|
@@ -44,4 +44,4 @@ ${r ? $(n.tree, 3).replace("<div", "<div ref={root}") : $(n.tree, 3)}
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export {
|
|
47
|
+
export { I as EMAIL_WIDTH, h as FRAME_WIDTH, e as MAX_CUSTOM_JS, k as MAX_DEPTH, y as MAX_NODES, o as MEDIA_QUERY, N as PAGE_TEMPLATES, R as SOL_SYSTEM_PROMPT, K as V1_DYNAMIC_EQUIVALENTS, L as V2_DYNAMIC_READY, i as WORKSPACE_ID, B as applyCommands, S as blankEmailPages, F as blankPages, n as buildPageFromTemplate, M as buildTemplateSections, p as catalogSchema, V as compilePageToEmail, T as compilePageToHtml, oe as compilePageToReact, ae as componentNameFor, _ as computePlacements, P as convertLegacyDesign, H as convertV1Design, te as createDefaultDesignSystem, U as describeCommand, J as describeDesign, C as describeSection, D as emailIssues, f as ensureWorkspace, c as getPageTemplate, q as isLegacyDesign, d as isPageEmpty, t as isWorkspaceNode, Z as lintDesignSystem, g as listPageTemplates, j as pageChildren, z as parsePages, A as parseSolReply, a as parseVideoUrl, ne as prepareCustomJs, v as printHtml, X as repairDesignSystem, r as resolveFormDestination, W as sanitizeCss, b as sanitizeV2Html, G as setPageTemplateResolver, x as solCommandSchema, w as starterEmailPages, s as stripWorkspace, ee as templateSeed, l as validHtmlId, u as workspaceOf };
|