@matfsw/docusaurus-plantuml-plugin 1.0.2 → 1.1.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 +108 -1
- package/README.md +265 -50
- package/dist/assets.js +25 -8
- package/dist/constants.d.ts +12 -1
- package/dist/constants.js +12 -1
- package/dist/index.cjs +116 -17
- package/dist/index.d.cts +41 -1
- package/dist/options.d.ts +42 -1
- package/dist/options.js +105 -8
- package/dist/runtime/assetLoader.d.ts +13 -3
- package/dist/runtime/assetLoader.js +68 -8
- package/dist/runtime/cache.d.ts +21 -0
- package/dist/runtime/cache.js +12 -0
- package/dist/runtime/errors.d.ts +16 -1
- package/dist/runtime/errors.js +32 -0
- package/dist/runtime/graphvizRenderer.d.ts +24 -0
- package/dist/runtime/graphvizRenderer.js +95 -0
- package/dist/runtime/types.d.ts +41 -0
- package/dist/theme/MDXComponents/Code/index.d.ts +8 -3
- package/dist/theme/MDXComponents/Code/index.js +31 -8
- package/dist/theme/PlantUmlDiagram/index.d.ts +16 -4
- package/dist/theme/PlantUmlDiagram/index.js +49 -12
- package/dist/theme/PlantUmlDiagram/styles.module.css +31 -0
- package/dist/theme/PlantUmlDiagram/useZoomPan.js +10 -5
- package/dist/theme/codeBlockMeta.d.ts +9 -0
- package/dist/theme/codeBlockMeta.js +21 -0
- package/dist/theme/usePlantUmlConfig.d.ts +1 -1
- package/dist/theme/usePlantUmlConfig.js +20 -1
- package/package.json +9 -9
|
@@ -81,6 +81,27 @@ export function parseBooleanMeta(props, key) {
|
|
|
81
81
|
return false;
|
|
82
82
|
return undefined;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Reads a `key=value` pair from the fence metastring, accepting `engine=neato`,
|
|
86
|
+
* `engine="neato"` and `engine='neato'` alike.
|
|
87
|
+
*
|
|
88
|
+
* Unlike {@link parseBooleanMeta} this runs against the raw metastring, because the value it
|
|
89
|
+
* is looking for may itself be the quoted part. Returns `undefined` when the key is absent or
|
|
90
|
+
* carries no value, which the caller reads as "fall back to the plugin option".
|
|
91
|
+
*/
|
|
92
|
+
export function parseStringMeta(props, key) {
|
|
93
|
+
const metastring = props.metastring;
|
|
94
|
+
if (typeof metastring !== 'string' || metastring === '')
|
|
95
|
+
return undefined;
|
|
96
|
+
// Word boundaries by hand, matching parseBooleanMeta: `subengine=` must not match `engine`.
|
|
97
|
+
const pattern = new RegExp(`(?:^|\\s)${key}=(?:"([^"]*)"|'([^']*)'|(\\S+))(?=\\s|$)`, 'i');
|
|
98
|
+
const match = pattern.exec(metastring);
|
|
99
|
+
if (!match)
|
|
100
|
+
return undefined;
|
|
101
|
+
const value = match[1] ?? match[2] ?? match[3];
|
|
102
|
+
const trimmed = value?.trim();
|
|
103
|
+
return trimmed !== undefined && trimmed !== '' ? trimmed : undefined;
|
|
104
|
+
}
|
|
84
105
|
/** Reads `title="..."` (or `title='...'`) from the fence metastring. */
|
|
85
106
|
export function parseTitle(props) {
|
|
86
107
|
if (typeof props.title === 'string' && props.title !== '')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ResolvedPlantUmlOptions } from '../options.js';
|
|
2
2
|
export interface PlantUmlRuntimeConfig {
|
|
3
3
|
options: ResolvedPlantUmlOptions;
|
|
4
4
|
/** Absolute, `baseUrl`-prefixed URL of the directory holding the runtime assets. */
|
|
@@ -2,6 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
3
3
|
import { useAllPluginInstancesData } from '@docusaurus/useGlobalData';
|
|
4
4
|
import { PLUGIN_NAME } from '../constants.js';
|
|
5
|
+
import { DEFAULT_GRAPHVIZ_OPTIONS } from '../options.js';
|
|
5
6
|
function isGlobalData(value) {
|
|
6
7
|
if (typeof value !== 'object' || value === null)
|
|
7
8
|
return false;
|
|
@@ -25,5 +26,23 @@ export function usePlantUmlConfig() {
|
|
|
25
26
|
// Memoized because consumers use this object as an effect dependency. Returning a fresh
|
|
26
27
|
// object on every render would restart the render effect on every state update, which
|
|
27
28
|
// re-enters rendering forever.
|
|
28
|
-
return useMemo(() =>
|
|
29
|
+
return useMemo(() => first
|
|
30
|
+
? {
|
|
31
|
+
options: withGraphvizDefaults(first.options),
|
|
32
|
+
assetsBaseUrl,
|
|
33
|
+
coreVersion: first.coreVersion,
|
|
34
|
+
}
|
|
35
|
+
: null, [first, assetsBaseUrl]);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fills in the `graphviz` group when it is missing from global data.
|
|
39
|
+
*
|
|
40
|
+
* `resolveOptions` always produces it, so this only matters for data written by an older
|
|
41
|
+
* version of the plugin — a stale `.docusaurus` cache surviving an upgrade, most plausibly.
|
|
42
|
+
* Substituting the defaults keeps such a site rendering instead of failing on a missing key.
|
|
43
|
+
*/
|
|
44
|
+
function withGraphvizDefaults(options) {
|
|
45
|
+
if (options.graphviz)
|
|
46
|
+
return options;
|
|
47
|
+
return { ...options, graphviz: DEFAULT_GRAPHVIZ_OPTIONS };
|
|
29
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matfsw/docusaurus-plantuml-plugin",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Render PlantUML diagrams in Docusaurus 3 entirely in the browser - no Java, no PlantUML server, no CDN.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docusaurus",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"CHANGELOG.md"
|
|
42
42
|
],
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=20.
|
|
44
|
+
"node": ">=20.9.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"clean": "node scripts/clean.mjs",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@plantuml/core": "^1.2026.6",
|
|
73
|
-
"copy-webpack-plugin": "^
|
|
73
|
+
"copy-webpack-plugin": "^14.0.0",
|
|
74
74
|
"dompurify": "^3.2.7"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
@@ -91,19 +91,19 @@
|
|
|
91
91
|
"@testing-library/jest-dom": "^6.9.1",
|
|
92
92
|
"@testing-library/react": "^16.3.0",
|
|
93
93
|
"@testing-library/user-event": "^14.6.1",
|
|
94
|
-
"@types/node": "^
|
|
95
|
-
"@types/react": "^
|
|
96
|
-
"@types/react-dom": "^
|
|
94
|
+
"@types/node": "^26.1.2",
|
|
95
|
+
"@types/react": "^19.2.18",
|
|
96
|
+
"@types/react-dom": "^19.2.4",
|
|
97
97
|
"@vitest/coverage-v8": "^3.2.4",
|
|
98
98
|
"eslint": "^9.39.1",
|
|
99
99
|
"eslint-config-prettier": "^10.1.8",
|
|
100
100
|
"eslint-plugin-react": "^7.37.5",
|
|
101
101
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
102
|
-
"globals": "^
|
|
102
|
+
"globals": "^17.9.0",
|
|
103
103
|
"jsdom": "^26.1.0",
|
|
104
104
|
"prettier": "^3.6.2",
|
|
105
|
-
"react": "^
|
|
106
|
-
"react-dom": "^
|
|
105
|
+
"react": "^19.2.8",
|
|
106
|
+
"react-dom": "^19.2.8",
|
|
107
107
|
"tsup": "^8.5.0",
|
|
108
108
|
"typescript": "~5.9.3",
|
|
109
109
|
"typescript-eslint": "^8.46.4",
|