Skip to content

fix: vendor mermaid#154

Merged
yaythomas merged 1 commit into
mainfrom
fix/mermaid-csp-self-host
Apr 28, 2026
Merged

fix: vendor mermaid#154
yaythomas merged 1 commit into
mainfrom
fix/mermaid-csp-self-host

Conversation

@yaythomas
Copy link
Copy Markdown
Contributor

Description of changes:
Mermaid diagrams render as raw text on docs.aws.amazon.com because the site's Content Security Policy blocks Zensical's default load of mermaid from unpkg.com. The same pages work on localhost only because localhost has no CSP.

Switch to self-hosting the @mermaid-js/tiny UMD build, which ships as a single file with no lazy-loaded chunks and supports all diagram types currently in use (flowchart, sequence, state, class, entity-relationship).

  • Add scripts/vendor_mermaid.py, which reads version and expected sha256 from scripts/vendor_mermaid.toml, downloads the pinned tiny build from cdn.jsdelivr.net, and verifies the sha256. The script supports --check (CI-safe) and --latest modes.
  • Vendor @mermaid-js/tiny@11.14.0 into docs/assets/javascripts/mermaid.tiny.js.
  • Add docs/javascripts/mermaid-init.js, which initializes the vendored build with startOnLoad: false and securityLevel: strict.
  • Register both files under extra_javascript in zensical.toml.
  • Add .gitattributes marking docs/assets/javascripts/** as binary so PR diffs for vendored files stay readable.
  • Add a "Verify vendored Mermaid" step to the docs workflow so drift between the committed file and the pinned sha256 fails CI.
  • Document the vendoring convention and upgrade procedure in CONTRIBUTING.md under "Vendored dependencies".

Affected pages: getting-started/development-environment, sdk-reference/operations/{invoke,wait-for-condition,callback}, testing/runner.

Issue #, if available:
Closes #152

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Mermaid diagrams render as raw text on docs.aws.amazon.com because
the site's Content Security Policy blocks Zensical's default load
of mermaid from unpkg.com. The same pages work on localhost only
because localhost has no CSP.

Switch to self-hosting the @mermaid-js/tiny UMD build, which ships
as a single file with no lazy-loaded chunks and supports all
diagram types currently in use (flowchart, sequence, state, class,
entity-relationship).

- Add scripts/vendor_mermaid.py, which reads version and expected
  sha256 from scripts/vendor_mermaid.toml, downloads the pinned
  tiny build from cdn.jsdelivr.net, and verifies the sha256. The
  script supports --check (CI-safe) and --latest modes.
- Vendor @mermaid-js/tiny@11.14.0 into
  docs/assets/javascripts/mermaid.tiny.js.
- Add docs/javascripts/mermaid-init.js, which initializes the
  vendored build with startOnLoad: false and securityLevel: strict.
- Register both files under extra_javascript in zensical.toml.
- Add .gitattributes marking docs/assets/javascripts/** as binary
  so PR diffs for vendored files stay readable.
- Add a "Verify vendored Mermaid" step to the docs workflow so
  drift between the committed file and the pinned sha256 fails CI.
- Document the vendoring convention and upgrade procedure in
  CONTRIBUTING.md under "Vendored dependencies".

Affected pages: getting-started/development-environment,
sdk-reference/operations/{invoke,wait-for-condition,callback},
testing/runner.

Closes #152
@yaythomas yaythomas merged commit 5867312 into main Apr 28, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in aws-durable-execution Apr 28, 2026
@yaythomas yaythomas deleted the fix/mermaid-csp-self-host branch April 28, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Mermaid diagrams are not rendered in the SDK guide

2 participants