@pathmx/mermaid 0.5.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/LICENSE ADDED
@@ -0,0 +1,43 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Lucide Icons and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ ---
18
+
19
+ The following Lucide icons are derived from the Feather project:
20
+
21
+ airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
22
+
23
+ The MIT License (MIT) (for the icons listed above)
24
+
25
+ Copyright (c) 2013-present Cole Bemis
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
42
+ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE
43
+ SOFTWARE.
package/LICENSE.md ADDED
@@ -0,0 +1,172 @@
1
+ # PathMX Proprietary Beta License
2
+
3
+ Version 0.1 — July 21, 2026
4
+
5
+ Copyright © 2026 DUO Interactive, LLC.
6
+ All rights reserved.
7
+
8
+ This license governs the first-party PathMX software distributed in the npm
9
+ package `@pathmx/core`, including its command-line interface, bundled
10
+ library surfaces, runtime and Player components, and accompanying
11
+ documentation (the “Software”). DUO Interactive, LLC is the “Licensor.” This
12
+ license does not cover the private PathMX source-code repository or separately
13
+ identified third-party materials.
14
+
15
+ “Project” means Paths, Sources, responses, data, and other content authored or
16
+ processed with the Software.
17
+
18
+ “Application” means software or a service created by you in which the Software
19
+ supports product-specific functionality but is not itself offered as a
20
+ general-purpose PathMX product.
21
+
22
+ “Redistributable Components” means runtime, Player, or library portions of the
23
+ Software incorporated into a Project, Application, or generated output through
24
+ ordinary use of the Software or ordinary compilation and bundling tools.
25
+
26
+ “Authorized Users” means your employees and individual contractors who use the
27
+ Software on your behalf, and your hosting, continuous-integration, and other
28
+ service providers that possess or run necessary copies solely to provide
29
+ services to you.
30
+
31
+ ## 1. Agreement
32
+
33
+ By installing, accessing, or using the Software, you agree to this license. If
34
+ you use the Software on behalf of an organization, you represent that you have
35
+ authority to accept this license for that organization. If you do not agree,
36
+ do not install or use the Software.
37
+
38
+ ## 2. License grant
39
+
40
+ Subject to this license, the Licensor grants you a non-exclusive, worldwide,
41
+ royalty-free, non-transferable, and non-sublicensable license, perpetual for
42
+ the version of the Software to which it applies unless terminated under
43
+ Section 10, to:
44
+
45
+ - install, execute, and use the Software for personal, educational,
46
+ internal-business, or commercial purposes;
47
+ - use the Software to author, integrate, build, test, serve, play, host, and
48
+ operate Projects and Applications;
49
+ - import, compile, bundle, configure, and integrate the Software through its
50
+ documented library and command-line interfaces;
51
+ - create and distribute independent Projects, Applications, plugins, and
52
+ integrations that use those interfaces without modifying the Software
53
+ itself; and
54
+ - make copies reasonably necessary for local development, testing, continuous
55
+ integration, backup, and hosted production environments.
56
+
57
+ Your Authorized Users may exercise those rights solely on your behalf. You are
58
+ responsible for their compliance with this license.
59
+
60
+ You may reproduce and distribute Redistributable Components only as
61
+ incorporated into your Project, Application, or generated output, and only when
62
+ you preserve applicable license and proprietary notices. You may host and
63
+ commercially provide access to that Project, Application, or output. You may
64
+ not distribute Redistributable Components as a standalone package or as a
65
+ general-purpose substitute for the Software.
66
+
67
+ Each lawful recipient of a Redistributable Component may execute and use that
68
+ component, display its output, and make technically necessary transitory copies
69
+ solely as incorporated into the Project, Application, or output in which they
70
+ received it. This limited recipient permission does not include a right to
71
+ extract, modify, or redistribute the component separately.
72
+
73
+ ## 3. Restrictions
74
+
75
+ Except where applicable law does not allow the restriction, you may not:
76
+
77
+ - modify, adapt, translate, or create derivative works of the Software, except
78
+ for the compilation, bundling, configuration, and integration expressly
79
+ permitted in Section 2;
80
+ - redistribute, sublicense, sell, lease, or otherwise provide the Software to
81
+ another person as a standalone package, product, or service except to an
82
+ Authorized User or as a Redistributable Component under Section 2;
83
+ - resell, rebrand, or provide the Software as a hosted or managed service that
84
+ gives third parties general-purpose access to substantial PathMX authoring,
85
+ building, serving, Player-administration, or library functionality for their
86
+ own unrelated projects;
87
+ - reverse engineer, decompile, disassemble, or otherwise attempt to derive the
88
+ source code of the Software; or
89
+ - remove or alter copyright, license, trademark, or other proprietary notices.
90
+
91
+ For clarity, the managed-service restriction does not prohibit a hosted
92
+ Project or Application in which PathMX supports the licensee's own
93
+ product-specific experience and is not itself the general-purpose product
94
+ offered to customers.
95
+
96
+ ## 4. Your content
97
+
98
+ As between you and the Licensor, you retain ownership of the Paths, Sources,
99
+ responses, data, independent application code, and other content that you
100
+ author or provide while using the Software. You are responsible for that
101
+ content and for having the rights needed to use it.
102
+
103
+ Generated output may contain Redistributable Components or third-party
104
+ materials. Your ownership of your content does not change the ownership or
105
+ license terms of those components and materials.
106
+
107
+ ## 5. Ownership and trademarks
108
+
109
+ The Software is licensed, not sold. The Licensor and its suppliers retain all
110
+ rights in the Software not expressly granted by this license. This license
111
+ does not grant permission to use the PathMX name, logos, or other marks except
112
+ as reasonably necessary to identify the Software accurately.
113
+
114
+ ## 6. Beta status and changes
115
+
116
+ The Software is a proprietary beta release. Its APIs, behavior, file formats,
117
+ and features may change or be removed without notice. The Licensor has no
118
+ obligation to provide support, maintenance, updates, continued availability,
119
+ or backward compatibility. A later version may be offered under different
120
+ license terms, including an open-source license. Different terms for a later
121
+ version do not change the license previously granted for an earlier version.
122
+
123
+ ## 7. Third-party materials
124
+
125
+ The Software and Redistributable Components may include or depend on
126
+ third-party materials governed by their own license terms. Those terms control
127
+ for the applicable third-party materials. You must preserve third-party notices
128
+ when the applicable third-party terms require it.
129
+
130
+ ## 8. Disclaimer of warranties
131
+
132
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED “AS IS” AND
133
+ “AS AVAILABLE,” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS,
134
+ IMPLIED, OR STATUTORY, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
135
+ PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR THAT THE SOFTWARE WILL BE
136
+ SECURE, ERROR-FREE, OR UNINTERRUPTED.
137
+
138
+ ## 9. Limitation of liability
139
+
140
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR AND ITS CONTRIBUTORS,
141
+ SUPPLIERS, AND AFFILIATES WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
142
+ SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR LOSS OF DATA,
143
+ PROFITS, REVENUE, GOODWILL, OR BUSINESS OPPORTUNITY, ARISING FROM OR RELATED TO
144
+ THE SOFTWARE OR THIS LICENSE, EVEN IF ADVISED OF THE POSSIBILITY OF THOSE
145
+ DAMAGES.
146
+
147
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THEIR TOTAL LIABILITY FOR ALL CLAIMS
148
+ ARISING FROM OR RELATED TO THE SOFTWARE OR THIS LICENSE WILL NOT EXCEED THE
149
+ GREATER OF THE AMOUNT YOU PAID FOR THE SOFTWARE DURING THE TWELVE MONTHS BEFORE
150
+ THE EVENT GIVING RISE TO THE CLAIM OR US$100.
151
+
152
+ ## 10. Termination
153
+
154
+ This license terminates if you materially breach it and do not cure the breach
155
+ within thirty days after receiving written notice from the Licensor. On
156
+ termination, you and your Authorized Users must stop using and delete your
157
+ copies of the Software. Sections 4, 5, 8, 9, 10, and 11 survive termination.
158
+ Termination does not withdraw the limited permission already granted by
159
+ Section 2 to lawful recipients of Redistributable Components distributed
160
+ before termination.
161
+
162
+ ## 11. General
163
+
164
+ If a provision of this license is unenforceable, it will be modified only to
165
+ the minimum extent necessary to make it enforceable, and the remaining
166
+ provisions will continue in effect. Failure to enforce a provision is not a
167
+ waiver. You may not assign or transfer this license without the Licensor's
168
+ written consent. The Licensor may assign this license together with ownership
169
+ of the Software to a successor owner. This license binds and benefits the
170
+ permitted successors and assigns of you and the Licensor. This license is the
171
+ entire agreement concerning the Software unless you and the Licensor have
172
+ signed a separate agreement that expressly replaces it.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @pathmx/mermaid
2
+
3
+ Opt-in Mermaid diagram rendering for PathMX. The base package accepts any
4
+ renderer; the `beautiful` subpath supplies the pinned Beautiful Mermaid
5
+ adapter and loads it only when a Mermaid fence is compiled.
6
+
7
+ ```ts
8
+ import { BeautifulMermaidPlugin } from "@pathmx/mermaid/beautiful"
9
+ import { PathMX } from "@pathmx/core/bun"
10
+ import { defaultPlugins } from "@pathmx/core/plugins"
11
+
12
+ const app = await PathMX({
13
+ plugins: [BeautifulMermaidPlugin, ...defaultPlugins],
14
+ })
15
+ ```
16
+
17
+ Use a custom renderer through the base entrypoint:
18
+
19
+ ```ts
20
+ import { MermaidPlugin } from "@pathmx/mermaid"
21
+
22
+ const plugin = () => MermaidPlugin(async (code) => renderDiagram(code))
23
+ ```
package/beautiful.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { RenderOptions } from "beautiful-mermaid"
2
+ import { MermaidPlugin, type MermaidRenderer } from "./index.ts"
3
+
4
+ const options: RenderOptions = {
5
+ bg: "var(--pmx-color-bg)",
6
+ fg: "var(--pmx-color-fg)",
7
+ accent: "var(--pmx-color-accent)",
8
+ muted: "var(--pmx-color-muted)",
9
+ surface: "var(--pmx-color-surface)",
10
+ border: "var(--pmx-color-border)",
11
+ font: "var(--pmx-font-body)",
12
+ transparent: true,
13
+ }
14
+
15
+ let module: Promise<typeof import("beautiful-mermaid")> | undefined
16
+
17
+ export const beautifulMermaidRenderer: MermaidRenderer = async (code) => {
18
+ module ??= import("beautiful-mermaid")
19
+ const { renderMermaidSVG } = await module
20
+ return renderMermaidSVG(code, options)
21
+ }
22
+
23
+ /** Ready-to-use Mermaid Plugin backed by the lazy-loaded Beautiful Mermaid renderer. */
24
+ export function BeautifulMermaidPlugin() {
25
+ return MermaidPlugin(beautifulMermaidRenderer)
26
+ }
package/client.ts ADDED
@@ -0,0 +1,81 @@
1
+ import "./theme.css"
2
+ import { xIconSvg } from "./icons.ts"
3
+
4
+ const readyClass = "pmx-mermaid-lightbox-ready"
5
+ const openClass = "pmx-mermaid-lightbox-open"
6
+
7
+ declare global {
8
+ interface Window {
9
+ __pathmxMermaidLightboxInstalled?: boolean
10
+ }
11
+ }
12
+
13
+ let dialog: HTMLDialogElement | undefined
14
+ let content: HTMLElement | undefined
15
+ let opener: HTMLElement | undefined
16
+
17
+ function ensureDialog() {
18
+ if (dialog?.isConnected && content) return dialog
19
+
20
+ dialog = document.createElement("dialog")
21
+ dialog.className = "pmx-mermaid-lightbox"
22
+ dialog.dataset.pmxMermaidLightbox = ""
23
+ dialog.setAttribute("aria-label", "Expanded Mermaid diagram")
24
+ dialog.innerHTML = `<div class="pmx-mermaid-lightbox-panel"><button class="pmx-mermaid-lightbox-close" type="button" aria-label="Close expanded diagram" title="Close" autofocus>${xIconSvg}</button><div class="pmx-mermaid-lightbox-content" data-pmx-mermaid-lightbox-content></div></div>`
25
+ content = dialog.querySelector<HTMLElement>(
26
+ "[data-pmx-mermaid-lightbox-content]",
27
+ )!
28
+
29
+ dialog.addEventListener("click", (event) => {
30
+ if (event.target === dialog) dialog?.close()
31
+ })
32
+ dialog.addEventListener("close", () => {
33
+ document.documentElement.classList.remove(openClass)
34
+ content?.replaceChildren()
35
+ const returnTo = opener
36
+ opener = undefined
37
+ if (returnTo?.isConnected) returnTo.focus()
38
+ })
39
+ document.body.append(dialog)
40
+ return dialog
41
+ }
42
+
43
+ function openDiagram(button: Element) {
44
+ const figure = button.closest("[data-pmx-mermaid]")
45
+ const svg = figure?.querySelector(":scope > svg")
46
+ if (!(svg instanceof SVGElement)) return
47
+
48
+ const modal = ensureDialog()
49
+ const clone = svg.cloneNode(true) as SVGElement
50
+ clone.setAttribute("aria-hidden", "true")
51
+ content?.replaceChildren(clone)
52
+ opener = button instanceof HTMLElement ? button : undefined
53
+ document.documentElement.classList.add(openClass)
54
+ if (!modal.open) modal.showModal()
55
+ }
56
+
57
+ if (!window.__pathmxMermaidLightboxInstalled) {
58
+ window.__pathmxMermaidLightboxInstalled = true
59
+ document.documentElement.classList.add(readyClass)
60
+ document.addEventListener("click", (event) => {
61
+ const target = event.target
62
+ if (!(target instanceof Element)) return
63
+
64
+ const close = target.closest(".pmx-mermaid-lightbox-close")
65
+ if (close) {
66
+ dialog?.close()
67
+ return
68
+ }
69
+
70
+ const expand = target.closest(".pmx-mermaid-expand")
71
+ if (expand) openDiagram(expand)
72
+ })
73
+ document.addEventListener("keydown", (event) => {
74
+ if (event.key !== "Escape" || !dialog?.open) return
75
+ event.preventDefault()
76
+ dialog.close()
77
+ })
78
+ document.addEventListener("pmx:render", () => {
79
+ if (dialog?.open) dialog.close()
80
+ })
81
+ }
package/icons.ts ADDED
@@ -0,0 +1,6 @@
1
+ /** Generated by scripts/generate-lucide-icons.ts from @lucide/icons v1.34.0. */
2
+ export const expandIconSvg =
3
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-expand" aria-hidden="true" focusable="false"><path d="m15 15 6 6"></path><path d="m15 9 6-6"></path><path d="M21 16v5h-5"></path><path d="M21 8V3h-5"></path><path d="M3 16v5h5"></path><path d="m3 21 6-6"></path><path d="M3 8V3h5"></path><path d="M9 9 3 3"></path></svg>'
4
+
5
+ export const xIconSvg =
6
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x" aria-hidden="true" focusable="false"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>'
package/index.ts ADDED
@@ -0,0 +1,99 @@
1
+ import {
2
+ isFenceClose,
3
+ matchFenceOpen,
4
+ type AppContext,
5
+ type Plugin,
6
+ } from "@pathmx/core"
7
+ import { expandIconSvg } from "./icons.ts"
8
+
9
+ type Awaitable<T> = T | Promise<T>
10
+ type CompileContext = Parameters<NonNullable<Plugin["precompile"]>>[1]
11
+
12
+ export type MermaidRenderer = (code: string) => Awaitable<string>
13
+
14
+ const SLOT = /<div data-pmx-mermaid-slot="(\d+)"><\/div>/g
15
+ const clientEntry = new URL("./client.ts", import.meta.url)
16
+
17
+ function renderError(error: unknown) {
18
+ return error instanceof Error ? error.message : String(error)
19
+ }
20
+
21
+ async function stashMermaid(
22
+ markdown: string,
23
+ ctx: CompileContext,
24
+ app: AppContext,
25
+ render: MermaidRenderer,
26
+ ) {
27
+ if (!/mermaid/i.test(markdown)) return markdown
28
+
29
+ const lines = markdown.split(/\r?\n/)
30
+ const output: string[] = []
31
+
32
+ for (let index = 0; index < lines.length; index++) {
33
+ const line = lines[index] ?? ""
34
+ const fence = matchFenceOpen(line)
35
+ if (!fence) {
36
+ output.push(line)
37
+ continue
38
+ }
39
+
40
+ let close = index + 1
41
+ while (close < lines.length && !isFenceClose(lines[close]!, fence.marker))
42
+ close++
43
+ if (close === lines.length) {
44
+ output.push(...lines.slice(index))
45
+ break
46
+ }
47
+
48
+ const fenced = lines.slice(index, close + 1)
49
+ const language = fence.info.split(/\s+/, 1)[0]?.toLowerCase()
50
+ if (language !== "mermaid") {
51
+ output.push(...fenced)
52
+ index = close
53
+ continue
54
+ }
55
+
56
+ const code = lines.slice(index + 1, close).join("\n")
57
+ try {
58
+ const svg = await render(code)
59
+ const slot =
60
+ ctx.slots.push(
61
+ `<figure class="pmx-mermaid" data-pmx-mermaid><button class="pmx-mermaid-expand" type="button" aria-label="View diagram larger" aria-haspopup="dialog" title="View diagram larger">${expandIconSvg}</button>${svg}</figure>`,
62
+ ) - 1
63
+ output.push(`${fence.indent}<div data-pmx-mermaid-slot="${slot}"></div>`)
64
+ } catch (error) {
65
+ app.log.warn("render", {
66
+ source: ctx.source.id,
67
+ block: ctx.block?.id,
68
+ error: renderError(error),
69
+ })
70
+ output.push(...fenced)
71
+ }
72
+ index = close
73
+ }
74
+
75
+ return output.join("\n")
76
+ }
77
+
78
+ export function MermaidPlugin(render: MermaidRenderer): Plugin {
79
+ return {
80
+ id: "mermaid",
81
+ precompile(markdown, ctx, app) {
82
+ return stashMermaid(markdown, ctx, app, render)
83
+ },
84
+
85
+ postcompile(html, ctx) {
86
+ if (!html.includes("data-pmx-mermaid-slot")) return html
87
+ return html.replace(
88
+ SLOT,
89
+ (match, index: string) => ctx.slots[Number(index)] ?? match,
90
+ )
91
+ },
92
+
93
+ async page(html, ctx) {
94
+ if (!html.includes("data-pmx-mermaid")) return html
95
+ await ctx.addBrowserBundle(clientEntry, "mermaid-lightbox")
96
+ return html
97
+ },
98
+ }
99
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@pathmx/mermaid",
3
+ "description": "Mermaid diagram plugins and renderers for PathMX.",
4
+ "version": "0.5.0",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/pathmx/pathmx-beta.git",
9
+ "directory": "pathmx/mermaid"
10
+ },
11
+ "homepage": "https://github.com/pathmx/pathmx-beta#readme",
12
+ "bugs": "https://github.com/pathmx/pathmx-beta/issues",
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "registry": "https://registry.npmjs.org/",
16
+ "tag": "beta"
17
+ },
18
+ "type": "module",
19
+ "exports": {
20
+ ".": "./index.ts",
21
+ "./beautiful": "./beautiful.ts"
22
+ },
23
+ "engines": {
24
+ "bun": ">=1.4.0"
25
+ },
26
+ "peerDependencies": {
27
+ "@pathmx/core": "^0.5.0"
28
+ },
29
+ "dependencies": {
30
+ "beautiful-mermaid": "1.1.3"
31
+ }
32
+ }
package/theme.css ADDED
@@ -0,0 +1,120 @@
1
+ .pmx-mermaid {
2
+ position: relative;
3
+ }
4
+
5
+ .pmx-mermaid-expand {
6
+ position: absolute;
7
+ z-index: 1;
8
+ inset-block-start: 0.5rem;
9
+ inset-inline-end: 0.5rem;
10
+ display: none;
11
+ inline-size: 1.75rem;
12
+ block-size: 1.75rem;
13
+ margin-block-end: -1.75rem;
14
+ padding: 0;
15
+ place-items: center;
16
+ border: 1px solid var(--pmx-color-border);
17
+ border-radius: calc(var(--pmx-radius) * 0.75);
18
+ background: color-mix(in oklch, var(--pmx-color-bg) 90%, transparent);
19
+ color: var(--pmx-color-muted);
20
+ box-shadow: 0 1px 4px
21
+ color-mix(in oklch, var(--pmx-color-fg) 12%, transparent);
22
+ cursor: zoom-in;
23
+ }
24
+
25
+ .pmx-mermaid-lightbox-ready .pmx-mermaid-expand {
26
+ display: grid;
27
+ }
28
+
29
+ .pmx-mermaid-expand:hover,
30
+ .pmx-mermaid-expand:focus-visible {
31
+ color: var(--pmx-color-fg);
32
+ border-color: var(--pmx-color-accent);
33
+ }
34
+
35
+ .pmx-mermaid-expand:focus-visible,
36
+ .pmx-mermaid-lightbox-close:focus-visible {
37
+ outline: 2px solid var(--pmx-color-focus);
38
+ outline-offset: 2px;
39
+ }
40
+
41
+ .pmx-mermaid-lightbox {
42
+ inline-size: min(96vw, 100rem);
43
+ max-inline-size: none;
44
+ block-size: min(92vh, 72rem);
45
+ max-block-size: none;
46
+ margin: auto;
47
+ padding: 0;
48
+ overflow: hidden;
49
+ border: 1px solid var(--pmx-color-border);
50
+ border-radius: calc(var(--pmx-radius) * 1.5);
51
+ background: var(--pmx-color-bg);
52
+ color: var(--pmx-color-fg);
53
+ box-shadow: 0 1.5rem 5rem color-mix(in oklch, black 35%, transparent);
54
+ }
55
+
56
+ .pmx-mermaid-lightbox::backdrop {
57
+ background: color-mix(in oklch, black 70%, transparent);
58
+ backdrop-filter: blur(4px);
59
+ }
60
+
61
+ .pmx-mermaid-lightbox-panel {
62
+ position: relative;
63
+ inline-size: 100%;
64
+ block-size: 100%;
65
+ overflow: auto;
66
+ overscroll-behavior: contain;
67
+ }
68
+
69
+ .pmx-mermaid-lightbox-content {
70
+ display: flex;
71
+ box-sizing: border-box;
72
+ min-inline-size: 100%;
73
+ min-block-size: 100%;
74
+ padding: clamp(2.5rem, 5vw, 5rem);
75
+ align-items: safe center;
76
+ justify-content: safe center;
77
+ }
78
+
79
+ .pmx-mermaid-lightbox-content svg {
80
+ display: block;
81
+ flex: none;
82
+ inline-size: min(86rem, 86vw);
83
+ max-inline-size: none;
84
+ block-size: auto;
85
+ }
86
+
87
+ .pmx-mermaid-lightbox-close {
88
+ position: sticky;
89
+ z-index: 2;
90
+ top: 0.75rem;
91
+ left: calc(100% - 3rem);
92
+ display: grid;
93
+ inline-size: 2.25rem;
94
+ block-size: 2.25rem;
95
+ margin-block-end: -3rem;
96
+ padding: 0;
97
+ place-items: center;
98
+ border: 1px solid var(--pmx-color-border);
99
+ border-radius: 50%;
100
+ background: var(--pmx-color-surface);
101
+ color: var(--pmx-color-fg);
102
+ cursor: pointer;
103
+ }
104
+
105
+ .pmx-mermaid-lightbox-open {
106
+ overflow: hidden;
107
+ }
108
+
109
+ @media (max-width: 40rem) {
110
+ .pmx-mermaid-lightbox {
111
+ inline-size: 100vw;
112
+ block-size: 100dvh;
113
+ border: 0;
114
+ border-radius: 0;
115
+ }
116
+
117
+ .pmx-mermaid-lightbox-content {
118
+ padding: 3rem 1rem;
119
+ }
120
+ }