Skip to content

Commit 8762d9d

Browse files
authored
Merge branch 'master' into master
2 parents a75f4cf + 5f95c54 commit 8762d9d

File tree

1,649 files changed

+330817
-100128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,649 files changed

+330817
-100128
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
env:
1818
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
1919
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
20-
- uses: actions/upload-artifact@v3
20+
- uses: actions/upload-artifact@v4
2121
if: always()
2222
with:
2323
name: d2chaos

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ d2renderers/d2latex/polyfills.js
55
d2renderers/d2latex/setup.js
66
d2renderers/d2sketch/rough.js
77
lib/png/generate_png.js
8+
d2js

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.POSIX:
22

33
.PHONY: all
4-
all: fmt gen lint build test
4+
all: fmt gen js lint build test
55

66
.PHONY: fmt
77
fmt:
@@ -21,3 +21,6 @@ test: fmt
2121
.PHONY: race
2222
race: fmt
2323
prefix "$@" ./ci/test.sh --race ./...
24+
.PHONY: js
25+
js: gen
26+
cd d2js/js && prefix "$@" ./make.sh all

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ let us know and we'll be happy to include it here!
238238

239239
### Community plugins
240240

241-
- **Tree-sitter grammar**: [https://git.pleshevski.ru/pleshevskiy/tree-sitter-d2](https://git.pleshevski.ru/pleshevskiy/tree-sitter-d2)
241+
- **Tree-sitter grammar**: [https://github.com/ravsii/tree-sitter-d2](https://github.com/ravsii/tree-sitter-d2)
242242
- **Emacs major mode**: [https://github.com/andorsk/d2-mode](https://github.com/andorsk/d2-mode)
243243
- **Goldmark extension**: [https://github.com/FurqanSoftware/goldmark-d2](https://github.com/FurqanSoftware/goldmark-d2)
244244
- **Telegram bot**: [https://github.com/meinside/telegram-d2-bot](https://github.com/meinside/telegram-d2-bot)
@@ -262,6 +262,7 @@ let us know and we'll be happy to include it here!
262262
- **MkDocs Plugin**: [https://github.com/landmaj/mkdocs-d2-plugin](https://github.com/landmaj/mkdocs-d2-plugin)
263263
- **Remark Plugin**: [https://github.com/mech-a/remark-d2](https://github.com/mech-a/remark-d2)
264264
- **VitePress Plugin**: [https://github.com/BadgerHobbs/vitepress-plugin-d2](https://github.com/BadgerHobbs/vitepress-plugin-d2)
265+
- **Zed extension**: [https://github.com/gabeidx/zed-d2](https://github.com/gabeidx/zed-d2)
265266

266267
### Misc
267268

@@ -292,6 +293,12 @@ Do you have or see an open-source project with `.d2` files? Please submit a PR a
292293
this selected list of featured projects using D2.
293294

294295
- [ElasticSearch](https://github.com/elastic/beats/blob/main/libbeat/publisher/queue/proxy/diagrams/broker.d2)
296+
- [Sourcegraph](https://handbook.sourcegraph.com/departments/engineering/managed-services/telemetry-gateway/#dev-architecture-diagram)
297+
- [Temporal](https://github.com/temporalio/temporal/blob/0be2681c994470c7c61ea88e4fcef89bb4024e58/docs/_assets/matching-context.d2)
298+
- [Tauri](https://v2.tauri.app/concept/inter-process-communication/)
299+
- Rust GUI framework (78.5k stars)
300+
- [Intellij](https://github.com/JetBrains/intellij-community/blob/45bcfc17a3f3e0d8548bc69e922d4ca97ac21b2b/platform/settings/docs/topics/overview.md)
301+
- [Coder](https://coder.com/blog/managing-templates-in-coder)
295302
- [UC
296303
Berkeley](https://github.com/ucb-bar/hammer/blob/2b5c04d7b7d9ee3c73575efcd7ee0698bd5bfa88/doc/Hammer-Use/hier.d2)
297304
- [Coronacheck](https://github.com/minvws/nl-covid19-coronacheck-app-ios/blob/e1567e9d1633b3273c537a105bff0e7d3a57ecfe/Diagrams/client-side-datamodel.d2)

ci/peek-wasm-size.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
OUTPUT_FILE="main.wasm"
4+
SOURCE_PACKAGE="./d2js"
5+
6+
echo "Building WASM file..."
7+
GOOS=js GOARCH=wasm go build -ldflags='-s -w' -trimpath -o "$OUTPUT_FILE" "$SOURCE_PACKAGE"
8+
9+
if [ $? -eq 0 ]; then
10+
echo "Build successful."
11+
12+
if [ -f "$OUTPUT_FILE" ]; then
13+
FILE_SIZE_BYTES=$(stat -f%z "$OUTPUT_FILE")
14+
FILE_SIZE_MB=$(echo "scale=2; $FILE_SIZE_BYTES / 1024 / 1024" | bc)
15+
16+
echo "File size of $OUTPUT_FILE: $FILE_SIZE_MB MB"
17+
else
18+
echo "File $OUTPUT_FILE not found!"
19+
exit 1
20+
fi
21+
22+
echo "Deleting $OUTPUT_FILE..."
23+
rm "$OUTPUT_FILE"
24+
echo "File deleted."
25+
else
26+
echo "Build failed."
27+
exit 1
28+
fi

ci/release/build.sh

+3-88
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cd -- "$(dirname "$0")/../.."
1010

1111
help() {
1212
cat <<EOF
13-
usage: $0 [--rebuild] [--local] [--dry-run] [--run=regex] [--host-only] [--lockfile-force]
13+
usage: $0 [--rebuild] [--dry-run] [--run=regex] [--host-only] [--lockfile-force]
1414
[--install] [--uninstall]
1515
1616
$0 builds D2 release archives into ./ci/release/build/<version>/d2-<VERSION>-<OS>-<ARCH>.tar.gz
@@ -24,14 +24,6 @@ Flags:
2424
By default build.sh will avoid rebuilding finished assets if they already exist but if you
2525
changed something and need to force rebuild, use this flag.
2626
27-
--local
28-
By default build.sh uses \$CI_D2_LINUX_AMD64, \$CI_D2_LINUX_ARM64,
29-
\$CI_D2_MACOS_AMD64 and \$CI_D2_MACOS_ARM64 to build the release
30-
archives. It's required for now due to the following issue:
31-
https://github.com/terrastruct/d2/issues/31
32-
With --local, build.sh will cross compile locally. warning: This is only for testing
33-
purposes, do not use in production!
34-
3527
--host-only
3628
Use to build the release archive for the host OS-ARCH only. All logging is done to stderr
3729
so in a script you can read from stdout to get the path to the release archive.
@@ -75,10 +67,6 @@ main() {
7567
flag_noarg && shift "$FLAGSHIFT"
7668
REBUILD=1
7769
;;
78-
local)
79-
flag_noarg && shift "$FLAGSHIFT"
80-
LOCAL=1
81-
;;
8270
dry-run)
8371
flag_noarg && shift "$FLAGSHIFT"
8472
DRY_RUN=1
@@ -90,7 +78,6 @@ main() {
9078
host-only)
9179
flag_noarg && shift "$FLAGSHIFT"
9280
HOST_ONLY=1
93-
LOCAL=1
9481
;;
9582
version)
9683
flag_nonemptyarg && shift "$FLAGSHIFT"
@@ -104,13 +91,11 @@ main() {
10491
flag_noarg && shift "$FLAGSHIFT"
10592
INSTALL=1
10693
HOST_ONLY=1
107-
LOCAL=1
10894
;;
10995
uninstall)
11096
flag_noarg && shift "$FLAGSHIFT"
11197
UNINSTALL=1
11298
HOST_ONLY=1
113-
LOCAL=1
11499
;;
115100
push-docker)
116101
flag_noarg && shift "$FLAGSHIFT"
@@ -170,45 +155,8 @@ build() {
170155
return 0
171156
fi
172157

173-
if [ -n "${LOCAL-}" ]; then
174-
build_local
175-
return 0
176-
fi
177-
178-
case $OS in
179-
macos)
180-
case $ARCH in
181-
amd64)
182-
REMOTE_HOST=$CI_D2_MACOS_AMD64 build_remote_macos
183-
;;
184-
arm64)
185-
REMOTE_HOST=$CI_D2_MACOS_ARM64 build_remote_macos
186-
;;
187-
*)
188-
warn "no builder for OS=$OS ARCH=$ARCH, building locally..."
189-
build_local
190-
;;
191-
esac
192-
;;
193-
linux)
194-
case $ARCH in
195-
amd64)
196-
REMOTE_HOST=$CI_D2_LINUX_AMD64 build_remote_linux
197-
;;
198-
arm64)
199-
REMOTE_HOST=$CI_D2_LINUX_ARM64 build_remote_linux
200-
;;
201-
*)
202-
warn "no builder for OS=$OS ARCH=$ARCH, building locally..."
203-
build_local
204-
;;
205-
esac
206-
;;
207-
*)
208-
warn "no builder for OS=$OS, building locally..."
209-
build_local
210-
;;
211-
esac
158+
build_local
159+
return 0
212160
}
213161

214162
build_local() {
@@ -221,39 +169,6 @@ build_local() {
221169
sh_c ./ci/release/_build.sh
222170
}
223171

224-
build_remote_macos() {(
225-
sh_c lockfile_ssh "$REMOTE_HOST" .d2-build-lock
226-
sh_c gitsync "$REMOTE_HOST" src/d2
227-
sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \
228-
TERM=${TERM-} \
229-
DRY_RUN=${DRY_RUN-} \
230-
HW_BUILD_DIR=$HW_BUILD_DIR \
231-
VERSION=$VERSION \
232-
OS=$OS \
233-
ARCH=$ARCH \
234-
ARCHIVE=$ARCHIVE \
235-
PATH=\\\"/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin\\\${PATH+:\\\$PATH}\\\" \
236-
./src/d2/ci/release/_build.sh"
237-
sh_c mkdir -p "$HW_BUILD_DIR"
238-
sh_c rsync --archive --human-readable "$REMOTE_HOST:src/d2/$ARCHIVE" "$ARCHIVE"
239-
)}
240-
241-
build_remote_linux() {(
242-
sh_c lockfile_ssh "$REMOTE_HOST" .d2-build-lock
243-
sh_c gitsync "$REMOTE_HOST" src/d2
244-
sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \
245-
TERM=${TERM-} \
246-
DRY_RUN=${DRY_RUN-} \
247-
HW_BUILD_DIR=$HW_BUILD_DIR \
248-
VERSION=$VERSION \
249-
OS=$OS \
250-
ARCH=$ARCH \
251-
ARCHIVE=$ARCHIVE \
252-
./src/d2/ci/release/build_in_docker.sh"
253-
sh_c mkdir -p "$HW_BUILD_DIR"
254-
sh_c rsync --archive --human-readable "$REMOTE_HOST:src/d2/$ARCHIVE" "$ARCHIVE"
255-
)}
256-
257172
build_docker() {
258173
if [ -n "${LOCAL-}" ]; then
259174
sh_c ./ci/release/docker/build.sh \

ci/release/changelogs/next.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
Hotfix for 0.6.4 breaking plugins, along with 2 other compiler bugfixes.
1+
#### Features 🚀
2+
3+
- Animations: `style.animated: true` is supported on shapes [#2250](https://github.com/terrastruct/d2/pull/2250)
4+
- Connections now support `link` [#1955](https://github.com/terrastruct/d2/pull/1955)
5+
- Vars: vars in markdown blocks are substituted [#2218](https://github.com/terrastruct/d2/pull/2218)
6+
- Markdown: Github-flavored tables work in `md` blocks [#2221](https://github.com/terrastruct/d2/pull/2221)
7+
- Render: adds box arrowheads [#2227](https://github.com/terrastruct/d2/issues/2227)
8+
- `d2 fmt` now supports a `--check` flag [#2253](https://github.com/terrastruct/d2/pull/2253)
9+
- CLI: PNG output to stdout is supported using `--stdout-format png -` [#2291](https://github.com/terrastruct/d2/pull/2291)
10+
- Globs: `&connected` and `&leaf` filters are implemented [#2299](https://github.com/terrastruct/d2/pull/2299)
11+
- CLI: add --no-xml-tag for direct HTML embedding [#2302](https://github.com/terrastruct/d2/pull/2302)
12+
- CLI: `play` cmd added for opening d2 input in online playground [#2242](https://github.com/terrastruct/d2/pull/2242)
13+
14+
#### Improvements 🧹
15+
16+
- Composition: links pointing to own board are purged [#2203](https://github.com/terrastruct/d2/pull/2203)
17+
- Syntax: reserved keywords must be unquoted [#2231](https://github.com/terrastruct/d2/pull/2231)
18+
- Latex: Backslashes in Latex blocks do not escape [#2232](https://github.com/terrastruct/d2/pull/2232)
19+
- This is a breaking change. Previously Latex blocks required escaping the backslash. So
20+
for older D2 versions, you should remove the excess backslashes.
21+
- Links: non-http url scheme links are supported (e.g. `x.link: vscode://file/`) [#2237](https://github.com/terrastruct/d2/issues/2237)
22+
- Compiler: reserved keywords with missing values error instead of silently doing nothing [#2251](https://github.com/terrastruct/d2/pull/2251)
23+
- Render: SVG outputs conform to stricter HTML standards, e.g. no duplicate ids [#2273](https://github.com/terrastruct/d2/issues/2273)
24+
- Themes: theme names are consistently cased [#2322](https://github.com/terrastruct/d2/pull/2322)
25+
- Nears: constant nears avoid collision with edge routes [#2327](https://github.com/terrastruct/d2/pull/2327)
226

327
#### Bugfixes ⛑️
28+
29+
- Imports: fixes using substitutions in `icon` values [#2207](https://github.com/terrastruct/d2/pull/2207)
30+
- Markdown: fixes ampersands in URLs in markdown [#2219](https://github.com/terrastruct/d2/pull/2219)
31+
- Globs: fixes edge case where globs with imported boards would create empty boards [#2247](https://github.com/terrastruct/d2/pull/2247)
32+
- Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264)
33+
- Null: fixes `null`ing a connection with absolute syntax [#2318](https://github.com/terrastruct/d2/issues/2318)
34+
- Gradients: works with connection fills [#2326](https://github.com/terrastruct/d2/pull/2326)
35+
- Latex: fixes backslashes doubling on successive parses [#2328](https://github.com/terrastruct/d2/pull/2328)

ci/release/changelogs/v0.6.6.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#### Features 🚀
2+
3+
- Glob inverse filters are implemented (e.g. `*: {!&shape: circle; style.fill: red}` to turn all non-circles red) [#2008](https://github.com/terrastruct/d2/pull/2008)
4+
- Globs can be used in glob filter values, including checking for existence (e.g. `*: {&link: *; style.fill: red}` to turn all objects with a link red) [#2009](https://github.com/terrastruct/d2/pull/2009)
5+
6+
#### Improvements 🧹
7+
8+
- Opacity 0 shapes no longer have a label mask which made any segment of connections going through them lower opacity [#1940](https://github.com/terrastruct/d2/pull/1940)
9+
- Bidirectional connections are now animated in opposite directions rather than one direction [#1939](https://github.com/terrastruct/d2/pull/1939)
10+
11+
#### Bugfixes ⛑️
12+
13+
- Local relative icons are relative to the d2 file instead of CLI invoke path [#1924](https://github.com/terrastruct/d2/pull/1924)
14+
- Custom label positions weren't being read when the width was smaller than the label [#1928](https://github.com/terrastruct/d2/pull/1928)
15+
- Using `shape: circle` for arrowheads no longer removes all arrowheads along path in sketch mode [#1942](https://github.com/terrastruct/d2/pull/1942)
16+
- Globs to null connections work [#1965](https://github.com/terrastruct/d2/pull/1965)
17+
- Edge globs setting styles inherit correctly in child boards [#1967](https://github.com/terrastruct/d2/pull/1967)
18+
- Board links imported with spread imports work [#1972](https://github.com/terrastruct/d2/pull/1972)
19+
- Fix importing a file with nested boards [#1998](https://github.com/terrastruct/d2/pull/1998)
20+
- Fix importing a file with underscores in links [#1999](https://github.com/terrastruct/d2/pull/1999)
21+
- Replace a panic with an error message resulting from invalid `link` usage [#2011](https://github.com/terrastruct/d2/pull/2011)
22+
- Fix globs not applying to scenarios on keys that were applied in earlier scenarios [#2021](https://github.com/terrastruct/d2/pull/2021)
23+
- Fix edge case of invalid SVG from code blocks [#2031](https://github.com/terrastruct/d2/pull/2031)

ci/release/changelogs/v0.6.7.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#### Features 🚀
2+
3+
- Vars: Variable definitions can refer to other variables in the current scope [#2052](https://github.com/terrastruct/d2/pull/2052)
4+
- Composition: Imported boards can use underscores to reference boards beyond its own scope (e.g. to a sibling board at the scope its imported to) [#2075](https://github.com/terrastruct/d2/pull/2075)
5+
- Autoformat: Reserved keywords are formatted to be lowercase [#2098](https://github.com/terrastruct/d2/pull/2098)
6+
- Misc: support for characters in the Latin-1 and geometric shapes unicode range [#2100](https://github.com/terrastruct/d2/pull/2100)
7+
- Imports: can now import from absolute file paths [#2113](https://github.com/terrastruct/d2/pull/2113)
8+
- Render: linear and radial gradients are now available for `fill`, `stroke` and `font-color` [#2120](https://github.com/terrastruct/d2/pull/2120)
9+
10+
#### Improvements 🧹
11+
12+
- Sequence diagram: edge groups account for edge label heights [#2038](https://github.com/terrastruct/d2/pull/2038)
13+
- Sequence diagram: self-referential edges account for edge label heights [#2040](https://github.com/terrastruct/d2/pull/2040)
14+
- Sequence diagram: The spacing between self-referential edges and regular edges is uniform [#2043](https://github.com/terrastruct/d2/pull/2043)
15+
- Compiler: Error on multi-line labels in `sql_table` shapes [#2057](https://github.com/terrastruct/d2/pull/2057)
16+
- Sequence diagram: Image shape actors can use spans and notes [#2056](https://github.com/terrastruct/d2/issues/2056)
17+
- Globs: Filters work with default values (e.g. `&opacity: 1` will capture everything without opacity explicitly set) [#2090](https://github.com/terrastruct/d2/pull/2090)
18+
- Render: connection label fills have a bit of padding and border-radius for better aesthetics [#2094](https://github.com/terrastruct/d2/pull/2094)
19+
- Sequence diagram: the padding between message labels and message endpoints are slightly increased [#2096](https://github.com/terrastruct/d2/pull/2096)
20+
- Render: code syntax highlighter dependency upgrade caused some slight subtle color changes in code snippets [#2119](https://github.com/terrastruct/d2/pull/2119)
21+
22+
23+
#### Bugfixes ⛑️
24+
25+
- Sequence diagram: multi-line edge labels no longer can collide with other elements [#2049](https://github.com/terrastruct/d2/pull/2049)
26+
- Sequence diagram: long self-referential edge labels no longer can collide neighboring actors (or its own) lifeline edges [#2050](https://github.com/terrastruct/d2/pull/2050)
27+
- Sequence diagram: fixes layout when sequence diagrams are in children boards (e.g. a layer) [#1692](https://github.com/terrastruct/d2/issues/1692)
28+
- Globs: An edge case was fixed where globs used in edges were creating nodes when it shouldn't have [#2051](https://github.com/terrastruct/d2/pull/2051)
29+
- Render: Multi-line class labels/headers are rendered correctly [#2057](https://github.com/terrastruct/d2/pull/2057)
30+
- CLI: Watch mode uses correct backlinks (`_` usages) [#2058](https://github.com/terrastruct/d2/pull/2058)
31+
- Vars: Spread variables are inserted in place instead of appending to end of scope [#2062](https://github.com/terrastruct/d2/pull/2062)
32+
- Imports: fix local icon imports from files that are imported [#2066](https://github.com/terrastruct/d2/pull/2066)
33+
- CLI: fixes edge case of watch mode links to nested board that had more nested boards not working [#2070](https://github.com/terrastruct/d2/pull/2070)
34+
- CLI: fixes theme flag not being passed to GIF outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
35+
- CLI: fixes scale flag not being passed to animated SVG outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
36+
- CLI: pptx exports use theme flags correctly [#2099](https://github.com/terrastruct/d2/pull/2099)
37+
- Imports: importing files with url links is fixed [#2105](https://github.com/terrastruct/d2/pull/2105)
38+
- Composition: linking to invalid boards no longer produces an invalid link [#2118](https://github.com/terrastruct/d2/pull/2118)

ci/release/changelogs/v0.6.8.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#### Features 🚀
2+
3+
- Render: SVG files render in non-browser contexts (e.g. Inkscape, LaTeX) [#2147](https://github.com/terrastruct/d2/pull/2147)
4+
5+
#### Improvements 🧹
6+
7+
- Lib: removes a dependency on external slog that was causing troubles with installation [#2137](https://github.com/terrastruct/d2/pull/2137)
8+
- CLI: attempts writing to path atomically, falling back to non-atomic if failed [#2141](https://github.com/terrastruct/d2/pull/2141)
9+
- Export: pptx has "created at" metadata removed, so successive runs yield the same result [#2169](https://github.com/terrastruct/d2/pull/2160)
10+
- Formatter: empty board keywords (e.g. `layers`) are removed [#2178](https://github.com/terrastruct/d2/pull/2178)
11+
- Render: a tooltip or link by itself will not expand width of shape [#2183](https://github.com/terrastruct/d2/pull/2183)
12+
13+
#### Bugfixes ⛑️
14+
15+
- Render: fixes edge case of a 3d shape with outside label being cut off [#2132](https://github.com/terrastruct/d2/pull/2132)
16+
- Composition: labels for boards set with shorthand `x: y` was not applied [#2182](https://github.com/terrastruct/d2/pull/2182)
17+
- Globs: double globs (`**`) were erroring when used with multiple scenario boards [#2195](https://github.com/terrastruct/d2/pull/2195)

ci/release/docker/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ ARG TARGETARCH
55

66
RUN apt-get update && apt-get install -y ca-certificates curl dumb-init sudo
77

8-
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash -s - && \
8+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -s - && \
99
apt-get install -y nodejs
10-
RUN npx playwright@1.31.1 install --with-deps chromium
10+
RUN npx playwright@1.45.3 install --with-deps chromium
1111

1212
RUN adduser --gecos '' --disabled-password debian \
1313
&& echo "debian ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd

0 commit comments

Comments
 (0)