@matfsw/docusaurus-plantuml-plugin 1.7.0 → 1.8.0
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/CHANGELOG.md +68 -1
- package/README.md +99 -66
- package/dist/assets.js +38 -1
- package/dist/constants.d.ts +8 -13
- package/dist/constants.js +9 -14
- package/dist/index.cjs +68 -92
- package/dist/index.d.cts +14 -0
- package/dist/index.js +2 -13
- package/dist/options.d.ts +14 -0
- package/dist/options.js +21 -0
- package/dist/runtime/cache.d.ts +9 -1
- package/dist/runtime/cache.js +3 -2
- package/dist/runtime/renderer.d.ts +2 -0
- package/dist/runtime/renderer.js +9 -4
- package/dist/runtime/types.d.ts +12 -3
- package/dist/theme/PlantUmlDiagram/index.js +7 -1
- package/dist/theme/PlantUmlDiagram/routeMatching.d.ts +42 -0
- package/dist/theme/PlantUmlDiagram/routeMatching.js +38 -0
- package/dist/theme/PlantUmlDiagram/useDiagramLinks.d.ts +5 -2
- package/dist/theme/PlantUmlDiagram/useDiagramLinks.js +6 -0
- package/package.json +5 -5
- package/dist/enginePatch.d.ts +0 -41
- package/dist/enginePatch.js +0 -120
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,71 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.8.0] - 2026-09-08
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`maxSvgSize` — the diagram size ceiling is now a plugin option.** It defaults to `32768`
|
|
15
|
+
points, exactly the value 1.7.0 applied, so nothing renders differently unless you change
|
|
16
|
+
it. Raise it for a diagram that still does not fit, or set it to `0` to remove the check:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
{
|
|
20
|
+
maxSvgSize: 65_536, // or 0 for no ceiling at all
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It takes a non-negative integer and applies to PlantUML fences only — Graphviz keeps its own
|
|
25
|
+
`graphviz.maxSourceBytes` guard. A negative value is rejected at build time rather than
|
|
26
|
+
passed through, because the engine reads a negative as "unspecified" and would quietly fall
|
|
27
|
+
back to its own 8192 default. See [Diagram size](README.md#diagram-size) and
|
|
28
|
+
[ADR 0008](docs/adr/0008-configurable-max-svg-size.md).
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- **The engine is no longer patched.** 1.7.0 rewrote two literals in `@plantuml/core`'s
|
|
33
|
+
minified bundle to raise a ceiling that had no option behind it. Upstream has since added
|
|
34
|
+
one ([plantuml/plantuml#2832](https://github.com/plantuml/plantuml/issues/2832)), so the
|
|
35
|
+
rewrite is gone and the vendored engine ships as published. The build no longer reads and
|
|
36
|
+
rewrites 7 MB, and `.docusaurus/plantuml-engine/` is no longer generated — an existing one
|
|
37
|
+
from 1.7.x is orphaned and can be deleted.
|
|
38
|
+
- **`@plantuml/core` now requires `>= 1.2026.8`**, the release that added `maxSvgSize`. An
|
|
39
|
+
older engine ignores render options it does not know, which would leave `maxSvgSize` reading
|
|
40
|
+
as honoured while the stock 4096-point ceiling refused large diagrams — so the build fails
|
|
41
|
+
naming the installed version instead. If an override or a stale lockfile pins you below it,
|
|
42
|
+
update `@plantuml/core`.
|
|
43
|
+
- **The runtime assets moved back to `assets/plantuml-client-<coreVersion>/`.** The
|
|
44
|
+
`-max32768` segment existed to distinguish differently patched engines; with no patch it
|
|
45
|
+
distinguishes nothing. The URL changes anyway because the engine version changes, so this
|
|
46
|
+
costs no extra cache churn. The standard library is nested inside that directory and is
|
|
47
|
+
re-downloaded once. No configuration changes.
|
|
48
|
+
- **`maxSvgSize` is part of the render cache key.** The ceiling can be lowered, and `session`
|
|
49
|
+
cache entries outlive the rebuild that lowered it; without this a site that tightened the
|
|
50
|
+
setting would keep serving readers the oversized diagram their tab had already cached.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- **An in-diagram link to a path the running build does not route no longer dead-ends on
|
|
55
|
+
"Page not found".** Clicks used to go through the Docusaurus router whenever the target was
|
|
56
|
+
same-origin. On a site published as several Docusaurus builds — one per product area, a docs
|
|
57
|
+
build beside a marketing build, two builds joined by a reverse proxy — the bundles share an
|
|
58
|
+
origin but each routes only its own subtree, so a link to a sibling build's page matched no
|
|
59
|
+
route, rendered *this* build's `NotFound`, and never reached the server that could serve it.
|
|
60
|
+
The tell was that reloading the same URL worked.
|
|
61
|
+
|
|
62
|
+
The plugin now checks the running build's route table and pushes only what this build
|
|
63
|
+
routes, handing anything else to the browser as a normal navigation. An unknown page inside
|
|
64
|
+
a subtree this build owns still routes client-side, because its own 404 page is the right
|
|
65
|
+
answer there. Single-build sites are unaffected. As a side benefit, `experimental_router:
|
|
66
|
+
'hash'` — where a site-absolute link resolves to a path the router cannot push — now falls
|
|
67
|
+
back to a native load instead of going nowhere.
|
|
68
|
+
|
|
69
|
+
## [1.7.1] - 2026-09-03
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
|
|
73
|
+
- Bump the all-security group across 2 directories with 1 update (#37)
|
|
74
|
+
|
|
10
75
|
## [1.7.0] - 2026-09-02
|
|
11
76
|
|
|
12
77
|
### Added
|
|
@@ -652,7 +717,9 @@ Initial release.
|
|
|
652
717
|
opt-out.
|
|
653
718
|
- Plugin option validation that rejects unknown keys and out-of-range values at build time.
|
|
654
719
|
|
|
655
|
-
[Unreleased]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.
|
|
720
|
+
[Unreleased]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.8.0...HEAD
|
|
721
|
+
[1.8.0]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.7.1...v1.8.0
|
|
722
|
+
[1.7.1]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.7.0...v1.7.1
|
|
656
723
|
[1.7.0]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.6.3...v1.7.0
|
|
657
724
|
[1.6.3]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.6.2...v1.6.3
|
|
658
725
|
[1.6.2]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.6.1...v1.6.2
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ them are exported.
|
|
|
60
60
|
| Node.js (build) | `>= 20.9.0` (the Node 20 LTS line) |
|
|
61
61
|
| React | `18.x` or `19.x` (matching your Docusaurus install) |
|
|
62
62
|
| Bundler | webpack (default) and Rspack (`future.v4` / `@docusaurus/faster`) |
|
|
63
|
-
| PlantUML engine | `@plantuml/core`
|
|
63
|
+
| PlantUML engine | `@plantuml/core` `>= 1.2026.8` |
|
|
64
64
|
| Browsers | Modern evergreen browsers; no IE (see [Browser compatibility](#browser-compatibility)) |
|
|
65
65
|
|
|
66
66
|
The plugin requires a theme that already provides `MDXComponents/Code` — in practice
|
|
@@ -100,8 +100,10 @@ exactly what the compatibility job in CI does to test the `3.5.2` leg.
|
|
|
100
100
|
### A note on the engine's licence
|
|
101
101
|
|
|
102
102
|
`@plantuml/core` is MIT-licensed **from version `1.2026.6` onwards**. Earlier versions were
|
|
103
|
-
published under GPL-3.0-or-later. This plugin depends on `^1.2026.
|
|
104
|
-
|
|
103
|
+
published under GPL-3.0-or-later. This plugin depends on `^1.2026.8` — which is well past that
|
|
104
|
+
line, and is also the release that added the `maxSvgSize` option
|
|
105
|
+
[`maxSvgSize`](#diagram-size) relies on. Pinning or deduping `@plantuml/core` below `1.2026.8`
|
|
106
|
+
fails the build with a message naming the version, rather than silently ignoring the option.
|
|
105
107
|
|
|
106
108
|
## Installation
|
|
107
109
|
|
|
@@ -149,6 +151,7 @@ const config: Config = {
|
|
|
149
151
|
showSourceOnError: true,
|
|
150
152
|
renderTimeoutMs: 20_000,
|
|
151
153
|
cacheMaxEntries: 50,
|
|
154
|
+
maxSvgSize: 32_768,
|
|
152
155
|
zoom: true,
|
|
153
156
|
graphviz: {
|
|
154
157
|
enabled: true,
|
|
@@ -231,26 +234,29 @@ props untouched. Existing code-block behaviour (highlighting, line numbers, titl
|
|
|
231
234
|
|
|
232
235
|
## Options
|
|
233
236
|
|
|
234
|
-
| Option | Type | Default | Description
|
|
235
|
-
| ------------------- | --------------------------------- | ---------------------- |
|
|
236
|
-
| `languages` | `string[]` | `['plantuml', 'puml']` | Fence languages treated as PlantUML. Matched case-insensitively; must contain at least one non-empty, non-duplicate entry.
|
|
237
|
-
| `theme` | `'auto' \| 'light' \| 'dark'` | `'auto'` | Diagram colour scheme. `auto` follows the Docusaurus colour mode; `light`/`dark` pin it.
|
|
238
|
-
| `lazy` | `boolean` | `true` | Render a diagram only once it scrolls near the viewport (300 px root margin).
|
|
239
|
-
| `cache` | `'none' \| 'memory' \| 'session'` | `'memory'` | Where rendered SVG is cached.
|
|
240
|
-
| `sanitizeSvg` | `boolean` | `true` | Run rendered SVG through DOMPurify before inserting it. See [Security model](#svg-sanitization-and-security-model).
|
|
241
|
-
| `showSourceOnError` | `boolean` | `true` | Include the diagram source in a `<details>` block on the error panel.
|
|
242
|
-
| `renderTimeoutMs` | `number` | `20000` | Abort a single render (and the runtime load) after this many milliseconds. Integer, `100`–`600000`.
|
|
243
|
-
| `cacheMaxEntries` | `number` | `50` | Upper bound on cached SVG entries. Positive integer.
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
237
|
+
| Option | Type | Default | Description |
|
|
238
|
+
| ------------------- | --------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
239
|
+
| `languages` | `string[]` | `['plantuml', 'puml']` | Fence languages treated as PlantUML. Matched case-insensitively; must contain at least one non-empty, non-duplicate entry. |
|
|
240
|
+
| `theme` | `'auto' \| 'light' \| 'dark'` | `'auto'` | Diagram colour scheme. `auto` follows the Docusaurus colour mode; `light`/`dark` pin it. |
|
|
241
|
+
| `lazy` | `boolean` | `true` | Render a diagram only once it scrolls near the viewport (300 px root margin). |
|
|
242
|
+
| `cache` | `'none' \| 'memory' \| 'session'` | `'memory'` | Where rendered SVG is cached. |
|
|
243
|
+
| `sanitizeSvg` | `boolean` | `true` | Run rendered SVG through DOMPurify before inserting it. See [Security model](#svg-sanitization-and-security-model). |
|
|
244
|
+
| `showSourceOnError` | `boolean` | `true` | Include the diagram source in a `<details>` block on the error panel. |
|
|
245
|
+
| `renderTimeoutMs` | `number` | `20000` | Abort a single render (and the runtime load) after this many milliseconds. Integer, `100`–`600000`. |
|
|
246
|
+
| `cacheMaxEntries` | `number` | `50` | Upper bound on cached SVG entries. Positive integer. |
|
|
247
|
+
| `maxSvgSize` | `number` | `32768` | Refuse a PlantUML diagram wider or taller than this many points. Non-negative integer; `0` disables the check. See [Diagram size](#diagram-size). |
|
|
248
|
+
| `zoom` | `boolean` | `true` | Let readers zoom and pan diagrams. Adds a control toolbar and a focusable viewport. Override per fence with `zoom=false`. |
|
|
249
|
+
| `showSource` | `boolean` | `true` | Offer a toolbar control that reveals the diagram source and copies it to the clipboard. Override per fence with `showSource=false`. |
|
|
250
|
+
| `graphviz` | `object` | see below | Graphviz/DOT support. See [Graphviz options](#graphviz-options). |
|
|
251
|
+
| `stdlib` | `object \| false` | see below | PlantUML standard library (`!include <C4/…>`). See [Standard library options](#standard-library-options). |
|
|
252
|
+
| `id` | `string` | `'default'` | Docusaurus plugin instance id; only relevant if you register the plugin more than once. |
|
|
253
|
+
|
|
254
|
+
Every option above except `graphviz`, `stdlib`, `theme` and `maxSvgSize` applies to **both**
|
|
255
|
+
engines: `lazy`, `cache`, `sanitizeSvg`, `showSourceOnError`, `renderTimeoutMs`,
|
|
256
|
+
`cacheMaxEntries` and `zoom` behave identically for a `dot` fence and a `plantuml` fence.
|
|
257
|
+
`theme` is the exception for colour — see [Light and dark mode](#light-and-dark-mode) — and
|
|
258
|
+
`maxSvgSize` is PlantUML-only, because Graphviz fences are bounded by
|
|
259
|
+
`graphviz.maxSourceBytes` instead.
|
|
254
260
|
|
|
255
261
|
Options are validated during the Docusaurus configuration phase, before anything is built.
|
|
256
262
|
**Unknown keys are rejected** rather than ignored, because a typo in `docusaurus.config.ts`
|
|
@@ -259,7 +265,8 @@ would otherwise silently disable the option you meant to set:
|
|
|
259
265
|
```text
|
|
260
266
|
[docusaurus-plugin-plantuml-client] Unknown option 'sanitiseSvg'. Supported options:
|
|
261
267
|
'languages', 'theme', 'lazy', 'cache', 'sanitizeSvg', 'showSourceOnError',
|
|
262
|
-
'renderTimeoutMs', 'cacheMaxEntries', 'zoom', 'showSource', 'graphviz',
|
|
268
|
+
'renderTimeoutMs', 'cacheMaxEntries', 'maxSvgSize', 'zoom', 'showSource', 'graphviz',
|
|
269
|
+
'stdlib'.
|
|
263
270
|
```
|
|
264
271
|
|
|
265
272
|
The same is true one level deeper, so `graphviz: {enigne: 'neato'}` fails the build rather than
|
|
@@ -805,12 +812,22 @@ digraph {
|
|
|
805
812
|
|
|
806
813
|
#### How clicks navigate
|
|
807
814
|
|
|
808
|
-
Both engines share the same navigation behaviour: a click on an in-diagram link to a
|
|
809
|
-
|
|
810
|
-
paths get the site's `baseUrl` exactly as markdown links do, so `/docs/orders`
|
|
811
|
-
same thing in a diagram as in prose. External links and pure `#…` anchors stay
|
|
812
|
-
modified clicks (Ctrl, Cmd, Shift) keep the browser's own behaviour, and a click that
|
|
813
|
-
a drag never navigates.
|
|
815
|
+
Both engines share the same navigation behaviour: a click on an in-diagram link to a URL
|
|
816
|
+
**this build routes** goes through the Docusaurus router — no full page load — and
|
|
817
|
+
site-absolute paths get the site's `baseUrl` exactly as markdown links do, so `/docs/orders`
|
|
818
|
+
means the same thing in a diagram as in prose. External links and pure `#…` anchors stay
|
|
819
|
+
native, modified clicks (Ctrl, Cmd, Shift) keep the browser's own behaviour, and a click that
|
|
820
|
+
ends a drag never navigates.
|
|
821
|
+
|
|
822
|
+
A same-origin path this build has **no route for** stays native too, and that exception
|
|
823
|
+
matters if your site is published as more than one Docusaurus build — one per product area,
|
|
824
|
+
a docs build beside a marketing build, or two builds stitched together by a reverse proxy.
|
|
825
|
+
Those bundles share an origin but each routes only its own subtree, so pushing a sibling
|
|
826
|
+
build's path into this build's router would render _this_ build's "Page not found" while the
|
|
827
|
+
server that could serve it is never asked. (The tell is that reloading the same URL works.)
|
|
828
|
+
The plugin checks the running build's route table and hands anything it does not own to the
|
|
829
|
+
browser. An unknown page _inside_ a subtree this build does own still routes normally — its
|
|
830
|
+
own 404 page is the right answer there.
|
|
814
831
|
|
|
815
832
|
Clicking either example node above therefore navigates — without a reload — to
|
|
816
833
|
`/docs/orders`, where the diagram containing `ORDER_DETAIL_1` highlights and centres it.
|
|
@@ -1043,7 +1060,7 @@ Failures are classified internally as one of:
|
|
|
1043
1060
|
| Kind | Cause |
|
|
1044
1061
|
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1045
1062
|
| `load` | `viz-global.js` or `plantuml.js` could not be fetched, timed out, or was not the expected module (usually a proxy or service worker returning the wrong file). |
|
|
1046
|
-
| `engine` | The engine threw, or its output could not be used at all. Includes `Diagram too large for browser rendering: WxH (max 32768)` — see [Diagram size](#diagram-size).
|
|
1063
|
+
| `engine` | The engine threw, or its output could not be used at all. Includes `Diagram too large for browser rendering: WxH (max 32768; …)` — see [Diagram size](#diagram-size). |
|
|
1047
1064
|
| `diagram` | The source is not valid PlantUML. |
|
|
1048
1065
|
| `syntax` | The source is not valid DOT. Carries Graphviz's own diagnostic, including the line number. |
|
|
1049
1066
|
| `too-large` | A DOT source exceeded `graphviz.maxSourceBytes`. |
|
|
@@ -1067,19 +1084,35 @@ The two engines report invalid source very differently:
|
|
|
1067
1084
|
|
|
1068
1085
|
## Diagram size
|
|
1069
1086
|
|
|
1070
|
-
`@plantuml/core`
|
|
1071
|
-
PlantUML points, reporting it through its error callback:
|
|
1087
|
+
`@plantuml/core` measures every diagram it lays out and refuses to serialize one wider or
|
|
1088
|
+
taller than a set number of PlantUML points, reporting it through its error callback:
|
|
1072
1089
|
|
|
1073
1090
|
```text
|
|
1074
|
-
Diagram too large for browser rendering: 78x12916 (max
|
|
1091
|
+
Diagram too large for browser rendering: 78x12916 (max 8192; override via the maxSvgSize
|
|
1092
|
+
option, or set it to 0 to disable this check)
|
|
1075
1093
|
```
|
|
1076
1094
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
configurable — one constant, applied on every build.
|
|
1095
|
+
The engine's own ceiling is **8192**. This plugin sets **32768** by default — high enough that
|
|
1096
|
+
a real architecture diagram or release runbook does not meet it — and `maxSvgSize` moves it:
|
|
1080
1097
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1098
|
+
```ts
|
|
1099
|
+
{
|
|
1100
|
+
maxSvgSize: 65_536, // raise it
|
|
1101
|
+
}
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
```ts
|
|
1105
|
+
{
|
|
1106
|
+
maxSvgSize: 0, // no ceiling at all
|
|
1107
|
+
}
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
It takes a non-negative integer. `0` is the engine's own convention for "no check"; a negative
|
|
1111
|
+
value is rejected at build time rather than passed through, because the engine reads a negative
|
|
1112
|
+
as "unspecified" and would quietly fall back to 8192.
|
|
1113
|
+
|
|
1114
|
+
The ceiling is not something a diagram can talk its way around, which is why the option is the
|
|
1115
|
+
only real lever. Measured against the engine:
|
|
1083
1116
|
|
|
1084
1117
|
| Attempt | Effect |
|
|
1085
1118
|
| ------------------------- | -------------------------------------------------------- |
|
|
@@ -1088,38 +1121,38 @@ worth doing. Measured against the engine:
|
|
|
1088
1121
|
| `left to right direction` | none; it transposes width and height |
|
|
1089
1122
|
| `skinparam ranksep 5` | works — it genuinely shrinks the layout |
|
|
1090
1123
|
|
|
1091
|
-
|
|
1092
|
-
diagram smaller: fewer nodes and edges, tighter `skinparam ranksep`/`nodesep`, a
|
|
1093
|
-
`skinparam defaultFontSize`, or splitting one diagram into several fences.
|
|
1124
|
+
So if you would rather keep the ceiling where it is, the levers that work are the ones that
|
|
1125
|
+
make the diagram smaller: fewer nodes and edges, tighter `skinparam ranksep`/`nodesep`, a
|
|
1126
|
+
smaller `skinparam defaultFontSize`, or splitting one diagram into several fences.
|
|
1127
|
+
|
|
1128
|
+
**Raising it is not free.** A 30 000-point diagram is a multi-hundred-KB SVG, and both the
|
|
1129
|
+
error detection and the DOMPurify sanitization parse it synchronously on the main thread. Such
|
|
1130
|
+
a diagram can visibly stall the tab while it lands, and may need `renderTimeoutMs` raised above
|
|
1131
|
+
its 20 s default. That cost is the reason the default is a number rather than `0`. See
|
|
1132
|
+
[ADR 0008](docs/adr/0008-configurable-max-svg-size.md).
|
|
1094
1133
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
thread. Such a diagram can visibly stall the tab while it lands, and may need
|
|
1098
|
-
`renderTimeoutMs` raised above its 20 s default. See
|
|
1099
|
-
[ADR 0007](docs/adr/0007-engine-size-ceiling-patch.md).
|
|
1134
|
+
`maxSvgSize` applies to PlantUML fences only; Graphviz has its own guard in
|
|
1135
|
+
`graphviz.maxSourceBytes`.
|
|
1100
1136
|
|
|
1101
1137
|
## `baseUrl` support
|
|
1102
1138
|
|
|
1103
1139
|
The runtime assets are emitted into
|
|
1104
1140
|
|
|
1105
1141
|
```text
|
|
1106
|
-
<baseUrl>assets/plantuml-client-<coreVersion
|
|
1142
|
+
<baseUrl>assets/plantuml-client-<coreVersion>/
|
|
1107
1143
|
```
|
|
1108
1144
|
|
|
1109
1145
|
and resolved in the browser through Docusaurus' own `useBaseUrl()`. A site deployed at
|
|
1110
1146
|
`baseUrl: '/plantuml-test/'` therefore fetches:
|
|
1111
1147
|
|
|
1112
1148
|
```text
|
|
1113
|
-
/plantuml-test/assets/plantuml-client-1.2026.
|
|
1114
|
-
/plantuml-test/assets/plantuml-client-1.2026.
|
|
1149
|
+
/plantuml-test/assets/plantuml-client-1.2026.8/viz-global.js
|
|
1150
|
+
/plantuml-test/assets/plantuml-client-1.2026.8/plantuml.js
|
|
1115
1151
|
```
|
|
1116
1152
|
|
|
1117
1153
|
No path is hard-coded to the site root, so project-pages deployments and reverse-proxied
|
|
1118
1154
|
subpaths work without configuration. The engine version is part of the directory name, so an
|
|
1119
|
-
upgrade changes the URL and stale caches are defeated automatically. The
|
|
1120
|
-
is part of the same identity: what is served is a _patched_ engine (see
|
|
1121
|
-
[Diagram size](#diagram-size)), and a reader holding a cached copy from a plugin version that
|
|
1122
|
-
patched differently must not be handed it from the same URL. The bundled example site
|
|
1155
|
+
upgrade changes the URL and stale caches are defeated automatically. The bundled example site
|
|
1123
1156
|
deploys under a non-root `baseUrl` precisely so this path is exercised on every build.
|
|
1124
1157
|
|
|
1125
1158
|
## Browser compatibility
|
|
@@ -1466,16 +1499,16 @@ too and was rejected: it carries one person's account reach and expires on a cal
|
|
|
1466
1499
|
- **One PlantUML diagram renders at a time.** The PlantUML engine has module-level shared
|
|
1467
1500
|
state, so a page with many large diagrams renders them sequentially. This is a correctness
|
|
1468
1501
|
requirement, not a tuning knob. Graphviz has no such constraint and is not queued.
|
|
1469
|
-
- **PlantUML diagrams are capped at 32768 points in each dimension.** The
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
- **A `@plantuml/core`
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1502
|
+
- **PlantUML diagrams are capped at 32768 points in each dimension by default.** The engine
|
|
1503
|
+
measures the laid-out diagram and refuses anything larger. `maxSvgSize` raises the ceiling,
|
|
1504
|
+
or removes it with `0` — see [Diagram size](#diagram-size) — but a genuinely enormous diagram
|
|
1505
|
+
then renders instead of failing fast, and both the error detection and the sanitizer parse
|
|
1506
|
+
the resulting SVG synchronously, so it can stall the tab on its way in. Past that, the
|
|
1507
|
+
diagram itself has to get smaller.
|
|
1508
|
+
- **A `@plantuml/core` older than `1.2026.8` fails the build.** That release added the
|
|
1509
|
+
`maxSvgSize` render option, and an engine that does not know the option ignores it in
|
|
1510
|
+
silence — which would leave `maxSvgSize` reading as honoured while the engine's own ceiling
|
|
1511
|
+
refused large diagrams. The plugin checks the installed version rather than guessing.
|
|
1479
1512
|
- **Graphviz rendering blocks the main thread.** Viz.js lays out synchronously. A 300-edge
|
|
1480
1513
|
graph takes ~26 ms, but a 3 000-edge graph takes ~2.25 s and visibly freezes the page;
|
|
1481
1514
|
`graphviz.maxSourceBytes` is the guard. Rendering in a Web Worker would remove the ceiling
|
|
@@ -1498,7 +1531,7 @@ too and was rejected: it carries one person's account reach and expires on a cal
|
|
|
1498
1531
|
### Diagrams stay on "Loading PlantUML runtime…" and the assets 404 under a subpath
|
|
1499
1532
|
|
|
1500
1533
|
Open the network tab and check the failing URL. It should be
|
|
1501
|
-
`<baseUrl>assets/plantuml-client-<version
|
|
1534
|
+
`<baseUrl>assets/plantuml-client-<version>/viz-global.js`. If the request goes to
|
|
1502
1535
|
`/assets/...` when your site lives at `/docs/`, the site's `baseUrl` is wrong — not the
|
|
1503
1536
|
plugin's paths, which are always resolved through `useBaseUrl()`.
|
|
1504
1537
|
|
|
@@ -1522,7 +1555,7 @@ served as `text/plain`, `application/octet-stream` or `text/html`. The console s
|
|
|
1522
1555
|
MIME type checking error. Check with:
|
|
1523
1556
|
|
|
1524
1557
|
```bash
|
|
1525
|
-
curl -I https://example.com/your-base-url/assets/plantuml-client-1.2026.
|
|
1558
|
+
curl -I https://example.com/your-base-url/assets/plantuml-client-1.2026.8/plantuml.js
|
|
1526
1559
|
```
|
|
1527
1560
|
|
|
1528
1561
|
The `content-type` must be a JavaScript type (`text/javascript` or
|
package/dist/assets.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { PLANTUML_MODULE_FILENAME, PLUGIN_NAME, VIZ_SCRIPT_FILENAME } from './constants.js';
|
|
4
|
+
import { MINIMUM_CORE_VERSION, PLANTUML_MODULE_FILENAME, PLUGIN_NAME, VIZ_SCRIPT_FILENAME, } from './constants.js';
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
/**
|
|
7
7
|
* Locates the installed `@plantuml/core` package on disk.
|
|
@@ -21,6 +21,7 @@ export function locatePlantUmlCore() {
|
|
|
21
21
|
const packageDir = path.dirname(packageJsonPath);
|
|
22
22
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
23
23
|
const version = typeof packageJson.version === 'string' ? packageJson.version : '0.0.0';
|
|
24
|
+
assertSupportedVersion(version);
|
|
24
25
|
const files = [
|
|
25
26
|
path.join(packageDir, VIZ_SCRIPT_FILENAME),
|
|
26
27
|
path.join(packageDir, PLANTUML_MODULE_FILENAME),
|
|
@@ -47,3 +48,39 @@ function assertRuntimeFile(file, version) {
|
|
|
47
48
|
'@plantuml/core is not one this plugin supports. Pin a supported version, or open an ' +
|
|
48
49
|
'issue if the package has genuinely changed its layout.');
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Compares two `major.minor.patch` versions, ignoring any pre-release suffix.
|
|
53
|
+
*
|
|
54
|
+
* A hand-rolled comparison rather than a `semver` dependency: the only versions being
|
|
55
|
+
* compared are `@plantuml/core`'s own, which are plain three-part numbers.
|
|
56
|
+
*/
|
|
57
|
+
function compareVersions(left, right) {
|
|
58
|
+
const parse = (value) => (value.split('-')[0] ?? '').split('.').map((part) => Number.parseInt(part, 10) || 0);
|
|
59
|
+
const a = parse(left);
|
|
60
|
+
const b = parse(right);
|
|
61
|
+
for (let index = 0; index < 3; index += 1) {
|
|
62
|
+
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
63
|
+
if (difference !== 0)
|
|
64
|
+
return difference;
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Fails the build if the installed `@plantuml/core` predates the `maxSvgSize` render option.
|
|
70
|
+
*
|
|
71
|
+
* `package.json` already asks for a new enough version, but a site can end up on an older one
|
|
72
|
+
* through a hoisted duplicate, an override, or a stale lockfile. Without this check that would
|
|
73
|
+
* be silent: the engine ignores an option it does not know, so `options.maxSvgSize` would read
|
|
74
|
+
* as honoured while the engine's own 4096-point ceiling quietly refused large diagrams.
|
|
75
|
+
*
|
|
76
|
+
* See `docs/adr/0008-configurable-max-svg-size.md`.
|
|
77
|
+
*/
|
|
78
|
+
function assertSupportedVersion(version) {
|
|
79
|
+
if (compareVersions(version, MINIMUM_CORE_VERSION) >= 0)
|
|
80
|
+
return;
|
|
81
|
+
throw new Error(`[${PLUGIN_NAME}] '@plantuml/core@${version}' is older than the minimum this plugin ` +
|
|
82
|
+
`supports, ${MINIMUM_CORE_VERSION}. That release added the 'maxSvgSize' render option ` +
|
|
83
|
+
"this plugin's `maxSvgSize` setting relies on; on an older engine the setting would be " +
|
|
84
|
+
'silently ignored and diagrams larger than 4096 points would be refused. Update ' +
|
|
85
|
+
'@plantuml/core, or remove the override or stale lockfile entry pinning it.');
|
|
86
|
+
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -11,24 +11,19 @@ export declare const PLUGIN_ID = "plantuml-client";
|
|
|
11
11
|
export declare const DEFAULT_PLUGIN_ID = "default";
|
|
12
12
|
export declare const PLUGIN_NAME = "docusaurus-plugin-plantuml-client";
|
|
13
13
|
/**
|
|
14
|
-
* The
|
|
14
|
+
* The lowest `@plantuml/core` this plugin supports, checked by `locatePlantUmlCore()`.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* 1.2026.8 is the release that added the `maxSvgSize` render option. On anything older the
|
|
17
|
+
* option is silently ignored and the engine's own 4096-point ceiling applies, which would
|
|
18
|
+
* turn `options.maxSvgSize` into a setting that reads as honoured and is not.
|
|
18
19
|
*/
|
|
19
|
-
export declare const
|
|
20
|
-
/**
|
|
21
|
-
* The ceiling this plugin patches into the engine it serves. See `src/enginePatch.ts` and
|
|
22
|
-
* `docs/adr/0007-engine-size-ceiling-patch.md`.
|
|
23
|
-
*/
|
|
24
|
-
export declare const MAX_DIAGRAM_SIZE = 32768;
|
|
20
|
+
export declare const MINIMUM_CORE_VERSION = "1.2026.8";
|
|
25
21
|
/**
|
|
26
22
|
* Directory (relative to `baseUrl`) that the PlantUML runtime assets are emitted into.
|
|
27
23
|
*
|
|
28
|
-
* The
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* same URL. Same reasoning as the `stdlib-<revision>` segment nested inside this one.
|
|
24
|
+
* The engine version is in the name so that upgrading `@plantuml/core` moves every asset URL
|
|
25
|
+
* and no stale cache entry can survive it. Same reasoning as the `stdlib-<revision>` segment
|
|
26
|
+
* nested inside this one.
|
|
32
27
|
*/
|
|
33
28
|
export declare function assetsDirForVersion(coreVersion: string): string;
|
|
34
29
|
export declare const VIZ_SCRIPT_FILENAME = "viz-global.js";
|
package/dist/constants.js
CHANGED
|
@@ -11,27 +11,22 @@ export const PLUGIN_ID = 'plantuml-client';
|
|
|
11
11
|
export const DEFAULT_PLUGIN_ID = 'default';
|
|
12
12
|
export const PLUGIN_NAME = `docusaurus-plugin-${PLUGIN_ID}`;
|
|
13
13
|
/**
|
|
14
|
-
* The
|
|
14
|
+
* The lowest `@plantuml/core` this plugin supports, checked by `locatePlantUmlCore()`.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* 1.2026.8 is the release that added the `maxSvgSize` render option. On anything older the
|
|
17
|
+
* option is silently ignored and the engine's own 4096-point ceiling applies, which would
|
|
18
|
+
* turn `options.maxSvgSize` into a setting that reads as honoured and is not.
|
|
18
19
|
*/
|
|
19
|
-
export const
|
|
20
|
-
/**
|
|
21
|
-
* The ceiling this plugin patches into the engine it serves. See `src/enginePatch.ts` and
|
|
22
|
-
* `docs/adr/0007-engine-size-ceiling-patch.md`.
|
|
23
|
-
*/
|
|
24
|
-
export const MAX_DIAGRAM_SIZE = 32_768;
|
|
20
|
+
export const MINIMUM_CORE_VERSION = '1.2026.8';
|
|
25
21
|
/**
|
|
26
22
|
* Directory (relative to `baseUrl`) that the PlantUML runtime assets are emitted into.
|
|
27
23
|
*
|
|
28
|
-
* The
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* same URL. Same reasoning as the `stdlib-<revision>` segment nested inside this one.
|
|
24
|
+
* The engine version is in the name so that upgrading `@plantuml/core` moves every asset URL
|
|
25
|
+
* and no stale cache entry can survive it. Same reasoning as the `stdlib-<revision>` segment
|
|
26
|
+
* nested inside this one.
|
|
32
27
|
*/
|
|
33
28
|
export function assetsDirForVersion(coreVersion) {
|
|
34
|
-
return `assets/${PLUGIN_ID}-${coreVersion}
|
|
29
|
+
return `assets/${PLUGIN_ID}-${coreVersion}`;
|
|
35
30
|
}
|
|
36
31
|
export const VIZ_SCRIPT_FILENAME = 'viz-global.js';
|
|
37
32
|
export const PLANTUML_MODULE_FILENAME = 'plantuml.js';
|