@charisol/plexo-sdk 2.0.13 → 2.0.15
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/plexo-sdk.css +1 -1
- package/dist/{v1-CMpjMZtt.js → v1-CpqTI-dy.js} +1807 -1763
- package/dist/v2/compile/build.d.ts +1 -1
- package/dist/v2/compile/index.d.ts +1 -0
- package/dist/v2/components/canvas/WorkspaceLayer.d.ts +7 -0
- package/dist/v2/components/canvas/canvasDrop.d.ts +16 -0
- package/dist/v2/components/design/useStrataSync.d.ts +5 -0
- package/dist/v2/context/EditorContext.d.ts +12 -0
- package/dist/v2/context/WorkspaceContext.d.ts +3 -0
- package/dist/v2/email/compile.d.ts +1 -1
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/workspace.d.ts +16 -0
- package/dist/v2-compile.js +17 -17
- package/dist/v2.js +3781 -3476
- package/package.json +1 -1
|
@@ -48,6 +48,6 @@ export declare function safeGradient(v: string): boolean;
|
|
|
48
48
|
* - an element partly outside is clipped at its section's edge;
|
|
49
49
|
* - the same box model and constraints the editor uses (computeNodeCss) decide where everything lands.
|
|
50
50
|
*/
|
|
51
|
-
export declare function buildPage(
|
|
51
|
+
export declare function buildPage(pageIn: PageDefinition, opts?: CompileOptions): BuiltPage;
|
|
52
52
|
/** @deprecated use `BuiltPage.fontLinks` (one address per family group, with the right weights). Kept for older callers: the first Google Fonts address, or null. */
|
|
53
53
|
export declare function googleFontsHref(fonts: string[]): string | null;
|
|
@@ -16,6 +16,7 @@ export type { CompileOptions } from './build';
|
|
|
16
16
|
export { parsePages, MAX_NODES, MAX_DEPTH, type ParseResult } from './schema';
|
|
17
17
|
export { FRAME_WIDTH, MEDIA_QUERY } from '../render/frames';
|
|
18
18
|
export { computePlacements, type Placement } from '../render/placement';
|
|
19
|
+
export { stripWorkspace, pageChildren, isWorkspaceNode, workspaceOf, ensureWorkspace, WORKSPACE_ID } from '../workspace';
|
|
19
20
|
export { resolveFormDestination, type FormDestination, type FormDestinationConfig } from '../render/formAction';
|
|
20
21
|
export { convertLegacyDesign, isLegacyDesign, type LegacyDesign } from '../migrate/legacy';
|
|
21
22
|
export { blankPages } from '../data/blankPage';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The empty canvas around the page: what has been built or parked there. It is drawn on the canvas plane itself (outside every
|
|
4
|
+
* screen frame), at the plane's origin, and each item places itself by its x/y — canvas coordinates. It is part of the editing
|
|
5
|
+
* session only: it is never published (compilers drop it).
|
|
6
|
+
*/
|
|
7
|
+
export declare const WorkspaceLayer: React.FC;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DocumentNode } from '../../types/editor';
|
|
2
|
+
export type DropSpot = {
|
|
3
|
+
kind: 'node';
|
|
4
|
+
targetId: string;
|
|
5
|
+
position: 'before' | 'after' | 'inside';
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'canvas';
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'none';
|
|
10
|
+
};
|
|
11
|
+
export declare function locateDropSpot(clientX: number, clientY: number, draggedId: string, tree: DocumentNode, canvas: HTMLElement | null): DropSpot;
|
|
12
|
+
/** The canvas plane's point for a screen point (what x/y of a workspace item mean), undoing pan and zoom. */
|
|
13
|
+
export declare function screenToCanvas(clientX: number, clientY: number): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
} | null;
|
|
@@ -20,6 +20,11 @@ export interface StrataSync {
|
|
|
20
20
|
busy: string | null;
|
|
21
21
|
error: string | null;
|
|
22
22
|
notice: string | null;
|
|
23
|
+
/** What Strata said about the last send (things it accepted but would like tidied), in its own words. */
|
|
24
|
+
warnings: Array<{
|
|
25
|
+
key?: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
23
28
|
connect(options?: {
|
|
24
29
|
switchAccount?: boolean;
|
|
25
30
|
}): Promise<void>;
|
|
@@ -61,6 +61,16 @@ interface EditorContextType {
|
|
|
61
61
|
clearDragState: () => void;
|
|
62
62
|
handleDrop: () => void;
|
|
63
63
|
moveNode: (sourceId: string, targetParentId: string, targetIndex: number) => void;
|
|
64
|
+
/** Takes an element or whole section off the page and parks it on the empty canvas at a canvas position (not published). */
|
|
65
|
+
moveNodeToWorkspace: (sourceId: string, at: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}, size?: {
|
|
69
|
+
width: number;
|
|
70
|
+
height?: number;
|
|
71
|
+
}) => void;
|
|
72
|
+
/** Puts a workspace item onto the page at a drop position (the same targets the page's own drags use). */
|
|
73
|
+
moveNodeFromWorkspace: (sourceId: string, targetId: string, position: 'before' | 'after' | 'inside') => void;
|
|
64
74
|
moveNodeUp: (nodeId: string) => void;
|
|
65
75
|
moveNodeDown: (nodeId: string) => void;
|
|
66
76
|
viewportMode: ViewportMode;
|
|
@@ -81,6 +91,8 @@ interface EditorContextType {
|
|
|
81
91
|
x: number;
|
|
82
92
|
y: number;
|
|
83
93
|
}>>;
|
|
94
|
+
/** Pans the canvas (never the page around the editor) so an element is in view. */
|
|
95
|
+
revealNode: (nodeId: string) => void;
|
|
84
96
|
canvasTool: CanvasToolMode;
|
|
85
97
|
setCanvasTool: (tool: CanvasToolMode) => void;
|
|
86
98
|
canvasViewMode: CanvasViewMode;
|
|
@@ -27,4 +27,4 @@ export declare function darkVersion(kind: DarkKind, c: string): string | null;
|
|
|
27
27
|
* on a phone the columns stack. Anything an email can't show is left out and reported in `warnings`, never half-drawn.
|
|
28
28
|
* The design is untrusted input: text and addresses are escaped and colours / lengths are checked.
|
|
29
29
|
*/
|
|
30
|
-
export declare function compilePageToEmail(
|
|
30
|
+
export declare function compilePageToEmail(pageIn: PageDefinition, opts?: CompileEmailOptions): CompiledEmail;
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { LegacyDesign } from './migrate/legacy';
|
|
|
16
16
|
export * from './design';
|
|
17
17
|
export type { DesignSystem } from './design/types';
|
|
18
18
|
export { blankPages } from './data/blankPage';
|
|
19
|
+
export { stripWorkspace, pageChildren, isWorkspaceNode, workspaceOf, ensureWorkspace, WORKSPACE_ID } from './workspace';
|
|
19
20
|
export { PAGE_TEMPLATES, listPageTemplates, buildPageFromTemplate, buildTemplateSections, templateSeed, getPageTemplate, isPageEmpty } from './sections/pageTemplates';
|
|
20
21
|
export type { PageTemplate, PageTemplateSection, PageTemplateSummary } from './sections/pageTemplates';
|
|
21
22
|
export { catalogSchema, describeDesign, applyCommands, parseSolReply, describeCommand, setPageTemplateResolver, SOL_SYSTEM_PROMPT, solCommandSchema } from './sol';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DocumentNode } from './types/editor';
|
|
2
|
+
export declare const WORKSPACE_ID = "plx-workspace";
|
|
3
|
+
export declare const isWorkspaceNode: (n: DocumentNode | null | undefined) => boolean;
|
|
4
|
+
/** The workspace container of a page's root, if it has one. */
|
|
5
|
+
export declare const workspaceOf: (root: DocumentNode) => DocumentNode | undefined;
|
|
6
|
+
/** What a page really contains: its children without the workspace. */
|
|
7
|
+
export declare const pageChildren: (root: DocumentNode) => DocumentNode[];
|
|
8
|
+
/** True when `nodeId` is the workspace or sits anywhere inside it. */
|
|
9
|
+
export declare function isInWorkspace(root: DocumentNode, nodeId: string): boolean;
|
|
10
|
+
export declare function newWorkspace(): DocumentNode;
|
|
11
|
+
/** The root with a workspace container (added last) — unchanged when it already has one. */
|
|
12
|
+
export declare function ensureWorkspace(root: DocumentNode): DocumentNode;
|
|
13
|
+
/** A page without its workspace (what compilers, exports and anything that reads "the page" should see). Same object when there is none. */
|
|
14
|
+
export declare function stripWorkspace<T extends {
|
|
15
|
+
rootNode: DocumentNode;
|
|
16
|
+
}>(page: T): T;
|
package/dist/v2-compile.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { A as e,
|
|
2
|
-
import { n as
|
|
1
|
+
import { A as e, An as t, At as n, C as r, Cn as i, Dn as a, Dt as o, E as ee, En as te, Mt as s, N as c, Nn as l, Nt as u, On as d, Ot as f, P as p, Pt as m, _ as h, a as g, at as _, c as v, ct as y, d as b, dn as x, f as S, fn as C, g as w, h as T, i as E, it as D, j as O, jn as k, jt as A, kn as ne, kt as j, l as M, lt as N, m as P, n as F, nt as I, o as L, ot as R, p as z, r as B, rt as V, s as H, st as U, t as W, u as G, ut as K, v as q, wn as J, xn as Y } from "./v1-CpqTI-dy.js";
|
|
2
|
+
import { n as X, t as Z } from "./lint-BWdiaRwp.js";
|
|
3
3
|
//#region src/v2/compile/react.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var re = /^[A-Z][A-Za-z0-9]*$/, Q = (e) => JSON.stringify(e);
|
|
5
|
+
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 =
|
|
10
|
-
r === !0 ? t += ` ${e}` : typeof r == "number" ? t += ` ${e}={${r}}` : t += ` ${e}={${
|
|
9
|
+
let e = C(n);
|
|
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;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function $(e, t) {
|
|
15
15
|
let n = " ".repeat(t);
|
|
16
|
-
if (typeof e == "string") return `${n}{${
|
|
17
|
-
let r =
|
|
18
|
-
return
|
|
16
|
+
if (typeof e == "string") return `${n}{${Q(e)}}`;
|
|
17
|
+
let r = ie(e);
|
|
18
|
+
return x.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
|
-
function
|
|
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("");
|
|
22
22
|
return /^[A-Z]/.test(t) ? t : `Design${t}`;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
26
|
-
let n =
|
|
24
|
+
function oe(e, t) {
|
|
25
|
+
if (!re.test(t.componentName)) throw Error(`"${t.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
|
|
26
|
+
let n = q(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 = ${p};\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
|
<>
|
|
37
37
|
${i.length ? " {FONTS.map((href) => <link key={href} rel=\"stylesheet\" href={href} />)}\n" : ""} <style>{CSS}</style>
|
|
38
|
-
${r ?
|
|
38
|
+
${r ? $(n.tree, 3).replace("<div", "<div ref={root}") : $(n.tree, 3)}
|
|
39
39
|
</>
|
|
40
40
|
);
|
|
41
41
|
}
|
|
@@ -44,4 +44,4 @@ ${r ? Z(n.tree, 3).replace("<div", "<div ref={root}") : Z(n.tree, 3)}
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export {
|
|
47
|
+
export { P as EMAIL_WIDTH, t as FRAME_WIDTH, e as MAX_CUSTOM_JS, E as MAX_DEPTH, g as MAX_NODES, k as MEDIA_QUERY, f as PAGE_TEMPLATES, I as SOL_SYSTEM_PROMPT, W as V1_DYNAMIC_EQUIVALENTS, F as V2_DYNAMIC_READY, i as WORKSPACE_ID, _ as applyCommands, b as blankEmailPages, y as blankPages, j as buildPageFromTemplate, n as buildTemplateSections, o as catalogSchema, z as compilePageToEmail, w as compilePageToHtml, oe as compilePageToReact, ae as componentNameFor, Y as computePlacements, M as convertLegacyDesign, B as convertV1Design, l as createDefaultDesignSystem, V as describeCommand, N as describeDesign, K as describeSection, T as emailIssues, J as ensureWorkspace, A as getPageTemplate, G as isLegacyDesign, s as isPageEmpty, te as isWorkspaceNode, Z as lintDesignSystem, u as listPageTemplates, a as pageChildren, L as parsePages, D as parseSolReply, ee as parseVideoUrl, O as prepareCustomJs, h as printHtml, X as repairDesignSystem, r as resolveFormDestination, H as sanitizeCss, v as sanitizeV2Html, R as setPageTemplateResolver, U as solCommandSchema, S as starterEmailPages, d as stripWorkspace, m as templateSeed, c as validHtmlId, ne as workspaceOf };
|