Skip to content

Fix d2.js startup in Safari workers with Goldmark v2 - #2965

Merged
alixander merged 3 commits into
masterfrom
fix/safari-d2js-startup
Nov 19, 2026
Merged

alixander merged 3 commits into
masterfrom
fix/safari-d2js-startup

Conversation

@alixander

@alixander alixander commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Human


AI

Fixes #2956. Thanks to @nelsonjchen for tracing the Safari worker crash to Goldmark's URL regexes in #2960.

Upgrade to Goldmark v2.1.16, which scans URLs without compiling those regexes during startup. D2 continues to use the upstream table and strikethrough extensions. The browser and Node workers now wait for Go to export the D2 API. If Go exits or throws first, D2.ready rejects with the startup error.

One Markdown edge case changes. A list item followed by a -- line, a blank line, and another paragraph now stays a list. The previous version rendered the item as a table.

The Goldmark upgrade pushed the Intel macOS binary over the 45 MB release limit. Native builds now reuse the SVG font data for six faces whose data URIs already contain the original TTF. All 12 registered font faces and SVG encodings match master byte for byte, including the two style aliases. The resulting Intel macOS binary is 44,170,064 bytes, down from 44,973,600 on master (7d48324).

Verification

  • The built browser package compiled, rendered, encoded, and decoded a Markdown diagram with a table and strikethrough in both Safari 27.2's WebKit engine and Chrome. In WebKit, pairing the new worker with the WASM from master surfaced the original stack overflow through D2.ready.
  • The two new startup tests fail against the published @d2lang/[email protected] and pass against this branch. The JavaScript type checks, unit tests, and installed-package integration tests passed.
  • D2's end-to-end, renderer, text-measurement, compiler, library, and Go WASM tests passed. All 652 CommonMark examples produced byte-identical HTML to the baseline.

The Playground can pick up the change in the next d2.js release. See d2lang/d2-playground#113.

  • sent from alixander's Codex

Use Goldmark's v2 parser and renderer for Markdown. Wait for Go to export
the D2 API before reporting worker readiness, and propagate startup
failures to callers.

- sent from alixander's Codex
Six native SVG font data URIs already contain the original TrueType face.
Decode those bytes into the public font registry and embed separate TTFs
only for the four WOFF encodings. All twelve face and data URI digests
match master, including the two hand-drawn style aliases.

The Intel macOS release binary falls from 45,185,936 to 44,157,776 bytes
with the Goldmark upgrade. The release limit is 45,000,000 bytes.

- sent from alixander's Codex
Include the animated appendix change and preserve both d2.js changelog entries.

- sent from alixander's Codex
@alixander
alixander merged commit 8e054d1 into master Nov 19, 2026
15 checks passed
@alixander
alixander deleted the fix/safari-d2js-startup branch November 19, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playground not working

1 participant