Repository navigation
·
19 commits
to master
since this release
Immutable
release. Only release title and notes can be modified.
D2 adds annotations, animated scenarios, connection icons, linked-layer zooms, video export, sequence diagrams v2, TALA hierarchy layouts, image shape fitting, composite primary keys, source validation warnings, and hyphenated shape and SQL constraint names.
Features 🚀
- Annotations. Draw marks (
circle,box,underline,brace,cross,highlight,arrow,trace, orlasso) and Markdown notes over a shape or connection without changing its layout. Rootannotationdraws a board caption whose Markdown links cue shapes in caption order. Customize colors withannotation.style.strokeandannotation.style.font-color. Annotation guide
Edit the annotation gallery in Playground
- Animated scenarios and connection icons. Set
animate-intervalandanimate-durationto tween directly between independentscenarios, and seticon.style.animated(e.g.2/sor200ms) withicon.shape(circle,square,triangle,diamond, or aniconimage) to send traffic along connections. When an Atlas subscriber goes down, 120 events pile up; replay clears the backlog while live delivery resumes. Animation guide · Order-outbox example
Edit Atlas delivery in Playground
- Linked-layer zoom. Animated SVG and GIF tours zoom through linked shapes as they enter or leave a layer, pause on a shared parent between sibling layers, and return to ancestors in one continuous pullback. Open the Atlas SVG and select Replay Worker to follow a delivery checkpoint down to the consumer’s inbox; clicking linked shapes in standalone SVG or D2.js explores the destination directly.
Edit the Atlas replay tour in Playground
- Video export. Export 60 fps motion as H.264 MP4 (
tour.mp4) or VP9 WebM (tour.webm) with FFmpeg 5.1 or newer. Configure dimensions, quality, and clip length with--video-size,--video-quality(low,medium,high,best), and--video-duration. Exports · Atlas MP4 · Atlas WebM - Motion review. Use
d2 storyboardto put timestamped frames from every board into one PNG, andd2 lint --motionto report crowded transitions, short-lived labels, hidden caption targets, and possible shape ID replacements. Both are available through MCP asstoryboardandlint_motion. Atlas storyboard · Motion review - Sequence diagrams v2. Use
shape: sequence-diagramfor explicit participant and message groups (actor-group,edge-group), branched frames (shape.branched), shared rows, activation labels, repeated headers (shape.mirrored,shape: sequence-diagram-checkpoint), numbered messages (shape.numbered), participant timeline notes (shape: page), and message annotations. Existingshape: sequence_diagramdiagrams keep their original layout and emit a deprecation warning ahead of D2 1.0. Guide and example · #2662 - TALA hierarchies. Branches and joins leave more room near box corners, grouped handoffs form aligned columns, parallel branches take symmetric routes, and TALA compares finished routes when choosing between compact placements. TALA · #3150
- Source validation warnings.
d2 validatepoints out explicit settings that D2 ignores and syntax that can draw a different diagram than intended, with rule codes and source locations. Use--max-warnings 0in CI,--jsonfor structured diagnostics, and--warn unmatched-globor--warn overwritten-stylefor optional checks. Available in the CLI, language server (d2 lsp), MCP (check), Go (d2compiler.Validate), and D2.js (d2.validate()). #3147 - Image shapes. Configure image sources and fitting under
shape: image { src: ./photo.png; fit: cover; position: center-right }.shape.fitsupportscontain,cover,fill,none, andscale-down, andshape.positionaccepts named anchors. Existingiconsources continue to work,icon.style.border-radiusrounds image corners (including through mixin classes), andshape.src: nullclears an inherited source. Icons · #3149 · #3175 - Composite primary keys. Declare multi-column SQL table primary keys with
shape: sql-table { primary-key: [tenant_id; project_id] }. Adjacent columns in key order share onePKlabel, while separated or reordered columns show numberedPKlabels. Useshape.primary-key: []to clear an inherited key. The language server updates composite key members when renaming columns. Example · #3148
Improvements 🧹
- Config theme keys. Use
vars.d2-config.themeandvars.d2-config.dark-theme(accepting either theme names or numeric IDs, matching--themeand--dark-theme).theme-idanddark-theme-idremain accepted as aliases and emit deprecation warnings ahead of D2 1.0. #3179 - Hyphenated shape and SQL constraint names. Use
sql-table,stored-data,primary-key, andforeign-keyto match D2’s hyphenated naming convention. The underscore spellings (sql_table,stored_data,primary_key,foreign_key) remain accepted as aliases and emit deprecation warnings ahead of D2 1.0. #3174 - 60 fps easing, playback progress, and reduced motion. Step tweens target 60 fps with cubic ease-in-out on display refresh, subpixel TALA pin movement, and cubic-bezier compression for uniform grid transitions. Timed exports show a faint playback track with gaps at board changes and a background-contrasting fill (
animate-progress,animate-progress-color). Reduced-motion SVGs open on a still board and keep click navigation. Animation · #3114 · #3135 · #3136 · #3139 · #3161 - Smaller SVG exports and WOFF2 fonts. Across 157 documentation diagrams, SVG output is 28.4% smaller raw and 35.1% smaller gzipped. D2 embeds smaller WOFF2 bundled and appendix fonts (retaining kerning, ligatures, and hinting) alongside more compact stylesheets, code blocks, arrowhead references, textures, sketch paths, and LaTeX glyphs. SVG benchmark · #3099 · #3101
- Smaller release archives. Compressing release archives with
libdeflateshrank the six CLI archives by about 0.8–0.9 MB each. #3142 · #3144 - Editor, LSP, and MCP. Added language server completions and hover docs for gradient colors and composite shape options (
shape.{src,fit,position,primary-key,numbered,mirrored,branched}), synced the MCP guide andd2(1)man page with new flags and config keys, and alignedd2oracle.Deletewithshapekeywords. #3118 · #3170
Bugfixes ⛑️
- Sketch mode. Sketched rectangles (including double-bordered shapes) with
style.border-radiusnow draw rounded corners in SVG as well as PNG, GIF, and video exports. #1098 · #3168 · #3172 - Shared strokes and SVG rendering. Touching shape borders, shared connection segments, and coincident class or SQL table dividers draw at single-stroke weight in static diagrams. Labels that mention fill pattern class names such as
paper-overlayno longer embed unused textures. Honored code font colors and whole-label text gradients, sanitized illegal XML 1.0 control characters in code blocks and legends, smoothed animated crossing gaps on large diagrams, fixed missing legend connections in Firefox, and preserved SVG fill patterns after dark-mode CSS in Apple ImageIO. #3126 · #3091 · #3089 · #3100 · #3131 · #3158 - Annotations and captions. Enabled Markdown links in annotations and made caption cue resolution Markdown-aware. Included 3D/multiple extrusions and leaving captions in annotation bounds, preserved layer zooms and independent viewports on annotated layers, and rejected unsupported HTML in annotations during validation and compilation. #3152 · #3153 · #3156 · #3162 · #3163
- Compiler, links, and validation. Unquoted HTTP and HTTPS links preserve URL
#fragments(put a space before#for a trailing comment). Relative file links are preserved and unresolved board links are reported without leakingroot.into unlabeled edge labels. Spreading anulledge attribute clears it while keeping the connection. Changing a compositeshape(imageorsql-table) to another shape type clears prior shape options.d2 validatevalidatesvars.d2-legendimage sources, rejects unknown--layoutengines, and no longer emits falseoverwritten-stylewarnings on distinct unindexed parallel edges. #3130 · #3146 · #3157 · #3160 · #3166 · #3169 · #3173 - Animations, video, and GIF. Raised the GIF total frame area ceiling from 160 to 256 Mi-pixels, stored opaque delta rectangles, and preserved long still holds without duplicate frames. Video and PNG exports now stage non-regular destinations such as
/dev/nullsafely without renaming special files. Animated SVG icons render their base state in raster exports (svgposterandd2svgimportfixes). Fixedd2 lint --motionsubpixel start detection, skipped unnecessary camera zoom filters whenanimate-duration: 0, canonicalized duplicate mask/marker IDs in native motion, and fixed negative-zero tween labels, gradient stop padding/tweens, and TALA arrival + paint composition. #3116 · #3117 · #3121 · #3127 · #3129 · #3132 · #3141 · #3151 · #3154 · #3155 · #3159 · #3164 · #3165 · #3167 - Installer. Avoided false Homebrew installer shadow warnings. #3090
Breaking Changes
- Compiled
d2targetdiagrams and JSON use hyphenated names. Compiledd2targetoutput and JSON now emitsql-table,stored-data,primary-key, andforeign-keyinstead of underscore spellings. D2 source still acceptssql_table,stored_data,primary_key, andforeign_keywith deprecation warnings ahead of D2 1.0. #3174 annotationis now a reserved keyword. Quote any existing shape literally named"annotation". #3085- CSS degree gradient angles. Degree gradients now start at the opposite edge and measure clockwise from up, matching CSS. #3123
- Playback progress bar and animation timing. Timed animations reserve space for a playback progress bar by default; opt out with
vars.d2-config.animate-progress: falseor--animate-progress=false. Composed tours takeanimate-intervalfrom the entry diagram; move board-localanimate-intervalvalues to the entry diagram. #3108 · #3119 - Stricter
d2 validate.d2 validatenow compiles diagrams and imports, validatesvars.d2-legendimage sources and annotation HTML, and rejects unknown--layoutengines. #3133 · #3160 - WOFF2 bundled fonts. Bundled SVG font subsets now embed as WOFF2 instead of WOFF/TTF. #3099
D2.js 0.3.0
The @d2lang/d2 package (and @terrastruct/d2 compatibility package) bumps to 0.3.0 for browsers and Node.js. #3176 · #3178
- Validation API.
d2.validate()checks D2 source and virtual imports in Node.js and browsers with the same default and optional warnings (unmatched-glob,overwritten-style) asd2 validate. - Animation and playback.
RenderOptionsaddsanimateProgressandanimateProgressColor. Standalone SVGs support linked-layer click navigation, 60 fps eased transitions, animated scenarios, connection icons, and annotations. - Shapes and TypeScript. Includes sequence diagrams v2, image shape fitting (
imageFit,imagePosition,iconBorderRadius), composite primary keys, and hyphenatedd2targetshape and constraint names.index.d.tsaddsd2.validate(),d2.version(),d2.jsVersion(), and missing shape and config fields (Diagram.config.{layoutEngine,data},ShapeBase.{iconBorderRadius,imageFit,imagePosition}). - WebAssembly size. Bundles all three layout engines plus sequence v2, annotations, and validation in 11.59 MB uncompressed and 3.94 MB Brotli inside the browser module.