@elucim/dsl 0.8.4 → 0.9.0
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.d.ts +1 -1
- package/dist/index.js +45 -44
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -570,7 +570,7 @@ export declare function renderElement(node: ElementNode, key: number): default_2
|
|
|
570
570
|
|
|
571
571
|
export declare function renderPlayer(node: PlayerNode, overrides?: RenderRootOverrides): default_2.ReactNode;
|
|
572
572
|
|
|
573
|
-
export declare function renderPresentation(node: PresentationNode): default_2.ReactNode;
|
|
573
|
+
export declare function renderPresentation(node: PresentationNode, overrides?: RenderRootOverrides): default_2.ReactNode;
|
|
574
574
|
|
|
575
575
|
export declare function renderRoot(node: SceneNode | PlayerNode | PresentationNode, overrides?: RenderRootOverrides): default_2.ReactNode;
|
|
576
576
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { easeOutBounce as oe, easeOutElastic as ge, easeOutBack as me, easeInBack as ye, easeInOutExpo as be, easeOutExpo as xe, easeInExpo as de, easeInOutSine as ve, easeOutSine as we, easeInSine as ke, easeInOutQuart as Ie, easeOutQuart as Se, easeInQuart as $e, easeInOutCubic as Oe, easeOutCubic as Ce, easeInCubic as Ae, easeInOutQuad as ze, easeOutQuad as pe, easeInQuad as Ee, linear as Fe, spring as Pe, cubicBezier as Re, Presentation as Te, Scene as Me, Player as Ne, Slide as We, Parallel as De, Stagger as _e, Morph as Ve, Transform as Le, Write as je, Draw as Be, FadeOut as qe, FadeIn as Ue, BarChart as Ge, LaTeX as He, Graph as Ke, Matrix as Qe, Text as j, VectorField as Xe, Vector as Je, FunctionPlot as Ye, Axes as Ze, Image as et, Polygon as tt, Rect as at, Arrow as rt, Line as it, Circle as nt, BezierCurve as st, Group as ct, Sequence as lt } from "@elucim/core";
|
|
2
2
|
import { jsx as l, jsxs as P } from "react/jsx-runtime";
|
|
3
|
-
import X, { forwardRef as ut, useRef as
|
|
3
|
+
import X, { forwardRef as ut, useRef as ht, useImperativeHandle as ft, useSyncExternalStore as ot } from "react";
|
|
4
4
|
import { renderToStaticMarkup as gt } from "react-dom/server";
|
|
5
5
|
const U = {
|
|
6
6
|
sin: Math.sin,
|
|
@@ -478,19 +478,19 @@ function ne(e, a, t) {
|
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
function vt(e, a, t) {
|
|
481
|
-
|
|
481
|
+
h(e, "x1", a, t), h(e, "y1", a, t), h(e, "cx1", a, t), h(e, "cy1", a, t), h(e, "x2", a, t), h(e, "y2", a, t), e.cx2 !== void 0 && R(e, "cx2", a, t), e.cy2 !== void 0 && R(e, "cy2", a, t), w(e, a, t);
|
|
482
482
|
}
|
|
483
483
|
function wt(e, a, t) {
|
|
484
|
-
|
|
484
|
+
h(e, "cx", a, t), h(e, "cy", a, t), F(e, "r", a, t), w(e, a, t);
|
|
485
485
|
}
|
|
486
486
|
function kt(e, a, t) {
|
|
487
|
-
|
|
487
|
+
h(e, "x1", a, t), h(e, "y1", a, t), h(e, "x2", a, t), h(e, "y2", a, t), w(e, a, t);
|
|
488
488
|
}
|
|
489
489
|
function It(e, a, t) {
|
|
490
|
-
|
|
490
|
+
h(e, "x1", a, t), h(e, "y1", a, t), h(e, "x2", a, t), h(e, "y2", a, t), w(e, a, t);
|
|
491
491
|
}
|
|
492
492
|
function St(e, a, t) {
|
|
493
|
-
|
|
493
|
+
h(e, "x", a, t), h(e, "y", a, t), F(e, "width", a, t), F(e, "height", a, t), w(e, a, t);
|
|
494
494
|
}
|
|
495
495
|
function $t(e, a, t) {
|
|
496
496
|
Array.isArray(e.points) ? e.points.length < 3 ? t.push({ path: `${a}.points`, message: "Polygon requires at least 3 points", severity: "error" }) : e.points.forEach((r, i) => {
|
|
@@ -498,7 +498,7 @@ function $t(e, a, t) {
|
|
|
498
498
|
}) : t.push({ path: `${a}.points`, message: 'Polygon requires a "points" array', severity: "error" }), w(e, a, t);
|
|
499
499
|
}
|
|
500
500
|
function Ot(e, a, t) {
|
|
501
|
-
|
|
501
|
+
h(e, "x", a, t), h(e, "y", a, t), typeof e.content != "string" && t.push({ path: `${a}.content`, message: 'Text requires a "content" string', severity: "error" }), w(e, a, t);
|
|
502
502
|
}
|
|
503
503
|
function Ct(e, a, t) {
|
|
504
504
|
S(e, "domain", a, t), S(e, "range", a, t), S(e, "origin", a, t), V(e, a, t);
|
|
@@ -535,7 +535,7 @@ function Ft(e, a, t) {
|
|
|
535
535
|
else {
|
|
536
536
|
const r = /* @__PURE__ */ new Set();
|
|
537
537
|
e.nodes.forEach((i, n) => {
|
|
538
|
-
typeof i.id != "string" ? t.push({ path: `${a}.nodes[${n}].id`, message: 'Graph node requires a string "id"', severity: "error" }) : (r.has(i.id) && t.push({ path: `${a}.nodes[${n}].id`, message: `Duplicate node id "${i.id}"`, severity: "error" }), r.add(i.id)),
|
|
538
|
+
typeof i.id != "string" ? t.push({ path: `${a}.nodes[${n}].id`, message: 'Graph node requires a string "id"', severity: "error" }) : (r.has(i.id) && t.push({ path: `${a}.nodes[${n}].id`, message: `Duplicate node id "${i.id}"`, severity: "error" }), r.add(i.id)), h(i, "x", `${a}.nodes[${n}]`, t), h(i, "y", `${a}.nodes[${n}]`, t);
|
|
539
539
|
}), Array.isArray(e.edges) && e.edges.forEach((i, n) => {
|
|
540
540
|
(typeof i.from != "string" || !r.has(i.from)) && t.push({ path: `${a}.edges[${n}].from`, message: `Edge "from" references unknown node "${i.from}"`, severity: "error" }), (typeof i.to != "string" || !r.has(i.to)) && t.push({ path: `${a}.edges[${n}].to`, message: `Edge "to" references unknown node "${i.to}"`, severity: "error" });
|
|
541
541
|
});
|
|
@@ -543,10 +543,10 @@ function Ft(e, a, t) {
|
|
|
543
543
|
w(e, a, t);
|
|
544
544
|
}
|
|
545
545
|
function Pt(e, a, t) {
|
|
546
|
-
typeof e.expression != "string" && t.push({ path: `${a}.expression`, message: 'LaTeX requires an "expression" string', severity: "error" }),
|
|
546
|
+
typeof e.expression != "string" && t.push({ path: `${a}.expression`, message: 'LaTeX requires an "expression" string', severity: "error" }), h(e, "x", a, t), h(e, "y", a, t), w(e, a, t);
|
|
547
547
|
}
|
|
548
548
|
function Rt(e, a, t) {
|
|
549
|
-
|
|
549
|
+
h(e, "from", a, t), qt(e, "durationInFrames", a, t), p(e, a, t);
|
|
550
550
|
}
|
|
551
551
|
function Tt(e, a, t) {
|
|
552
552
|
b(e, "duration", a, t), T(e, a, t), p(e, a, t);
|
|
@@ -593,7 +593,7 @@ function _t(e, a, t) {
|
|
|
593
593
|
R(e, "rotation", a, t), S(e, "rotationOrigin", a, t), S(e, "translate", a, t), R(e, "zIndex", a, t);
|
|
594
594
|
}
|
|
595
595
|
function Vt(e, a, t) {
|
|
596
|
-
typeof e.src != "string" && t.push({ path: `${a}.src`, message: 'Image requires a "src" string', severity: "error" }),
|
|
596
|
+
typeof e.src != "string" && t.push({ path: `${a}.src`, message: 'Image requires a "src" string', severity: "error" }), h(e, "x", a, t), h(e, "y", a, t), F(e, "width", a, t), F(e, "height", a, t), z(e, "preserveAspectRatio", a, t), e.borderRadius !== void 0 && (typeof e.borderRadius != "number" || e.borderRadius < 0) && t.push({ path: `${a}.borderRadius`, message: '"borderRadius" must be a number >= 0', severity: "error" }), e.clipShape !== void 0 && (ee.includes(e.clipShape) || t.push({
|
|
597
597
|
path: `${a}.clipShape`,
|
|
598
598
|
message: `Invalid clipShape "${e.clipShape}". Must be one of: ${ee.join(", ")}`,
|
|
599
599
|
severity: "error"
|
|
@@ -603,7 +603,7 @@ function Lt(e, a, t) {
|
|
|
603
603
|
p(e, a, t), w(e, a, t);
|
|
604
604
|
}
|
|
605
605
|
function jt(e, a, t) {
|
|
606
|
-
|
|
606
|
+
h(e, "x", a, t), h(e, "y", a, t), F(e, "width", a, t), F(e, "height", a, t), Array.isArray(e.bars) || t.push({ path: `${a}.bars`, message: 'BarChart requires a "bars" array', severity: "error" }), w(e, a, t);
|
|
607
607
|
}
|
|
608
608
|
function T(e, a, t) {
|
|
609
609
|
if (e.easing !== void 0) {
|
|
@@ -632,7 +632,7 @@ function T(e, a, t) {
|
|
|
632
632
|
t.push({ path: `${a}.easing`, message: 'Easing must be a string name or { type: "spring"|"cubicBezier", ... }', severity: "error" });
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function h(e, a, t, r) {
|
|
636
636
|
typeof e[a] != "number" && r.push({ path: `${t}.${a}`, message: `Required numeric field "${a}" is missing or not a number`, severity: "error" });
|
|
637
637
|
}
|
|
638
638
|
function F(e, a, t, r) {
|
|
@@ -721,7 +721,7 @@ function le(e, a) {
|
|
|
721
721
|
}
|
|
722
722
|
return ue(e, a);
|
|
723
723
|
case "presentation":
|
|
724
|
-
return Gt(e);
|
|
724
|
+
return Gt(e, a);
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
function H(e, a) {
|
|
@@ -759,19 +759,20 @@ function ue(e, a) {
|
|
|
759
759
|
}
|
|
760
760
|
);
|
|
761
761
|
}
|
|
762
|
-
function Gt(e) {
|
|
763
|
-
const { width:
|
|
762
|
+
function Gt(e, a) {
|
|
763
|
+
const { width: t, height: r } = L(e.preset, e.width, e.height);
|
|
764
764
|
return /* @__PURE__ */ l(
|
|
765
765
|
Te,
|
|
766
766
|
{
|
|
767
|
-
width:
|
|
768
|
-
height:
|
|
767
|
+
width: t,
|
|
768
|
+
height: r,
|
|
769
769
|
background: u(e.background),
|
|
770
770
|
transition: e.transition,
|
|
771
771
|
transitionDuration: e.transitionDuration,
|
|
772
772
|
showHUD: e.showHud,
|
|
773
773
|
showNotes: e.showNotes,
|
|
774
|
-
|
|
774
|
+
colorScheme: a == null ? void 0 : a.colorScheme,
|
|
775
|
+
children: e.slides.map((i, n) => Ht(i, n))
|
|
775
776
|
}
|
|
776
777
|
);
|
|
777
778
|
}
|
|
@@ -1279,7 +1280,7 @@ function v(e, a) {
|
|
|
1279
1280
|
return null;
|
|
1280
1281
|
}
|
|
1281
1282
|
}
|
|
1282
|
-
const
|
|
1283
|
+
const he = {
|
|
1283
1284
|
background: "#0a0a1e",
|
|
1284
1285
|
title: "#e0e7ff",
|
|
1285
1286
|
subtitle: "#94a3b8",
|
|
@@ -1317,7 +1318,7 @@ function Qt(e) {
|
|
|
1317
1318
|
r !== void 0 && (a[`--elucim-${t}`] = r);
|
|
1318
1319
|
return a;
|
|
1319
1320
|
}
|
|
1320
|
-
function
|
|
1321
|
+
function fe(e) {
|
|
1321
1322
|
return {
|
|
1322
1323
|
"--elucim-foreground": e.text,
|
|
1323
1324
|
"--elucim-background": e.background,
|
|
@@ -1334,7 +1335,7 @@ function he(e) {
|
|
|
1334
1335
|
"--elucim-error": e.error
|
|
1335
1336
|
};
|
|
1336
1337
|
}
|
|
1337
|
-
const Xt = he
|
|
1338
|
+
const Xt = fe(he), Jt = fe(Kt);
|
|
1338
1339
|
function Yt(e) {
|
|
1339
1340
|
if (typeof window > "u" || typeof window.matchMedia != "function") return () => {
|
|
1340
1341
|
};
|
|
@@ -1351,39 +1352,39 @@ function ta() {
|
|
|
1351
1352
|
return ot(Yt, Zt, ea);
|
|
1352
1353
|
}
|
|
1353
1354
|
const ga = ut(function({ dsl: a, className: t, style: r, theme: i, colorScheme: n, poster: s, onError: c }, x) {
|
|
1354
|
-
const m =
|
|
1355
|
-
|
|
1355
|
+
const m = ht(null), k = ta();
|
|
1356
|
+
ft(x, () => ({
|
|
1356
1357
|
getSvgElement: () => {
|
|
1357
|
-
var
|
|
1358
|
-
return ((
|
|
1358
|
+
var f;
|
|
1359
|
+
return ((f = m.current) == null ? void 0 : f.getSvgElement()) ?? null;
|
|
1359
1360
|
},
|
|
1360
|
-
seekToFrame: (
|
|
1361
|
+
seekToFrame: (f) => {
|
|
1361
1362
|
var C;
|
|
1362
|
-
return (C = m.current) == null ? void 0 : C.seekToFrame(
|
|
1363
|
+
return (C = m.current) == null ? void 0 : C.seekToFrame(f);
|
|
1363
1364
|
},
|
|
1364
1365
|
getTotalFrames: () => {
|
|
1365
|
-
var
|
|
1366
|
-
return ((
|
|
1366
|
+
var f;
|
|
1367
|
+
return ((f = m.current) == null ? void 0 : f.getTotalFrames()) ?? 0;
|
|
1367
1368
|
},
|
|
1368
1369
|
play: () => {
|
|
1369
|
-
var
|
|
1370
|
-
return (
|
|
1370
|
+
var f;
|
|
1371
|
+
return (f = m.current) == null ? void 0 : f.play();
|
|
1371
1372
|
},
|
|
1372
1373
|
pause: () => {
|
|
1373
|
-
var
|
|
1374
|
-
return (
|
|
1374
|
+
var f;
|
|
1375
|
+
return (f = m.current) == null ? void 0 : f.pause();
|
|
1375
1376
|
},
|
|
1376
1377
|
isPlaying: () => {
|
|
1377
|
-
var
|
|
1378
|
-
return ((
|
|
1378
|
+
var f;
|
|
1379
|
+
return ((f = m.current) == null ? void 0 : f.isPlaying()) ?? !1;
|
|
1379
1380
|
}
|
|
1380
1381
|
}));
|
|
1381
1382
|
const y = re(a);
|
|
1382
1383
|
if (!y.valid) {
|
|
1383
|
-
const
|
|
1384
|
-
c == null || c(
|
|
1384
|
+
const f = y.errors.filter((I) => I.severity === "error").map((I) => ({ path: I.path, message: I.message }));
|
|
1385
|
+
c == null || c(f);
|
|
1385
1386
|
const C = /* @__PURE__ */ new Map();
|
|
1386
|
-
for (const I of
|
|
1387
|
+
for (const I of f) {
|
|
1387
1388
|
const M = I.path.split("."), N = M.length > 1 ? M.slice(0, -1).join(".") : I.path, D = C.get(N) ?? [];
|
|
1388
1389
|
D.push(I), C.set(N, D);
|
|
1389
1390
|
}
|
|
@@ -1396,7 +1397,7 @@ const ga = ut(function({ dsl: a, className: t, style: r, theme: i, colorScheme:
|
|
|
1396
1397
|
children: [
|
|
1397
1398
|
/* @__PURE__ */ P("strong", { children: [
|
|
1398
1399
|
"Elucim DSL Validation Errors (",
|
|
1399
|
-
|
|
1400
|
+
f.length,
|
|
1400
1401
|
"):"
|
|
1401
1402
|
] }),
|
|
1402
1403
|
[...C.entries()].map(([I, M]) => /* @__PURE__ */ P("details", { open: !0, style: { marginTop: 8 }, children: [
|
|
@@ -1727,8 +1728,8 @@ class sa {
|
|
|
1727
1728
|
const d = x + g * (r + n);
|
|
1728
1729
|
return { x: d, y: s, w: r, h: i, cx: d + r / 2, cy: s + i / 2 };
|
|
1729
1730
|
}), k = a.map((y, g) => {
|
|
1730
|
-
var
|
|
1731
|
-
const d = m[g], $ = ((
|
|
1731
|
+
var f, C;
|
|
1732
|
+
const d = m[g], $ = ((f = t == null ? void 0 : t.colors) == null ? void 0 : f[g]) ?? this.theme.boxFill, O = ((C = t == null ? void 0 : t.strokeColors) == null ? void 0 : C[g]) ?? this.theme.boxStroke;
|
|
1732
1733
|
return {
|
|
1733
1734
|
type: "group",
|
|
1734
1735
|
children: [
|
|
@@ -1889,7 +1890,7 @@ class sa {
|
|
|
1889
1890
|
}
|
|
1890
1891
|
class ca {
|
|
1891
1892
|
constructor(a, t, r) {
|
|
1892
|
-
this._slides = [], this._title = a, this._theme = t ??
|
|
1893
|
+
this._slides = [], this._title = a, this._theme = t ?? he, this._opts = {
|
|
1893
1894
|
width: 900,
|
|
1894
1895
|
height: 640,
|
|
1895
1896
|
fps: 30,
|
|
@@ -1964,7 +1965,7 @@ export {
|
|
|
1964
1965
|
oa as TOKEN_NAMES,
|
|
1965
1966
|
mt as compileExpression,
|
|
1966
1967
|
yt as compileVectorExpression,
|
|
1967
|
-
|
|
1968
|
+
he as darkTheme,
|
|
1968
1969
|
Kt as lightTheme,
|
|
1969
1970
|
ya as presentation,
|
|
1970
1971
|
v as renderElement,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elucim/dsl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "JSON/YAML DSL for declarative Elucim animations — define visualizations without writing React code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vite": "^5.4.0",
|
|
59
59
|
"vite-plugin-dts": "^4.0.0",
|
|
60
60
|
"vitest": "^2.0.0",
|
|
61
|
-
"@elucim/core": "0.
|
|
61
|
+
"@elucim/core": "0.9.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"dev": "vite build --watch",
|