@markdy/core 0.8.2 → 0.8.4
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 +5 -5
- package/dist/index.d.ts +10 -0
- package/dist/index.js +72 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @markdy/core
|
|
2
2
|
|
|
3
|
-
The parser and AST types for [MarkdyScript](../../docs/SYNTAX.md) —
|
|
3
|
+
The parser and AST types for [MarkdyScript](../../docs/SYNTAX.md) — an AI-first DSL for animated architecture diagrams.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Zero runtime dependencies** — pure TypeScript, no DOM or platform APIs
|
|
8
8
|
- **Single-pass parser** — line-by-line state machine with strict `ParseError` diagnostics
|
|
9
|
-
- **
|
|
9
|
+
- **Diagram-native grammar** — scene metadata, architecture nodes, groups, styles, beats, flow chains, and reusable patterns
|
|
10
10
|
- **Isomorphic** — runs in Node.js, Deno, Bun, edge runtimes, and the browser
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
@@ -36,7 +36,7 @@ import { parse, ParseError } from "@markdy/core";
|
|
|
36
36
|
import type { DiagramAST } from "@markdy/core";
|
|
37
37
|
|
|
38
38
|
const source = `
|
|
39
|
-
scene "Request" theme=
|
|
39
|
+
scene "Request" theme=paper
|
|
40
40
|
browser Web
|
|
41
41
|
service API
|
|
42
42
|
beat main:
|
|
@@ -47,7 +47,7 @@ const source = `
|
|
|
47
47
|
try {
|
|
48
48
|
const ast: DiagramAST = parse(source);
|
|
49
49
|
|
|
50
|
-
console.log(ast.meta); // { width: 1280, height: 720, fps: 60, theme: "
|
|
50
|
+
console.log(ast.meta); // { width: 1280, height: 720, fps: 60, theme: "paper", direction: "LR", title: "Request" }
|
|
51
51
|
console.log(ast.nodes); // { Web: { kind: "browser", ... }, API: { kind: "service", ... } }
|
|
52
52
|
console.log(ast.beats); // [{ name: "main", cues: [...] }]
|
|
53
53
|
} catch (e) {
|
|
@@ -71,7 +71,7 @@ try {
|
|
|
71
71
|
| `NodeDecl` | type | Node declaration (kind, id, label, style) |
|
|
72
72
|
| `EdgeDecl` | type | Edge declaration (kind, from, to, label) |
|
|
73
73
|
| `BeatDecl` | type | Named beat with cues |
|
|
74
|
-
| `THEMES` / `resolveTheme` | tokens | Semantic theme palettes (`midnight`, `
|
|
74
|
+
| `THEMES` / `resolveTheme` | tokens | Semantic theme palettes (`paper`, `midnight`, `blueprint`, `graphite`) |
|
|
75
75
|
|
|
76
76
|
## Documentation
|
|
77
77
|
|
package/dist/index.d.ts
CHANGED
|
@@ -128,6 +128,15 @@ type ThemeTokens = {
|
|
|
128
128
|
gridMajor: string;
|
|
129
129
|
vignette: string;
|
|
130
130
|
accent: string;
|
|
131
|
+
/** Node card fill (falls back to surface derivations when omitted). */
|
|
132
|
+
nodeSurface?: string;
|
|
133
|
+
nodeSurfaceRaised?: string;
|
|
134
|
+
/** Node hairline / inset ring color. */
|
|
135
|
+
hairline?: string;
|
|
136
|
+
/** Ambient drop-shadow color (rgba). */
|
|
137
|
+
shadow?: string;
|
|
138
|
+
/** Edge label pill fill. */
|
|
139
|
+
labelPlate?: string;
|
|
131
140
|
roles: Record<string, string>;
|
|
132
141
|
edges: Record<EdgeKind, string>;
|
|
133
142
|
};
|
|
@@ -141,6 +150,7 @@ type PositionedNode = {
|
|
|
141
150
|
width: number;
|
|
142
151
|
height: number;
|
|
143
152
|
style?: Record<string, unknown>;
|
|
153
|
+
props?: Record<string, unknown>;
|
|
144
154
|
opacity: number;
|
|
145
155
|
};
|
|
146
156
|
type RoutedEdge = {
|
package/dist/index.js
CHANGED
|
@@ -381,8 +381,8 @@ function canonicalNodeKind(kind) {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
// src/compiler.ts
|
|
384
|
-
var SAFE =
|
|
385
|
-
var TITLE_BAND =
|
|
384
|
+
var SAFE = 44;
|
|
385
|
+
var TITLE_BAND = 76;
|
|
386
386
|
var NODE_W = 168;
|
|
387
387
|
var NODE_H = 72;
|
|
388
388
|
var DEFAULTS = {
|
|
@@ -498,6 +498,7 @@ function layoutNodes(ast, edges) {
|
|
|
498
498
|
width: NODE_W,
|
|
499
499
|
height: NODE_H,
|
|
500
500
|
style,
|
|
501
|
+
props: decl.props,
|
|
501
502
|
opacity: 0
|
|
502
503
|
});
|
|
503
504
|
});
|
|
@@ -660,37 +661,87 @@ var EDGE_COLORS = {
|
|
|
660
661
|
var THEMES = {
|
|
661
662
|
midnight: {
|
|
662
663
|
name: "midnight",
|
|
663
|
-
canvas: "#
|
|
664
|
-
surface: "#
|
|
665
|
-
surfaceRaised: "#
|
|
666
|
-
border: "#
|
|
664
|
+
canvas: "#070d18",
|
|
665
|
+
surface: "#0e1a2c",
|
|
666
|
+
surfaceRaised: "#152538",
|
|
667
|
+
border: "#28384f",
|
|
667
668
|
text: "#f4f7fb",
|
|
668
|
-
textMuted: "#
|
|
669
|
-
gridMinor: "rgba(148, 163, 184, 0.
|
|
670
|
-
gridMajor: "rgba(148, 163, 184, 0.
|
|
671
|
-
vignette: "rgba(2, 6, 23, 0.
|
|
669
|
+
textMuted: "#93a4bb",
|
|
670
|
+
gridMinor: "rgba(148, 163, 184, 0.10)",
|
|
671
|
+
gridMajor: "rgba(148, 163, 184, 0.16)",
|
|
672
|
+
vignette: "rgba(2, 6, 23, 0.7)",
|
|
672
673
|
accent: "#38bdf8",
|
|
674
|
+
nodeSurface: "#111f33",
|
|
675
|
+
nodeSurfaceRaised: "#1a2c44",
|
|
676
|
+
hairline: "rgba(148, 163, 184, 0.16)",
|
|
677
|
+
shadow: "rgba(2, 6, 23, 0.6)",
|
|
678
|
+
labelPlate: "#0f1c2e",
|
|
673
679
|
roles: { ...ROLE_COLORS },
|
|
674
680
|
edges: { ...EDGE_COLORS }
|
|
675
681
|
},
|
|
676
682
|
paper: {
|
|
677
683
|
name: "paper",
|
|
678
|
-
canvas: "#
|
|
684
|
+
canvas: "#f6f8fc",
|
|
679
685
|
surface: "#ffffff",
|
|
680
|
-
surfaceRaised: "#
|
|
681
|
-
border: "#
|
|
682
|
-
text: "#
|
|
683
|
-
textMuted: "#
|
|
684
|
-
gridMinor: "rgba(15, 23, 42, 0.
|
|
685
|
-
gridMajor: "rgba(15, 23, 42, 0.
|
|
686
|
-
vignette: "rgba(
|
|
687
|
-
accent: "#
|
|
686
|
+
surfaceRaised: "#f0f4f9",
|
|
687
|
+
border: "#d3dde9",
|
|
688
|
+
text: "#0f1c2e",
|
|
689
|
+
textMuted: "#5a6b80",
|
|
690
|
+
gridMinor: "rgba(15, 23, 42, 0.06)",
|
|
691
|
+
gridMajor: "rgba(15, 23, 42, 0.10)",
|
|
692
|
+
vignette: "rgba(226, 232, 240, 0.6)",
|
|
693
|
+
accent: "#0284c7",
|
|
694
|
+
nodeSurface: "#ffffff",
|
|
695
|
+
nodeSurfaceRaised: "#f7fafd",
|
|
696
|
+
hairline: "rgba(15, 23, 42, 0.10)",
|
|
697
|
+
shadow: "rgba(15, 23, 42, 0.14)",
|
|
698
|
+
labelPlate: "#ffffff",
|
|
699
|
+
roles: { ...ROLE_COLORS },
|
|
700
|
+
edges: { ...EDGE_COLORS }
|
|
701
|
+
},
|
|
702
|
+
blueprint: {
|
|
703
|
+
name: "blueprint",
|
|
704
|
+
canvas: "#0a1a3a",
|
|
705
|
+
surface: "#10214a",
|
|
706
|
+
surfaceRaised: "#182c5c",
|
|
707
|
+
border: "#2c477f",
|
|
708
|
+
text: "#eaf1ff",
|
|
709
|
+
textMuted: "#9fb6e0",
|
|
710
|
+
gridMinor: "rgba(125, 170, 255, 0.12)",
|
|
711
|
+
gridMajor: "rgba(125, 170, 255, 0.2)",
|
|
712
|
+
vignette: "rgba(4, 12, 34, 0.72)",
|
|
713
|
+
accent: "#5ba3ff",
|
|
714
|
+
nodeSurface: "#122452",
|
|
715
|
+
nodeSurfaceRaised: "#1b3068",
|
|
716
|
+
hairline: "rgba(125, 170, 255, 0.18)",
|
|
717
|
+
shadow: "rgba(3, 10, 30, 0.6)",
|
|
718
|
+
labelPlate: "#10214a",
|
|
719
|
+
roles: { ...ROLE_COLORS },
|
|
720
|
+
edges: { ...EDGE_COLORS }
|
|
721
|
+
},
|
|
722
|
+
graphite: {
|
|
723
|
+
name: "graphite",
|
|
724
|
+
canvas: "#111317",
|
|
725
|
+
surface: "#191c22",
|
|
726
|
+
surfaceRaised: "#22262e",
|
|
727
|
+
border: "#343a45",
|
|
728
|
+
text: "#eef1f5",
|
|
729
|
+
textMuted: "#9aa3b1",
|
|
730
|
+
gridMinor: "rgba(160, 170, 185, 0.08)",
|
|
731
|
+
gridMajor: "rgba(160, 170, 185, 0.14)",
|
|
732
|
+
vignette: "rgba(0, 0, 0, 0.6)",
|
|
733
|
+
accent: "#2dd4bf",
|
|
734
|
+
nodeSurface: "#1c2028",
|
|
735
|
+
nodeSurfaceRaised: "#262b34",
|
|
736
|
+
hairline: "rgba(160, 170, 185, 0.14)",
|
|
737
|
+
shadow: "rgba(0, 0, 0, 0.55)",
|
|
738
|
+
labelPlate: "#191c22",
|
|
688
739
|
roles: { ...ROLE_COLORS },
|
|
689
740
|
edges: { ...EDGE_COLORS }
|
|
690
741
|
}
|
|
691
742
|
};
|
|
692
743
|
function resolveTheme(name) {
|
|
693
|
-
return THEMES[name] ?? THEMES.
|
|
744
|
+
return THEMES[name] ?? THEMES.paper;
|
|
694
745
|
}
|
|
695
746
|
|
|
696
747
|
// src/parser.ts
|
|
@@ -704,15 +755,6 @@ var ParseError = class extends Error {
|
|
|
704
755
|
this.column = column;
|
|
705
756
|
}
|
|
706
757
|
};
|
|
707
|
-
var LEGACY_PATTERNS = [
|
|
708
|
-
{ re: /^\s*actor\s+/i, message: 'MarkdyScript 0.8 removed `actor` declarations. Use node kinds instead: `service API "Label"`.' },
|
|
709
|
-
{ re: /^\s*@\d/, message: "MarkdyScript 0.8 removed `@time:` events. Use `beat` blocks with flow chains and cues." },
|
|
710
|
-
{ re: /^\s*def\s+/i, message: "MarkdyScript 0.8 removed `def`. Use `pattern name(...):` for reusable flows." },
|
|
711
|
-
{ re: /^\s*seq\s+/i, message: "MarkdyScript 0.8 removed `seq`. Use `pattern` + `use` inside beats." },
|
|
712
|
-
{ re: /^\s*preset\s+/i, message: "MarkdyScript 0.8 removed presets. Use `scene` + `beat` composition." },
|
|
713
|
-
{ re: /^\s*asset\s+/i, message: "MarkdyScript 0.8 is diagram-only; `asset` declarations are not supported." },
|
|
714
|
-
{ re: /figure\s*\(/i, message: "MarkdyScript 0.8 is diagram-only; `figure` actors were removed." }
|
|
715
|
-
];
|
|
716
758
|
var FLOW_OP_RE = /(->|<-|~>|--)/;
|
|
717
759
|
var PROP_RE = /(\w[\w.-]*)=(\S+)/g;
|
|
718
760
|
function stripComment(line) {
|
|
@@ -940,20 +982,12 @@ function readIndentedBody(blocks, startIdx, parentIndent) {
|
|
|
940
982
|
}
|
|
941
983
|
function parse(source, opts = {}) {
|
|
942
984
|
const lines = source.replace(/\r\n/g, "\n").split("\n");
|
|
943
|
-
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
944
|
-
const line = stripComment(lines[i2]);
|
|
945
|
-
for (const legacy of LEGACY_PATTERNS) {
|
|
946
|
-
if (legacy.re.test(line)) {
|
|
947
|
-
throw new ParseError(legacy.message, i2 + 1);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
985
|
const diagnostics = [];
|
|
952
986
|
const meta = {
|
|
953
987
|
width: 1280,
|
|
954
988
|
height: 720,
|
|
955
989
|
fps: 60,
|
|
956
|
-
theme: "
|
|
990
|
+
theme: "paper",
|
|
957
991
|
direction: "LR"
|
|
958
992
|
};
|
|
959
993
|
const styles = {};
|
package/package.json
CHANGED