@charisol/plexo-sdk 2.0.28 → 2.0.29

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.
Files changed (47) hide show
  1. package/README.md +301 -0
  2. package/dist/{InlineColorPicker-BYcOgLVc.js → InlineColorPicker-XesBzRsU.js} +362 -114
  3. package/dist/{v1-Cz7qypQd.js → blank-BEl6CY5C.js} +4656 -10906
  4. package/dist/brandGuide-Dd4fqVjS.js +33 -0
  5. package/dist/{client-DUSU8g5z.js → client-CWui0-3q.js} +1 -1
  6. package/dist/codeEditor-Cux0ud2j.js +205 -0
  7. package/dist/files-Df6FY0HK.js +2182 -0
  8. package/dist/id-CR6Y8qD6.js +8 -0
  9. package/dist/index.js +12786 -13034
  10. package/dist/{brandGuide-DgoZ7spo.js → lint-CV3DmM0X.js} +78 -109
  11. package/dist/pdfImport-BOev0Pc1.js +262 -0
  12. package/dist/plexo-sdk.css +1 -1
  13. package/dist/v1-Cn7SGvZk.js +6253 -0
  14. package/dist/v2/CanvasEditor.d.ts +25 -0
  15. package/dist/v2/V2Editor.d.ts +15 -20
  16. package/dist/v2/compile/build.d.ts +5 -0
  17. package/dist/v2/components/properties/PropertiesPanel.d.ts +1 -0
  18. package/dist/v2/files/aiPicture.d.ts +85 -0
  19. package/dist/v2/files/build.d.ts +49 -0
  20. package/dist/v2/files/capture.d.ts +52 -0
  21. package/dist/v2/files/convert.d.ts +24 -0
  22. package/dist/v2/files/docx.d.ts +1 -0
  23. package/dist/v2/files/engine.d.ts +2 -0
  24. package/dist/v2/files/export.d.ts +97 -0
  25. package/dist/v2/files/import.d.ts +34 -0
  26. package/dist/v2/files/index.d.ts +16 -0
  27. package/dist/v2/files/pdf.d.ts +15 -0
  28. package/dist/v2/files/pdfImport.d.ts +28 -0
  29. package/dist/v2/files/sheet.d.ts +16 -0
  30. package/dist/v2/files/text.d.ts +8 -0
  31. package/dist/v2/files/types.d.ts +96 -0
  32. package/dist/v2/files/ui/ExportDock.d.ts +11 -0
  33. package/dist/v2/files/ui/ExportMenu.d.ts +5 -0
  34. package/dist/v2/files/ui/ExportPanel.d.ts +17 -0
  35. package/dist/v2/files/ui/FileEditor.d.ts +14 -0
  36. package/dist/v2/files/ui/HtmlWorkbench.d.ts +15 -0
  37. package/dist/v2/files/ui/codeEditor.d.ts +12 -0
  38. package/dist/v2/files/ui/editors.d.ts +28 -0
  39. package/dist/v2/files/vector.d.ts +19 -0
  40. package/dist/v2/files/zip.d.ts +10 -0
  41. package/dist/v2/host/HostContext.d.ts +6 -3
  42. package/dist/v2/index.d.ts +5 -1
  43. package/dist/v2-compile.js +17 -16
  44. package/dist/v2-files.js +3 -0
  45. package/dist/v2-strata.js +2 -2
  46. package/dist/v2.js +5805 -4038
  47. package/package.json +18 -3
@@ -0,0 +1,262 @@
1
+ import { r as e } from "./rolldown-runtime-B1bRi_D7.js";
2
+ import { t } from "./id-CR6Y8qD6.js";
3
+ //#region src/v2/files/build.ts
4
+ var n = (e) => `${Math.round(e * 100) / 100}px`, r = (e, t) => ({
5
+ position: "absolute",
6
+ x: Math.round(e * 100) / 100,
7
+ y: Math.round(t * 100) / 100
8
+ });
9
+ function i(e, i = "Text") {
10
+ let a = e.fontSize >= 32 && e.bold;
11
+ return {
12
+ id: t(a ? "heading" : "paragraph"),
13
+ type: a ? "heading" : "paragraph",
14
+ name: i,
15
+ content: e.text,
16
+ ...a ? { props: { level: 2 } } : {},
17
+ styles: {
18
+ ...r(e.x, e.y),
19
+ width: n(e.w),
20
+ fontSize: n(e.fontSize),
21
+ fontWeight: e.bold ? "700" : "400",
22
+ isItalic: e.italic || void 0,
23
+ textColor: e.color,
24
+ textAlign: e.align ?? "left",
25
+ lineHeight: String(e.lineHeight ?? 1.2),
26
+ ...e.family ? { fontFamily: e.family } : {},
27
+ ...e.letterSpacing ? { letterSpacing: n(e.letterSpacing) } : {},
28
+ ...e.uppercase ? { textTransform: "uppercase" } : {},
29
+ ...e.wrap === !1 ? { whiteSpace: "nowrap" } : {}
30
+ }
31
+ };
32
+ }
33
+ function a(e, i = "Shape") {
34
+ return {
35
+ id: t("container"),
36
+ type: "container",
37
+ name: i,
38
+ styles: {
39
+ ...r(e.x, e.y),
40
+ width: n(e.w),
41
+ height: n(e.h),
42
+ ...e.fill ? { backgroundColor: e.fill } : {},
43
+ ...e.radius ? { borderRadius: n(e.radius) } : {},
44
+ ...e.borderWidth && e.borderColor ? {
45
+ borderWidth: n(e.borderWidth),
46
+ borderStyle: "solid",
47
+ borderColor: e.borderColor
48
+ } : {},
49
+ ...e.shadow ? { boxShadow: e.shadow } : {},
50
+ ...e.opacity !== void 0 && e.opacity < 1 ? { opacity: e.opacity } : {}
51
+ },
52
+ children: []
53
+ };
54
+ }
55
+ function o(e, i, a = {}) {
56
+ return {
57
+ id: t("image"),
58
+ type: "image",
59
+ name: a.name ?? "Picture",
60
+ props: {
61
+ src: e,
62
+ alt: a.alt ?? "",
63
+ fit: "cover"
64
+ },
65
+ locked: a.locked,
66
+ styles: {
67
+ ...r(i.x, i.y),
68
+ width: n(i.w),
69
+ height: n(i.h),
70
+ ...i.radius ? { borderRadius: n(i.radius) } : {}
71
+ }
72
+ };
73
+ }
74
+ function s(e, r, i, a, o = "#ffffff") {
75
+ let s = Math.max(1, Math.round(r)), c = Math.max(1, Math.round(i));
76
+ return {
77
+ id: t("page"),
78
+ name: e,
79
+ slug: e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "page",
80
+ rootNode: {
81
+ id: t("page"),
82
+ type: "page",
83
+ name: "Page",
84
+ styles: {
85
+ backgroundColor: "#ffffff",
86
+ textColor: "#111827",
87
+ fontFamily: "Inter"
88
+ },
89
+ children: [{
90
+ id: t("section"),
91
+ type: "section",
92
+ name: "Page",
93
+ styles: {
94
+ layoutMode: "free",
95
+ position: "relative",
96
+ width: n(s),
97
+ maxWidth: n(s),
98
+ height: n(c),
99
+ minHeight: n(c),
100
+ margin: "0 auto",
101
+ paddingTop: "0px",
102
+ paddingBottom: "0px",
103
+ paddingLeft: "0px",
104
+ paddingRight: "0px",
105
+ backgroundColor: o
106
+ },
107
+ children: a
108
+ }]
109
+ }
110
+ };
111
+ }
112
+ //#endregion
113
+ //#region src/v2/files/pdfImport.ts
114
+ var c = /* @__PURE__ */ e({
115
+ pdfToPages: () => h,
116
+ readPdf: () => p
117
+ }), l = 30, u = 2, d = (e, t, n) => new Promise((r, i) => e.toBlob((e) => e ? r(e) : i(/* @__PURE__ */ Error("A page of the PDF could not be drawn.")), t, n));
118
+ function f(e, t) {
119
+ let n = e.replace(/^[A-Z]{6}\+/, ""), r = /bold|black|heavy|semibold|demi/i.test(n), i = /italic|oblique/i.test(n), a = n.replace(/[-,](bold|italic|oblique|regular|roman|mt|ps|semibold|black|light|medium).*$/i, "").replace(/MT$/, "").replace(/([a-z])([A-Z])/g, "$1 $2").trim(), o = t && /serif|mono/.test(t) ? t.includes("mono") ? "monospace" : t.includes("sans") ? "sans-serif" : "serif" : /times|georgia|garamond|palatino|serif/i.test(a) && !/sans/i.test(a) ? "serif" : /courier|mono|consolas/i.test(a) ? "monospace" : "sans-serif";
120
+ return {
121
+ family: `${a && !/^(g_d|f\d+|font|type)/i.test(a) ? `${a}, ` : ""}${o}`,
122
+ bold: r,
123
+ italic: i
124
+ };
125
+ }
126
+ async function p(e) {
127
+ await import("pdfjs-dist/build/pdf.worker.min.mjs");
128
+ let t = await import("pdfjs-dist"), n;
129
+ try {
130
+ n = await t.getDocument({ data: new Uint8Array(e) }).promise;
131
+ } catch (e) {
132
+ throw e.name === "PasswordException" ? Error("This PDF is protected with a password. Remove the password first, then open it again.") : Error("This PDF couldn't be read. It may be damaged. Try opening or re-saving it in another app first.");
133
+ }
134
+ let r = n.numPages, i = [];
135
+ for (let e = 1; e <= Math.min(r, l); e++) {
136
+ let r = await n.getPage(e), a = r.getViewport({ scale: 96 / 72 }), o = r.getViewport({ scale: 96 / 72 * u }), s = document.createElement("canvas");
137
+ s.width = Math.ceil(o.width), s.height = Math.ceil(o.height);
138
+ let c = s.getContext("2d", { willReadFrequently: !0 });
139
+ c.fillStyle = "#ffffff", c.fillRect(0, 0, s.width, s.height), await r.render({
140
+ canvas: s,
141
+ canvasContext: c,
142
+ viewport: o
143
+ }).promise;
144
+ let l = await r.getTextContent(), p = [];
145
+ for (let e of l.items) {
146
+ if (!e.str || !e.str.trim() || !e.transform) continue;
147
+ let n = t.Util.transform(a.transform, e.transform), r = Math.hypot(n[2], n[3]);
148
+ r < 3 || p.push({
149
+ str: e.str,
150
+ x: n[4],
151
+ baseline: n[5],
152
+ size: r,
153
+ width: (e.width ?? 0) * (a.scale || 1),
154
+ font: e.fontName ?? ""
155
+ });
156
+ }
157
+ p.sort((e, t) => Math.abs(e.baseline - t.baseline) > 2 ? e.baseline - t.baseline : e.x - t.x);
158
+ let h = [];
159
+ for (let e of p) {
160
+ let t = h[h.length - 1], n = t?.[t.length - 1];
161
+ n && Math.abs(e.baseline - n.baseline) <= 2 && e.x - (n.x + n.width) < n.size * .9 && e.x >= n.x ? t.push(e) : h.push([e]);
162
+ }
163
+ let g = (e, t) => {
164
+ let n = Math.max(0, Math.min(s.width - 1, Math.round(e * u))), r = Math.max(0, Math.min(s.height - 1, Math.round(t * u))), i = c.getImageData(n, r, 1, 1).data;
165
+ return [
166
+ i[0],
167
+ i[1],
168
+ i[2]
169
+ ];
170
+ }, _ = (e) => `#${e.map((e) => e.toString(16).padStart(2, "0")).join("")}`, v = [], y = [];
171
+ for (let e of h) {
172
+ let t = e[0], n = e[e.length - 1], i = "";
173
+ e.forEach((t, n) => {
174
+ let r = e[n - 1];
175
+ i += r && t.x - (r.x + r.width) > t.size * .15 && !r.str.endsWith(" ") && !t.str.startsWith(" ") ? ` ${t.str}` : t.str;
176
+ });
177
+ let a = Math.max(...e.map((e) => e.size)), o = t.x, d = t.baseline - a * .97, p = n.x + n.width - t.x, h = a * 1.25, b = g(o - 2, d + h / 2), x = [
178
+ 17,
179
+ 24,
180
+ 39
181
+ ], S = 0, C = Math.round(o * u), w = Math.round(d * u), T = Math.max(1, Math.min(s.width - C, Math.round(p * u))), E = Math.max(1, Math.min(s.height - w, Math.round(h * u)));
182
+ if (C >= 0 && w >= 0 && T > 0 && E > 0) {
183
+ let e = c.getImageData(C, w, T, E).data;
184
+ for (let t = 0; t < e.length; t += 4) {
185
+ let n = Math.abs(e[t] - b[0]) + Math.abs(e[t + 1] - b[1]) + Math.abs(e[t + 2] - b[2]);
186
+ n > S && (S = n, x = [
187
+ e[t],
188
+ e[t + 1],
189
+ e[t + 2]
190
+ ]);
191
+ }
192
+ }
193
+ let D = m(r, t.font), O = f(D.name || "", D.fallback ?? l.styles[t.font]?.fontFamily);
194
+ D.bold && (O.bold = !0), D.italic && (O.italic = !0), v.push({
195
+ text: i,
196
+ x: o,
197
+ y: d,
198
+ w: Math.ceil(p + a * .6),
199
+ fontSize: Math.round(a * 10) / 10,
200
+ color: _(x),
201
+ bold: O.bold,
202
+ italic: O.italic,
203
+ family: O.family,
204
+ wrap: !1,
205
+ lineHeight: 1.25
206
+ }), y.push({
207
+ x: o - 1,
208
+ y: d,
209
+ w: p + 2,
210
+ h,
211
+ bg: b
212
+ });
213
+ }
214
+ for (let e of y) c.fillStyle = _(e.bg), c.fillRect(e.x * u, e.y * u, e.w * u, e.h * u);
215
+ let b = await d(s, "image/jpeg", .9);
216
+ i.push({
217
+ width: Math.round(a.width),
218
+ height: Math.round(a.height),
219
+ image: b,
220
+ texts: v,
221
+ original: v.length ? void 0 : b
222
+ }), r.cleanup();
223
+ }
224
+ return await n.destroy?.(), {
225
+ pages: i,
226
+ total: r
227
+ };
228
+ }
229
+ function m(e, t) {
230
+ if (!t) return {};
231
+ try {
232
+ let n = e.commonObjs.get(t);
233
+ return n ? {
234
+ name: n.name,
235
+ bold: n.bold,
236
+ italic: n.italic,
237
+ fallback: n.fallbackName
238
+ } : {};
239
+ } catch {
240
+ return {};
241
+ }
242
+ }
243
+ async function h(e, t, n) {
244
+ let r = [], a = 0;
245
+ for (let c of e.pages) {
246
+ a++;
247
+ let e = [o(await n(new File([c.image], `${t}-page-${a}.jpg`, { type: "image/jpeg" })), {
248
+ x: 0,
249
+ y: 0,
250
+ w: c.width,
251
+ h: c.height
252
+ }, {
253
+ name: "Page picture",
254
+ alt: `Page ${a}`,
255
+ locked: !0
256
+ }), ...c.texts.map((e) => i(e))];
257
+ r.push(s(`Page ${a}`, c.width, c.height, e));
258
+ }
259
+ return r;
260
+ }
261
+ //#endregion
262
+ export { s as a, a as i, h as n, o, p as r, i as s, c as t };