@matfsw/docusaurus-plantuml-plugin 0.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.
@@ -0,0 +1,14 @@
1
+ import type { ResolvedPlantUmlOptions } from '../options.js';
2
+ export interface PlantUmlRuntimeConfig {
3
+ options: ResolvedPlantUmlOptions;
4
+ /** Absolute, `baseUrl`-prefixed URL of the directory holding the runtime assets. */
5
+ assetsBaseUrl: string;
6
+ coreVersion: string;
7
+ }
8
+ /**
9
+ * Reads the plugin's configuration from Docusaurus global data.
10
+ *
11
+ * Returns `null` rather than throwing when the data is absent, so a misconfigured site shows
12
+ * a contained error panel on the affected diagrams instead of failing to render the page.
13
+ */
14
+ export declare function usePlantUmlConfig(): PlantUmlRuntimeConfig | null;
@@ -0,0 +1,29 @@
1
+ import { useMemo } from 'react';
2
+ import useBaseUrl from '@docusaurus/useBaseUrl';
3
+ import { useAllPluginInstancesData } from '@docusaurus/useGlobalData';
4
+ import { PLUGIN_NAME } from '../constants.js';
5
+ function isGlobalData(value) {
6
+ if (typeof value !== 'object' || value === null)
7
+ return false;
8
+ const candidate = value;
9
+ return (typeof candidate.assetsDir === 'string' &&
10
+ typeof candidate.coreVersion === 'string' &&
11
+ typeof candidate.options === 'object' &&
12
+ candidate.options !== null);
13
+ }
14
+ /**
15
+ * Reads the plugin's configuration from Docusaurus global data.
16
+ *
17
+ * Returns `null` rather than throwing when the data is absent, so a misconfigured site shows
18
+ * a contained error panel on the affected diagrams instead of failing to render the page.
19
+ */
20
+ export function usePlantUmlConfig() {
21
+ const instances = useAllPluginInstancesData(PLUGIN_NAME, { failfast: false });
22
+ const first = instances ? Object.values(instances).find(isGlobalData) : undefined;
23
+ // `useBaseUrl` must be called unconditionally; the placeholder path is discarded below.
24
+ const assetsBaseUrl = useBaseUrl(first ? first.assetsDir : '/');
25
+ // Memoized because consumers use this object as an effect dependency. Returning a fresh
26
+ // object on every render would restart the render effect on every state update, which
27
+ // re-enters rendering forever.
28
+ return useMemo(() => (first ? { options: first.options, assetsBaseUrl, coreVersion: first.coreVersion } : null), [first, assetsBaseUrl]);
29
+ }
package/package.json ADDED
@@ -0,0 +1,112 @@
1
+ {
2
+ "name": "@matfsw/docusaurus-plantuml-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Render PlantUML diagrams in Docusaurus 3 entirely in the browser - no Java, no PlantUML server, no CDN.",
5
+ "keywords": [
6
+ "docusaurus",
7
+ "docusaurus-plugin",
8
+ "plantuml",
9
+ "uml",
10
+ "diagram",
11
+ "svg",
12
+ "browser"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "",
16
+ "homepage": "https://github.com/matf/docusaurus-plantuml-plugin#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/matf/docusaurus-plantuml-plugin.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/matf/docusaurus-plantuml-plugin/issues"
23
+ },
24
+ "type": "module",
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ },
34
+ "./theme/*": "./dist/theme/*",
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE",
41
+ "CHANGELOG.md"
42
+ ],
43
+ "engines": {
44
+ "node": ">=20.0.0"
45
+ },
46
+ "scripts": {
47
+ "clean": "node scripts/clean.mjs",
48
+ "build": "npm run clean && tsc -p tsconfig.build.json && tsup && node scripts/finalize-build.mjs",
49
+ "typecheck": "tsc -p tsconfig.json --noEmit",
50
+ "lint": "eslint .",
51
+ "lint:fix": "eslint . --fix",
52
+ "format": "prettier --write .",
53
+ "format:check": "prettier --check .",
54
+ "test": "npm run test:unit",
55
+ "test:unit": "vitest run",
56
+ "test:watch": "vitest",
57
+ "test:coverage": "vitest run --coverage",
58
+ "test:integration": "node scripts/test-packed-example.mjs",
59
+ "test:e2e": "playwright test",
60
+ "test:all": "npm run format:check && npm run lint && npm run typecheck && npm run test:unit && npm run build && npm run pack:check && npm run test:integration",
61
+ "pack:check": "node scripts/verify-package.mjs",
62
+ "verify:tag": "node scripts/verify-tag-version.mjs",
63
+ "sync:meta": "node scripts/sync-project-metadata.mjs",
64
+ "sync:check": "node scripts/sync-project-metadata.mjs --check",
65
+ "example:install": "npm --prefix examples/docusaurus install",
66
+ "example:build": "npm --prefix examples/docusaurus run build",
67
+ "example:serve": "npm --prefix examples/docusaurus run serve",
68
+ "example:start": "npm --prefix examples/docusaurus run start",
69
+ "prepublishOnly": "node scripts/assert-built.mjs"
70
+ },
71
+ "dependencies": {
72
+ "@plantuml/core": "^1.2026.6",
73
+ "copy-webpack-plugin": "^12.0.2",
74
+ "dompurify": "^3.2.7"
75
+ },
76
+ "peerDependencies": {
77
+ "@docusaurus/core": "^3.5.0",
78
+ "react": "^18.0.0 || ^19.0.0",
79
+ "react-dom": "^18.0.0 || ^19.0.0"
80
+ },
81
+ "devDependencies": {
82
+ "@docusaurus/core": "^3.9.2",
83
+ "@docusaurus/module-type-aliases": "^3.9.2",
84
+ "@docusaurus/preset-classic": "^3.9.2",
85
+ "@docusaurus/theme-classic": "^3.9.2",
86
+ "@docusaurus/tsconfig": "^3.9.2",
87
+ "@docusaurus/types": "^3.9.2",
88
+ "@eslint/js": "^9.39.1",
89
+ "@playwright/test": "^1.57.0",
90
+ "@testing-library/dom": "^10.4.1",
91
+ "@testing-library/jest-dom": "^6.9.1",
92
+ "@testing-library/react": "^16.3.0",
93
+ "@testing-library/user-event": "^14.6.1",
94
+ "@types/node": "^22.18.13",
95
+ "@types/react": "^18.3.27",
96
+ "@types/react-dom": "^18.3.7",
97
+ "@vitest/coverage-v8": "^3.2.4",
98
+ "eslint": "^9.39.1",
99
+ "eslint-config-prettier": "^10.1.8",
100
+ "eslint-plugin-react": "^7.37.5",
101
+ "eslint-plugin-react-hooks": "^5.2.0",
102
+ "globals": "^16.5.0",
103
+ "jsdom": "^26.1.0",
104
+ "prettier": "^3.6.2",
105
+ "react": "^18.3.1",
106
+ "react-dom": "^18.3.1",
107
+ "tsup": "^8.5.0",
108
+ "typescript": "~5.9.3",
109
+ "typescript-eslint": "^8.46.4",
110
+ "vitest": "^3.2.4"
111
+ }
112
+ }