@pixerate/editor 0.164.0 → 0.166.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/agent/index.cjs +54 -39
- package/dist/agent/index.js +24 -9
- package/dist/animation/index.cjs +6 -5
- package/dist/animation/index.js +5 -4
- package/dist/animation-editor/index.cjs +65 -64
- package/dist/animation-editor/index.js +8 -7
- package/dist/bridge/cli.cjs +3 -3
- package/dist/bridge/cli.js +2 -2
- package/dist/bridge/index.cjs +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/canvas/index.cjs +89 -87
- package/dist/canvas/index.js +11 -9
- package/dist/chart/controller.d.cts +60 -2
- package/dist/chart/controller.d.ts +60 -2
- package/dist/chart/index.cjs +657 -163
- package/dist/chart/index.d.cts +3 -0
- package/dist/chart/index.d.ts +3 -0
- package/dist/chart/index.js +512 -18
- package/dist/chart/layout-families.d.cts +14 -0
- package/dist/chart/layout-families.d.ts +14 -0
- package/dist/chart/layout-shared.d.cts +5 -0
- package/dist/chart/layout-shared.d.ts +5 -0
- package/dist/chart/links.d.cts +34 -0
- package/dist/chart/links.d.ts +34 -0
- package/dist/chart/mermaid.d.cts +9 -6
- package/dist/chart/mermaid.d.ts +9 -6
- package/dist/chart/race.d.cts +26 -0
- package/dist/chart/race.d.ts +26 -0
- package/dist/chart/schemas.d.cts +5 -0
- package/dist/chart/schemas.d.ts +5 -0
- package/dist/chart/spec.d.cts +3 -2
- package/dist/chart/spec.d.ts +3 -2
- package/dist/chart/style.d.cts +33 -0
- package/dist/chart/style.d.ts +33 -0
- package/dist/chart/types.d.cts +28 -2
- package/dist/chart/types.d.ts +28 -2
- package/dist/{chunk-ZVNAMTFO.cjs → chunk-3FSUJIXN.cjs} +18 -174
- package/dist/{chunk-RQCMSEM5.cjs → chunk-4QUUHTGJ.cjs} +2 -2
- package/dist/{chunk-CIPIESX4.cjs → chunk-4ZC5QJE2.cjs} +3 -3
- package/dist/{chunk-S6X2QRVU.cjs → chunk-5UEFBM2M.cjs} +1 -138
- package/dist/{chunk-5FNGLV2D.js → chunk-5UNQDC3Q.js} +18 -3
- package/dist/{chunk-YSAGBIRW.cjs → chunk-6FYIFGBW.cjs} +16 -16
- package/dist/{chunk-QYZGBVNC.js → chunk-7272D3K2.js} +10 -8
- package/dist/{chunk-462WGGXX.cjs → chunk-AMX23CSN.cjs} +27 -16
- package/dist/{chunk-3VLOOO3G.js → chunk-BDIM6NVW.js} +1 -1
- package/dist/{chunk-R3P2M7HU.cjs → chunk-BPX4Z3N3.cjs} +355 -207
- package/dist/{chunk-D54JHQK2.cjs → chunk-CHLV7UFP.cjs} +51 -51
- package/dist/{chunk-OXERWBKE.js → chunk-DFCAR7AW.js} +3 -3
- package/dist/{chunk-GZ2FM3ZB.js → chunk-DKNEQX7T.js} +6 -162
- package/dist/{chunk-JCXMJUQO.cjs → chunk-EGZM52EO.cjs} +3 -3
- package/dist/{chunk-ES3UEVUT.cjs → chunk-EUIDTZNQ.cjs} +112 -110
- package/dist/{chunk-H3OEM3Q2.js → chunk-F6R67I3A.js} +1 -1
- package/dist/{chunk-3NEZJCBY.js → chunk-FR432ROA.js} +349 -201
- package/dist/chunk-HIDFL5LQ.js +484 -0
- package/dist/{chunk-22KLZZGH.cjs → chunk-HXOBOHH2.cjs} +8 -8
- package/dist/{chunk-MKTDELCD.js → chunk-I5MRJW7B.js} +1 -1
- package/dist/{chunk-SDHZG5TF.js → chunk-ILP77UD6.js} +160 -2
- package/dist/{chunk-Z4P2RBMJ.js → chunk-ITANXMZD.js} +177 -3
- package/dist/chunk-KGRZMHZB.js +204 -0
- package/dist/{chunk-SET6KJOP.js → chunk-LPIKXPBM.js} +1 -1
- package/dist/{chunk-BQWGN5WH.js → chunk-M2TPMYJE.js} +1 -1
- package/dist/{chunk-GTELFJRE.cjs → chunk-M5GLQQWG.cjs} +2 -2
- package/dist/{chunk-4VU4CP7R.js → chunk-MHLU6GRJ.js} +1 -138
- package/dist/{chunk-NZD2MZJC.cjs → chunk-MZFZSVUJ.cjs} +38 -23
- package/dist/{chunk-DAPQGA55.js → chunk-NQQDGGXY.js} +2 -2
- package/dist/chunk-O6OGNDND.js +164 -0
- package/dist/{chunk-PA3IMPPS.cjs → chunk-OVYQAYGH.cjs} +81 -81
- package/dist/{chunk-YXOW456B.js → chunk-PPEDZ5WR.js} +1 -1
- package/dist/{chunk-24M7VD6M.cjs → chunk-S4EIAIEW.cjs} +7 -7
- package/dist/{chunk-M4MIZPQI.cjs → chunk-SJ2CPTQC.cjs} +189 -15
- package/dist/{chunk-YGG7WDWT.cjs → chunk-SZWVMB3B.cjs} +24 -18
- package/dist/chunk-TFF2GTGN.cjs +153 -0
- package/dist/chunk-TTCJPX4U.cjs +204 -0
- package/dist/{chunk-SBQVEBSU.cjs → chunk-UUUTEVX6.cjs} +242 -68
- package/dist/{chunk-WI7QJA7A.cjs → chunk-UXETV2NC.cjs} +161 -3
- package/dist/{chunk-GKNEJ6EN.cjs → chunk-V5L2G22R.cjs} +321 -107
- package/dist/{chunk-TALQONZ5.js → chunk-VB2CY6EG.js} +3 -3
- package/dist/{chunk-QY4KUDMY.js → chunk-VRXXAXUT.js} +2 -2
- package/dist/chunk-VU6WQSMB.cjs +164 -0
- package/dist/{chunk-NHLYK3AX.js → chunk-XBQX76CT.js} +182 -8
- package/dist/{chunk-5AARIS3R.cjs → chunk-XCDGM7TD.cjs} +37 -37
- package/dist/{chunk-POR54B55.js → chunk-XNU45TYA.js} +7 -1
- package/dist/{chunk-EVXQNQND.js → chunk-XZB3TJ6K.js} +16 -5
- package/dist/chunk-YBAPT7NL.js +153 -0
- package/dist/{chunk-SZA42R4N.js → chunk-YUFTVNLX.js} +230 -16
- package/dist/chunk-Z2UQYMPS.cjs +484 -0
- package/dist/color/index.cjs +5 -3
- package/dist/color/index.js +12 -10
- package/dist/diagram/index.cjs +55 -243
- package/dist/diagram/index.js +12 -200
- package/dist/export/index.cjs +7 -6
- package/dist/export/index.js +6 -5
- package/dist/extensions/index.cjs +12 -9
- package/dist/extensions/index.js +11 -8
- package/dist/gradient/index.cjs +29 -27
- package/dist/gradient/index.js +6 -4
- package/dist/image-editor/index.cjs +644 -643
- package/dist/image-editor/index.js +7 -6
- package/dist/index.cjs +21 -18
- package/dist/index.js +14 -11
- package/dist/paint-editor/index.cjs +19 -18
- package/dist/paint-editor/index.js +7 -6
- package/dist/parameters/index.cjs +2 -2
- package/dist/parameters/index.js +1 -1
- package/dist/persistence/assetWrites.d.cts +22 -0
- package/dist/persistence/assetWrites.d.ts +22 -0
- package/dist/persistence/assets.d.cts +71 -0
- package/dist/persistence/assets.d.ts +71 -0
- package/dist/persistence/documentStore.d.cts +17 -1
- package/dist/persistence/documentStore.d.ts +17 -1
- package/dist/persistence/documentTools.d.cts +5 -1
- package/dist/persistence/documentTools.d.ts +5 -1
- package/dist/persistence/editorAutosave.d.cts +7 -0
- package/dist/persistence/editorAutosave.d.ts +7 -0
- package/dist/persistence/index.cjs +141 -21
- package/dist/persistence/index.js +130 -10
- package/dist/persistence/storage.d.cts +13 -1
- package/dist/persistence/storage.d.ts +13 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.js +2 -2
- package/dist/tokens/index.cjs +11 -3
- package/dist/tokens/index.d.cts +1 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +10 -2
- package/dist/tokens/style.d.cts +36 -0
- package/dist/tokens/style.d.ts +36 -0
- package/dist/tools/index.cjs +15 -3
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +14 -2
- package/dist/tools/style-tools.d.cts +19 -0
- package/dist/tools/style-tools.d.ts +19 -0
- package/dist/tools/style.d.cts +212 -0
- package/dist/tools/style.d.ts +212 -0
- package/dist/tools/view.d.cts +6 -0
- package/dist/tools/view.d.ts +6 -0
- package/dist/typography/index.cjs +8 -6
- package/dist/typography/index.js +5 -3
- package/dist/vector/index.cjs +953 -952
- package/dist/vector/index.js +7 -6
- package/dist/video-editor/index.cjs +8 -7
- package/dist/video-editor/index.js +6 -5
- package/package.json +1 -1
- package/skills/pixerate-chart/SKILL.md +20 -2
- package/dist/chunk-ERAGQL2N.cjs +0 -68
- package/dist/chunk-KMU6QJB7.js +0 -68
|
@@ -551,117 +551,6 @@ function isColor(input) {
|
|
|
551
551
|
return parseColor(input) !== null;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
// src/color/gamut.ts
|
|
555
|
-
var clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
556
|
-
function inSrgbGamut(c, epsilon = 1e-5) {
|
|
557
|
-
return c.r >= -epsilon && c.r <= 1 + epsilon && c.g >= -epsilon && c.g <= 1 + epsilon && c.b >= -epsilon && c.b <= 1 + epsilon;
|
|
558
|
-
}
|
|
559
|
-
function deltaEOK(a, b) {
|
|
560
|
-
const la = rgbToOklab(a);
|
|
561
|
-
const lb = rgbToOklab(b);
|
|
562
|
-
return Math.hypot(la.l - lb.l, la.a - lb.a, la.b - lb.b);
|
|
563
|
-
}
|
|
564
|
-
function toSrgbGamut(c) {
|
|
565
|
-
const lch = oklabToOklch(rgbToOklab(c));
|
|
566
|
-
if (lch.l >= 1) return { r: 1, g: 1, b: 1, a: c.a };
|
|
567
|
-
if (lch.l <= 0) return { r: 0, g: 0, b: 0, a: c.a };
|
|
568
|
-
if (inSrgbGamut(c)) {
|
|
569
|
-
return { r: clamp01(c.r), g: clamp01(c.g), b: clamp01(c.b), a: c.a };
|
|
570
|
-
}
|
|
571
|
-
let low = 0;
|
|
572
|
-
let high = lch.c;
|
|
573
|
-
let clippedCandidate = { r: clamp01(c.r), g: clamp01(c.g), b: clamp01(c.b), a: c.a };
|
|
574
|
-
const JND = 0.02;
|
|
575
|
-
const EPS = 1e-4;
|
|
576
|
-
for (let i = 0; i < 30; i++) {
|
|
577
|
-
const mid = (low + high) / 2;
|
|
578
|
-
const candidate = oklabToRgb(oklchToOklab({ l: lch.l, c: mid, h: lch.h, alpha: c.a }));
|
|
579
|
-
const clipped = {
|
|
580
|
-
r: clamp01(candidate.r),
|
|
581
|
-
g: clamp01(candidate.g),
|
|
582
|
-
b: clamp01(candidate.b),
|
|
583
|
-
a: c.a
|
|
584
|
-
};
|
|
585
|
-
clippedCandidate = clipped;
|
|
586
|
-
const dE = deltaEOK(candidate, clipped);
|
|
587
|
-
if (dE < JND) {
|
|
588
|
-
if (JND - dE < EPS) {
|
|
589
|
-
return clipped;
|
|
590
|
-
}
|
|
591
|
-
low = mid;
|
|
592
|
-
} else {
|
|
593
|
-
high = mid;
|
|
594
|
-
}
|
|
595
|
-
if (high - low < 1e-4) {
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
return clippedCandidate;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// src/color/format.ts
|
|
603
|
-
var clamp012 = (v) => Math.min(1, Math.max(0, v));
|
|
604
|
-
var byte = (v) => Math.round(clamp012(v) * 255);
|
|
605
|
-
var hex2 = (n) => n.toString(16).padStart(2, "0");
|
|
606
|
-
var round2 = (n) => (Math.round(n * 100) / 100).toString();
|
|
607
|
-
function formatHex(c) {
|
|
608
|
-
const mapped = toSrgbGamut(c);
|
|
609
|
-
const head = `#${hex2(byte(mapped.r))}${hex2(byte(mapped.g))}${hex2(byte(mapped.b))}`;
|
|
610
|
-
const alpha = byte(mapped.a);
|
|
611
|
-
return alpha === 255 ? head : head + hex2(alpha);
|
|
612
|
-
}
|
|
613
|
-
function formatColor(c, format) {
|
|
614
|
-
switch (format) {
|
|
615
|
-
case "hex":
|
|
616
|
-
return formatHex(c);
|
|
617
|
-
case "rgb": {
|
|
618
|
-
const inGamut = toSrgbGamut(c);
|
|
619
|
-
const r = byte(inGamut.r);
|
|
620
|
-
const g = byte(inGamut.g);
|
|
621
|
-
const b = byte(inGamut.b);
|
|
622
|
-
return c.a < 1 ? `rgb(${r} ${g} ${b} / ${round2(c.a)})` : `rgb(${r} ${g} ${b})`;
|
|
623
|
-
}
|
|
624
|
-
case "hsl": {
|
|
625
|
-
const hsl = rgbToHsl(toSrgbGamut(c));
|
|
626
|
-
const h = (Math.round(hsl.h * 100) / 100).toString();
|
|
627
|
-
const s = (Math.round(hsl.s * 1e4) / 100).toString();
|
|
628
|
-
const l = (Math.round(hsl.l * 1e4) / 100).toString();
|
|
629
|
-
return c.a < 1 ? `hsl(${h} ${s}% ${l}% / ${round2(c.a)})` : `hsl(${h} ${s}% ${l}%)`;
|
|
630
|
-
}
|
|
631
|
-
case "oklch": {
|
|
632
|
-
const lch = oklabToOklch(rgbToOklab(c));
|
|
633
|
-
const l = (lch.l * 100).toFixed(2);
|
|
634
|
-
const ch = lch.c.toFixed(4);
|
|
635
|
-
const h = lch.h.toFixed(2);
|
|
636
|
-
return c.a < 1 ? `oklch(${l}% ${ch} ${h} / ${round2(c.a)})` : `oklch(${l}% ${ch} ${h})`;
|
|
637
|
-
}
|
|
638
|
-
case "oklab": {
|
|
639
|
-
const lab = rgbToOklab(c);
|
|
640
|
-
const l = (lab.l * 100).toFixed(2);
|
|
641
|
-
const a = lab.a.toFixed(4);
|
|
642
|
-
const b = lab.b.toFixed(4);
|
|
643
|
-
return c.a < 1 ? `oklab(${l}% ${a} ${b} / ${round2(c.a)})` : `oklab(${l}% ${a} ${b})`;
|
|
644
|
-
}
|
|
645
|
-
case "p3": {
|
|
646
|
-
const linSrgb = {
|
|
647
|
-
r: srgbToLinear(c.r),
|
|
648
|
-
g: srgbToLinear(c.g),
|
|
649
|
-
b: srgbToLinear(c.b),
|
|
650
|
-
a: c.a
|
|
651
|
-
};
|
|
652
|
-
const linP3 = linearSrgbToDisplayP3(linSrgb);
|
|
653
|
-
const r = linearToSrgb(linP3.r).toFixed(4);
|
|
654
|
-
const g = linearToSrgb(linP3.g).toFixed(4);
|
|
655
|
-
const b = linearToSrgb(linP3.b).toFixed(4);
|
|
656
|
-
return c.a < 1 ? `color(display-p3 ${r} ${g} ${b} / ${round2(c.a)})` : `color(display-p3 ${r} ${g} ${b})`;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
function normalizeColor(input) {
|
|
661
|
-
const parsed = parseColor(input);
|
|
662
|
-
return parsed ? formatHex(parsed) : null;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
554
|
// src/color/contrast.ts
|
|
666
555
|
var BLACK = { r: 0, g: 0, b: 0, a: 1 };
|
|
667
556
|
var WHITE = { r: 1, g: 1, b: 1, a: 1 };
|
|
@@ -720,25 +609,6 @@ function readableTextColor(background, candidates = [BLACK, WHITE]) {
|
|
|
720
609
|
return bestCandidate;
|
|
721
610
|
}
|
|
722
611
|
|
|
723
|
-
// src/color/suggest.ts
|
|
724
|
-
function suggestAccessibleForeground(foreground, background, options = {}) {
|
|
725
|
-
const large = options.large ?? false;
|
|
726
|
-
const lch = oklabToOklch(rgbToOklab(foreground));
|
|
727
|
-
const asHex = (l) => parseColor(formatHex(toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l })))));
|
|
728
|
-
for (let d = 0.01; d <= 1; d += 0.01) {
|
|
729
|
-
const downCand = asHex(Math.max(0, lch.l - d));
|
|
730
|
-
const upCand = asHex(Math.min(1, lch.l + d));
|
|
731
|
-
const downRatio = contrastRatio(downCand, background);
|
|
732
|
-
const upRatio = contrastRatio(upCand, background);
|
|
733
|
-
const downPass = contrastLevel(downRatio, { large }) !== "fail";
|
|
734
|
-
const upPass = contrastLevel(upRatio, { large }) !== "fail";
|
|
735
|
-
if (downPass && upPass) return formatHex(downRatio >= upRatio ? downCand : upCand);
|
|
736
|
-
if (downPass) return formatHex(downCand);
|
|
737
|
-
if (upPass) return formatHex(upCand);
|
|
738
|
-
}
|
|
739
|
-
return void 0;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
612
|
export {
|
|
743
613
|
srgbToLinear,
|
|
744
614
|
linearToSrgb,
|
|
@@ -755,15 +625,8 @@ export {
|
|
|
755
625
|
NAMED_COLORS,
|
|
756
626
|
parseColor,
|
|
757
627
|
isColor,
|
|
758
|
-
inSrgbGamut,
|
|
759
|
-
deltaEOK,
|
|
760
|
-
toSrgbGamut,
|
|
761
|
-
formatHex,
|
|
762
|
-
formatColor,
|
|
763
|
-
normalizeColor,
|
|
764
628
|
relativeLuminance,
|
|
765
629
|
contrastRatio,
|
|
766
630
|
contrastLevel,
|
|
767
|
-
readableTextColor
|
|
768
|
-
suggestAccessibleForeground
|
|
631
|
+
readableTextColor
|
|
769
632
|
};
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var _chunkBPX4Z3N3cjs = require('./chunk-BPX4Z3N3.cjs');
|
|
21
22
|
|
|
22
23
|
// src/chart/schemas.ts
|
|
23
24
|
var VALUE = { type: ["number", "string", "null"], description: 'A number, numeric text ("1,200", "12%", "$40", "(3)") or null for a gap.' };
|
|
@@ -29,7 +30,7 @@ var FORMAT = {
|
|
|
29
30
|
type: "object",
|
|
30
31
|
description: "How numbers are written on this axis or series.",
|
|
31
32
|
properties: {
|
|
32
|
-
style: { type: "string", enum: [...
|
|
33
|
+
style: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_NUMBER_STYLES], description: "number (default), percent (0.25 \u2192 25%), currency or compact (1.2K)." },
|
|
33
34
|
decimals: { type: "integer", minimum: 0, maximum: 10, description: "Fixed decimals (default: what the ticks need)." },
|
|
34
35
|
currency: { type: "string", description: 'ISO currency code for style "currency", e.g. "EUR" (default USD).' },
|
|
35
36
|
prefix: { type: "string", description: "Text before every number." },
|
|
@@ -49,10 +50,10 @@ var AXIS = (what) => ({
|
|
|
49
50
|
step: { type: ["number", "null"], exclusiveMinimum: 0, description: "Fixed distance between ticks, or null for automatic." },
|
|
50
51
|
gridlines: { type: "boolean", description: "Grid lines at each tick." },
|
|
51
52
|
format: FORMAT,
|
|
52
|
-
kind: { type: ["string", "null"], enum: [...
|
|
53
|
+
kind: { type: ["string", "null"], enum: [..._chunkBPX4Z3N3cjs.CHART_AXIS_KINDS, null], description: 'Category axis only: "date" reads categories as dates and labels them by calendar steps.' },
|
|
53
54
|
scale: {
|
|
54
55
|
type: ["string", "null"],
|
|
55
|
-
enum: [...
|
|
56
|
+
enum: [..._chunkBPX4Z3N3cjs.CHART_AXIS_SCALES, null],
|
|
56
57
|
description: 'Value axes and the numeric x axis of scatter / bubble charts: "log" spaces ticks by powers of logBase (values of 0 or less are skipped; min and max must be above 0; not with percent stacking). "linear" or null is the default. Ignored on a category axis.'
|
|
57
58
|
},
|
|
58
59
|
logBase: { type: ["number", "null"], minimum: 2, maximum: 1e3, description: "Base of a log axis, 2 to 1000 (default 10; null resets)." },
|
|
@@ -61,7 +62,7 @@ var AXIS = (what) => ({
|
|
|
61
62
|
additionalProperties: false
|
|
62
63
|
});
|
|
63
64
|
var TRENDLINE_PROPS = {
|
|
64
|
-
type: { type: "string", enum: [...
|
|
65
|
+
type: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_TRENDLINE_TYPES], description: "Fit: linear, exponential, logarithmic, power, polynomial or moving-average." },
|
|
65
66
|
order: { type: "integer", minimum: 2, maximum: 6, description: "Polynomial order (default 2)." },
|
|
66
67
|
period: { type: "integer", minimum: 2, description: "Moving-average period in points (default 2)." },
|
|
67
68
|
forward: { type: "number", minimum: 0, description: "Extend the line this many x units past the last point (default 0)." },
|
|
@@ -76,7 +77,7 @@ var REFERENCE_COMMON = {
|
|
|
76
77
|
label: { type: "string", description: 'Text written on it, e.g. "Target" (default none).' },
|
|
77
78
|
axis: {
|
|
78
79
|
type: "string",
|
|
79
|
-
enum: [...
|
|
80
|
+
enum: [..._chunkBPX4Z3N3cjs.CHART_REFERENCE_AXES],
|
|
80
81
|
description: "Axis it is measured on: y (default) is the value axis, y2 the secondary value axis (needs a series there), x the numeric x axis of a scatter or bubble chart."
|
|
81
82
|
},
|
|
82
83
|
color: { type: "string", description: "CSS colour (default: the text colour)." }
|
|
@@ -92,7 +93,7 @@ var REFERENCE_BAND_PROPS = {
|
|
|
92
93
|
};
|
|
93
94
|
var REFERENCE_COMMON_PATCH = {
|
|
94
95
|
label: { type: ["string", "null"], description: "Text written on it; null removes it." },
|
|
95
|
-
axis: { type: ["string", "null"], enum: [...
|
|
96
|
+
axis: { type: ["string", "null"], enum: [..._chunkBPX4Z3N3cjs.CHART_REFERENCE_AXES, null], description: "Axis it is measured on (y, y2 or x); null goes back to y." },
|
|
96
97
|
color: { type: ["string", "null"], description: "CSS colour; null goes back to the text colour." }
|
|
97
98
|
};
|
|
98
99
|
var REFERENCE_LINE_PATCH = { value: REFERENCE_LINE_PROPS.value, ...REFERENCE_COMMON_PATCH };
|
|
@@ -112,19 +113,27 @@ var TREE_NODE = {
|
|
|
112
113
|
};
|
|
113
114
|
var TREE_DEFS = { chartTreeNode: TREE_NODE };
|
|
114
115
|
var TREE_PATH = { type: "array", items: { type: "string" }, minItems: 1, description: 'Names from the top level down to the node, e.g. ["Europe", "France"] (from get_chart treeTable or spec.tree).' };
|
|
116
|
+
var LINK_PROPS = {
|
|
117
|
+
source: { type: "string", description: "Name of the node the flow leaves." },
|
|
118
|
+
target: { type: "string", description: "Name of the node it reaches (a different node; flows only go forwards, no loops)." },
|
|
119
|
+
value: { type: "number", exclusiveMinimum: 0, description: "How much flows, above 0 (its width)." },
|
|
120
|
+
color: { type: "string", description: "CSS colour (default: by sankeyLinkColor)." }
|
|
121
|
+
};
|
|
122
|
+
var RACE_TIME = { type: ["string", "number"], description: 'Time point label (a category, e.g. "2023") or index from 0; an index may be fractional, 2.5 being halfway between the third and fourth time points.' };
|
|
123
|
+
var LINK_INDEX = { type: "integer", minimum: 0, description: "Flow index (0 = first), as get_chart lists them in spec.links." };
|
|
115
124
|
var ERROR_BARS = (what) => ({
|
|
116
125
|
type: ["object", "null"],
|
|
117
126
|
description: `${what} null removes them.`,
|
|
118
127
|
properties: {
|
|
119
128
|
type: {
|
|
120
129
|
type: "string",
|
|
121
|
-
enum: [...
|
|
130
|
+
enum: [..._chunkBPX4Z3N3cjs.CHART_ERROR_BAR_TYPES],
|
|
122
131
|
description: "fixed: the same amount at every point; percent: a percentage of each value; stddev: value standard deviations of the series, drawn around the series mean (as Excel does); stderr: the standard error of the series at every point; custom: per-point plus / minus amounts."
|
|
123
132
|
},
|
|
124
133
|
value: { type: "number", minimum: 0, description: "Amount in data units for fixed (default 1), percent of each value for percent (default 5), number of standard deviations for stddev (default 1). Not for stderr or custom." },
|
|
125
134
|
plus: { type: "array", items: VALUE, description: "custom only: amount above each point, one per category, in data units (0 or more; null for none)." },
|
|
126
135
|
minus: { type: "array", items: VALUE, description: "custom only: amount below each point, one per category (default: the plus amounts)." },
|
|
127
|
-
direction: { type: "string", enum: [...
|
|
136
|
+
direction: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_ERROR_BAR_DIRECTIONS], description: "both (default), plus (only above) or minus (only below)." },
|
|
128
137
|
cap: { type: "boolean", description: "Draw end caps (default true)." }
|
|
129
138
|
},
|
|
130
139
|
required: ["type"],
|
|
@@ -134,22 +143,22 @@ var SERIES_PROPS = {
|
|
|
134
143
|
name: { type: "string", description: "Series name (legend and data grid header)." },
|
|
135
144
|
values: { type: "array", items: VALUE, description: "One value per category, in category order (padded with gaps)." },
|
|
136
145
|
color: { type: ["string", "null"], description: "CSS colour, or null for the palette colour." },
|
|
137
|
-
type: { type: ["string", "null"], enum: [...
|
|
146
|
+
type: { type: ["string", "null"], enum: [..._chunkBPX4Z3N3cjs.CHART_SERIES_TYPES, null], description: "Draw this series as bar, line, area or scatter (a combo chart); null follows the chart type." },
|
|
138
147
|
hidden: { type: "boolean", description: "Hide the series (its data is kept)." },
|
|
139
148
|
axis: { type: ["string", "null"], enum: ["primary", "secondary", null], description: "Value axis: secondary is drawn on the right with its own scale." },
|
|
140
149
|
x: { type: ["array", "null"], items: VALUE, description: "Numeric x per category, for scatter and bubble charts." },
|
|
141
150
|
sizes: { type: ["array", "null"], items: VALUE, description: "Bubble sizes per category (area is proportional to size)." },
|
|
142
151
|
pointColors: { type: ["array", "null"], items: { type: ["string", "null"] }, description: "Colour per category (null keeps the series colour)." },
|
|
143
152
|
callouts: { type: ["array", "null"], items: { type: ["string", "null"] }, description: "A label pinned to each point that matters, one per category (null: none); null removes them all. Bar, line, area and scatter charts. set_chart_callout sets one." },
|
|
144
|
-
marker: { type: ["string", "null"], enum: [...
|
|
145
|
-
curve: { type: ["string", "null"], enum: [...
|
|
153
|
+
marker: { type: ["string", "null"], enum: [..._chunkBPX4Z3N3cjs.CHART_MARKERS, null], description: "Point marker shape for line, area and scatter series." },
|
|
154
|
+
curve: { type: ["string", "null"], enum: [..._chunkBPX4Z3N3cjs.CHART_CURVES, null], description: "Line shape for this series: linear, smooth or step." },
|
|
146
155
|
dataLabels: { type: ["boolean", "null"], description: "Value labels for this series (null follows the chart)." },
|
|
147
156
|
format: { ...FORMAT, type: ["object", "null"], description: "How this series' labels are written (null follows the value axis)." },
|
|
148
157
|
errorBars: ERROR_BARS("Error bars along the value axis (bar, line, area and scatter series; on stacked charts they sit on the stack top)."),
|
|
149
158
|
xErrorBars: ERROR_BARS("Error bars along the x axis (scatter and bubble charts with numeric x values; amounts in x units).")
|
|
150
159
|
};
|
|
151
160
|
var CHART_UPDATE_PROPERTIES = {
|
|
152
|
-
type: { type: "string", enum: [...
|
|
161
|
+
type: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_TYPES], description: "Chart type. slope joins each category from the first series (before) to the second (after); likert reads each category as a question and the series as answers from most negative to most positive; parliament draws the first series as seats; sunburst draws the grouped data (set_chart_tree) as rings, and a treemap with grouped data nests its groups; sankey draws the flows (set_chart_links); barrace reads categories as time points and series as names, and animates their ranking." },
|
|
153
162
|
title: { type: "string", description: 'Title ("" for none).' },
|
|
154
163
|
subtitle: { type: "string", description: 'Subtitle ("" for none).' },
|
|
155
164
|
xAxis: AXIS("Category axis (or numeric x axis of scatter / bubble charts)."),
|
|
@@ -158,15 +167,15 @@ var CHART_UPDATE_PROPERTIES = {
|
|
|
158
167
|
legend: {
|
|
159
168
|
type: "object",
|
|
160
169
|
description: "Legend.",
|
|
161
|
-
properties: { show: { type: "boolean", description: "Show the legend." }, position: { type: "string", enum: [...
|
|
170
|
+
properties: { show: { type: "boolean", description: "Show the legend." }, position: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_LEGEND_POSITIONS], description: "Where the legend goes." } },
|
|
162
171
|
additionalProperties: false
|
|
163
172
|
},
|
|
164
|
-
stacking: { type: "string", enum: [...
|
|
165
|
-
orientation: { type: "string", enum: [...
|
|
166
|
-
curve: { type: "string", enum: [...
|
|
173
|
+
stacking: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_STACKINGS], description: "none, stacked, or percent (each category scaled to 100%)." },
|
|
174
|
+
orientation: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_ORIENTATIONS], description: "horizontal draws bars sideways." },
|
|
175
|
+
curve: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_CURVES], description: "Line shape: linear, smooth or step." },
|
|
167
176
|
points: { type: "boolean", description: "Dots on line and area series." },
|
|
168
177
|
dataLabels: { type: "boolean", description: "Value labels on bars, points and slices." },
|
|
169
|
-
labelPosition: { type: "string", enum: [...
|
|
178
|
+
labelPosition: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_LABEL_POSITIONS], description: "Bar label position; auto drops labels that do not fit." },
|
|
170
179
|
palette: { type: "array", items: { type: "string" }, minItems: 1, description: "Series colours in order (CSS colours)." },
|
|
171
180
|
innerRadius: { type: "number", minimum: 0, maximum: 0.9, description: "Donut hole as a fraction of the radius." },
|
|
172
181
|
gapWidth: { type: "number", minimum: 0, maximum: 0.9, description: "Space between bar groups as a fraction of the category (default 0.28)." },
|
|
@@ -174,18 +183,21 @@ var CHART_UPDATE_PROPERTIES = {
|
|
|
174
183
|
bins: { type: ["integer", "null"], minimum: 1, maximum: 500, description: "Histogram bin count, or null for \u221An." },
|
|
175
184
|
showTotal: { type: "boolean", description: "Waterfall: append a total bar." },
|
|
176
185
|
radarTicks: { type: ["integer", "null"], minimum: 1, maximum: 50, description: "Radar: number of evenly spaced rings from the value axis min to max, or null for round-number rings (default null)." },
|
|
177
|
-
radarGraticule: { type: "string", enum: [...
|
|
186
|
+
radarGraticule: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_RADAR_GRATICULES], description: "Radar: draw rings as polygons through the spokes or as circles (default polygon)." },
|
|
178
187
|
note: { type: "string", description: 'A source or footnote written under the chart ("" for none).' },
|
|
179
188
|
highlight: { type: "array", items: { type: "string" }, description: "Category labels and series names (or ids) to draw normally while the rest are muted; [] shows everything. highlight_chart checks the names." },
|
|
180
189
|
referenceLines: { type: "array", items: { type: "object", properties: REFERENCE_LINE_PROPS, required: ["value"], additionalProperties: false }, description: "Replaces every reference line (targets, floors, averages across the plot). add_chart_reference_line adds one." },
|
|
181
190
|
referenceBands: { type: "array", items: { type: "object", properties: REFERENCE_BAND_PROPS, required: ["from", "to"], additionalProperties: false }, description: "Replaces every reference band (target ranges across the plot). add_chart_reference_band adds one." },
|
|
182
191
|
varyColors: { type: "boolean", description: "A one-series bar, line, area or scatter chart colours each category from the palette, and its legend lists the categories (default false)." },
|
|
183
|
-
likertNeutral: { type: "string", enum: [...
|
|
184
|
-
likertSort: { type: "string", enum: [...
|
|
192
|
+
likertNeutral: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_LIKERT_NEUTRALS], description: "Likert with an odd number of answers: split (default) puts the middle answer across the centre line; separate draws it in its own column on the right." },
|
|
193
|
+
likertSort: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_LIKERT_SORTS], description: "Likert: order the questions by agreement (positive), by disagreement (negative) or as given (none, default)." },
|
|
185
194
|
parliamentArc: { type: "number", minimum: 90, maximum: 360, description: "Parliament: sweep of the hemicycle in degrees (default 180)." },
|
|
186
195
|
parliamentMajority: { type: ["integer", "null"], minimum: 1, description: "Parliament: seats needed for a majority, drawn as a dashed line (null: half of the seats plus one)." },
|
|
187
196
|
parliamentLabel: { type: "string", description: 'Parliament: caption under the seat total ("" writes "seats").' },
|
|
188
|
-
sunburstLabel: { type: "string", description: 'Sunburst: caption under the total in the centre ("" for none).' }
|
|
197
|
+
sunburstLabel: { type: "string", description: 'Sunburst: caption under the total in the centre ("" for none).' },
|
|
198
|
+
sankeyLinkColor: { type: "string", enum: [..._chunkBPX4Z3N3cjs.CHART_SANKEY_LINK_COLORS], description: "Sankey: colour each flow by its source node (default), its target node, or grey." },
|
|
199
|
+
raceTopN: { type: "integer", minimum: 1, maximum: 30, description: "Bar race: how many bars each moment shows (default 10)." },
|
|
200
|
+
sankeyNodes: { type: "array", items: { type: "string" }, description: "Sankey: node names in the order to stack them within their columns (reorder to untangle crossing flows); nodes left out follow in the order the flows name them." }
|
|
189
201
|
};
|
|
190
202
|
|
|
191
203
|
|
|
@@ -204,4 +216,7 @@ var CHART_UPDATE_PROPERTIES = {
|
|
|
204
216
|
|
|
205
217
|
|
|
206
218
|
|
|
207
|
-
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
exports.VALUE = VALUE; exports.SERIES_REF = SERIES_REF; exports.CATEGORY_REF = CATEGORY_REF; exports.WIDTH = WIDTH; exports.HEIGHT = HEIGHT; exports.TRENDLINE_PROPS = TRENDLINE_PROPS; exports.REFERENCE_LINE_PROPS = REFERENCE_LINE_PROPS; exports.REFERENCE_BAND_PROPS = REFERENCE_BAND_PROPS; exports.REFERENCE_LINE_PATCH = REFERENCE_LINE_PATCH; exports.REFERENCE_BAND_PATCH = REFERENCE_BAND_PATCH; exports.REFERENCE_INDEX = REFERENCE_INDEX; exports.TREE_DEFS = TREE_DEFS; exports.TREE_PATH = TREE_PATH; exports.LINK_PROPS = LINK_PROPS; exports.RACE_TIME = RACE_TIME; exports.LINK_INDEX = LINK_INDEX; exports.SERIES_PROPS = SERIES_PROPS; exports.CHART_UPDATE_PROPERTIES = CHART_UPDATE_PROPERTIES;
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
CHART_OOXML_NS,
|
|
12
12
|
CHART_OOXML_RELATIONSHIP,
|
|
13
13
|
chartToOoxml
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XNU45TYA.js";
|
|
15
15
|
import {
|
|
16
16
|
normalizeChartSpec
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-FR432ROA.js";
|
|
18
18
|
|
|
19
19
|
// src/export/images.ts
|
|
20
20
|
var DOCX_IMAGE_TYPES = {
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// src/diagram/source/lines.ts
|
|
2
|
+
var HEADER_PATTERNS = [
|
|
3
|
+
[/^\s*(flowchart|graph)(?:-elk)?\b/i, "flowchart"],
|
|
4
|
+
[/^\s*stateDiagram(?:-v2)?\b/i, "state"],
|
|
5
|
+
[/^\s*classDiagram(?:-v2)?\b/i, "class"],
|
|
6
|
+
[/^\s*erDiagram\b/i, "er"],
|
|
7
|
+
[/^\s*requirementDiagram\b/i, "requirement"],
|
|
8
|
+
[/^\s*mindmap\b/i, "mindmap"],
|
|
9
|
+
[/^\s*sequenceDiagram\b/i, "sequence"],
|
|
10
|
+
[/^\s*gantt\b/i, "gantt"],
|
|
11
|
+
[/^\s*pie\b/i, "pie"],
|
|
12
|
+
[/^\s*journey\b/i, "journey"],
|
|
13
|
+
[/^\s*timeline\b/i, "timeline"],
|
|
14
|
+
[/^\s*gitGraph\b/i, "gitGraph"],
|
|
15
|
+
[/^\s*C4(Context|Container|Component|Dynamic|Deployment)\b/, "c4"],
|
|
16
|
+
[/^\s*quadrantChart\b/i, "quadrant"],
|
|
17
|
+
[/^\s*sankey(?:-beta)?\b/i, "sankey"],
|
|
18
|
+
[/^\s*xychart(?:-beta)?\b/i, "xychart"],
|
|
19
|
+
[/^\s*block(?:-beta)?\b/i, "block"],
|
|
20
|
+
[/^\s*architecture(?:-beta)?\b/i, "architecture"],
|
|
21
|
+
[/^\s*packet(?:-beta)?\b/i, "packet"],
|
|
22
|
+
[/^\s*kanban\b/i, "kanban"],
|
|
23
|
+
[/^\s*radar(?:-beta)?\b/i, "radar"],
|
|
24
|
+
[/^\s*treemap(?:-beta)?\b/i, "treemap"],
|
|
25
|
+
[/^\s*info\b/i, "info"]
|
|
26
|
+
];
|
|
27
|
+
function detectFamilyFromHeader(header) {
|
|
28
|
+
for (const [re, family] of HEADER_PATTERNS) {
|
|
29
|
+
if (re.test(header)) return family;
|
|
30
|
+
}
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
function isCommentLine(line) {
|
|
34
|
+
const t = line.trim();
|
|
35
|
+
return t.startsWith("%%") && !t.startsWith("%%{");
|
|
36
|
+
}
|
|
37
|
+
function isDirectiveLine(line) {
|
|
38
|
+
return /^\s*%%\{.*\}%%\s*$/.test(line);
|
|
39
|
+
}
|
|
40
|
+
function splitSource(source) {
|
|
41
|
+
const eol = source.includes("\r\n") ? "\r\n" : "\n";
|
|
42
|
+
const rawLines = source.split(/\r\n|\n/);
|
|
43
|
+
let end = rawLines.length;
|
|
44
|
+
while (end > 0 && rawLines[end - 1].trim() === "") end--;
|
|
45
|
+
const trailingLines = rawLines.slice(end);
|
|
46
|
+
const trailing = trailingLines.length ? eol + trailingLines.join(eol) : "";
|
|
47
|
+
const lines = rawLines.slice(0, end);
|
|
48
|
+
const preambleLines = [];
|
|
49
|
+
let i = 0;
|
|
50
|
+
let frontmatter;
|
|
51
|
+
if (lines[0] !== void 0 && /^---\s*$/.test(lines[0])) {
|
|
52
|
+
preambleLines.push(lines[0]);
|
|
53
|
+
i = 1;
|
|
54
|
+
const fm = [];
|
|
55
|
+
while (i < lines.length && !/^---\s*$/.test(lines[i])) {
|
|
56
|
+
fm.push(lines[i]);
|
|
57
|
+
preambleLines.push(lines[i]);
|
|
58
|
+
i++;
|
|
59
|
+
}
|
|
60
|
+
if (i < lines.length) {
|
|
61
|
+
preambleLines.push(lines[i]);
|
|
62
|
+
i++;
|
|
63
|
+
}
|
|
64
|
+
frontmatter = parseSimpleYaml(fm);
|
|
65
|
+
}
|
|
66
|
+
while (i < lines.length) {
|
|
67
|
+
const line = lines[i];
|
|
68
|
+
if (line.trim() === "" || isDirectiveLine(line) || isCommentLine(line)) {
|
|
69
|
+
preambleLines.push(line);
|
|
70
|
+
i++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
const headerIndex = i;
|
|
76
|
+
const header = lines[i] ?? "";
|
|
77
|
+
const bodyLines = lines.slice(i + 1);
|
|
78
|
+
return {
|
|
79
|
+
eol,
|
|
80
|
+
preamble: { lines: preambleLines, frontmatter },
|
|
81
|
+
header,
|
|
82
|
+
headerIndex,
|
|
83
|
+
bodyLines,
|
|
84
|
+
trailing
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function parseSimpleYaml(lines) {
|
|
88
|
+
const out = {};
|
|
89
|
+
let currentKey = null;
|
|
90
|
+
let nested = null;
|
|
91
|
+
for (const raw of lines) {
|
|
92
|
+
if (raw.trim() === "" || raw.trim().startsWith("#")) continue;
|
|
93
|
+
const indent = raw.length - raw.trimStart().length;
|
|
94
|
+
const m = /^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(raw.trim());
|
|
95
|
+
if (!m) continue;
|
|
96
|
+
const [, key, valueRaw] = m;
|
|
97
|
+
const value = parseYamlScalar(valueRaw);
|
|
98
|
+
if (indent === 0) {
|
|
99
|
+
currentKey = key;
|
|
100
|
+
if (valueRaw.trim() === "") {
|
|
101
|
+
nested = {};
|
|
102
|
+
out[key] = nested;
|
|
103
|
+
} else {
|
|
104
|
+
nested = null;
|
|
105
|
+
out[key] = value;
|
|
106
|
+
}
|
|
107
|
+
} else if (nested && currentKey) {
|
|
108
|
+
nested[key] = value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
function parseYamlScalar(v) {
|
|
114
|
+
const t = v.trim();
|
|
115
|
+
if (t === "") return "";
|
|
116
|
+
if (t.startsWith("{") || t.startsWith("[")) {
|
|
117
|
+
try {
|
|
118
|
+
return JSON.parse(t);
|
|
119
|
+
} catch {
|
|
120
|
+
return t;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (/^(true|false)$/i.test(t)) return t.toLowerCase() === "true";
|
|
124
|
+
if (/^-?\d+(\.\d+)?$/.test(t)) return Number(t);
|
|
125
|
+
if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")) {
|
|
126
|
+
return t.slice(1, -1);
|
|
127
|
+
}
|
|
128
|
+
return t;
|
|
129
|
+
}
|
|
130
|
+
function splitStatements(line) {
|
|
131
|
+
const parts = [];
|
|
132
|
+
let depth = 0;
|
|
133
|
+
let quote = null;
|
|
134
|
+
let cur = "";
|
|
135
|
+
for (let i = 0; i < line.length; i++) {
|
|
136
|
+
const ch = line[i];
|
|
137
|
+
if (quote) {
|
|
138
|
+
cur += ch;
|
|
139
|
+
if (ch === quote) quote = null;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (ch === '"' || ch === "`") {
|
|
143
|
+
quote = ch;
|
|
144
|
+
cur += ch;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (ch === "[" || ch === "(" || ch === "{") depth++;
|
|
148
|
+
else if (ch === "]" || ch === ")" || ch === "}") depth = Math.max(0, depth - 1);
|
|
149
|
+
if (ch === ";" && depth === 0) {
|
|
150
|
+
parts.push(cur);
|
|
151
|
+
cur = "";
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
cur += ch;
|
|
155
|
+
}
|
|
156
|
+
parts.push(cur);
|
|
157
|
+
return parts;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
detectFamilyFromHeader,
|
|
162
|
+
splitSource,
|
|
163
|
+
splitStatements
|
|
164
|
+
};
|