How closetgeekshow/axure-to-mermaid works
Project Type and Purpose
• This is a front-end bookmarklet tool (an open-source browser plugin) that runs entirely in the browser.
File-Structure Analysis
Top-level:
• build/
– embedAssets.js: embeds CSS/HTML assets into the bookmarklet bundle
– processBookmarklet.js: bundles and minifies code for distribution
• src/
– components/: React-like UI modules
· AxureToMermaid.js – orchestrates data extraction from Axure
· Toolbar.js – renders the floating toolbar and export buttons
– store/:
– config/:
· buttonConfig.js, constants.js, embeddedAssets.js – UI settings and injected assets
– index.js – entry point, bootstraps the bookmarklet injection
• package.json, .gitignore, README.md, LICENSE, plan/…
README Insights
• The tool loads dependencies (js-base64, pako, matcha-css) at run-time from CDN to keep the bookmarklet small.
• It relies on Axure’s global object ($axure) at runtime.
• No server component; all logic runs in the browser.
Core System Components & Interactions
A. Components:
1. Bookmarklet Loader (index.js + build scripts)
2. UI Layer (Toolbar.js)
3. Data Extraction (AxureToMermaid.js)
5. State Store (MermaidStore.js + EventEmitter)
6. Export & Sharing (button handlers that call CDN services or clipboard APIs)
7. Config & Assets (buttonConfig, constants, embeddedAssets)
8. Utils (cssLoader for injecting styles, dom helpers)
B. Relationships / Data Flow:
• User clicks bookmarklet → Bookmarklet Loader injects CSS & Toolbar component into page
• Toolbar UI emits events (start conversion, export) via EventEmitter → Store updates
• MermaidStore holds markup → Toolbar presents it and export options
C. Architectural Patterns / Principles:
• Modular componentization: UI vs processing vs store vs utils
• Unidirectional data flow: actions → store → UI updates
• Dependency injection via CDN to minimize bundle size
• Separation of build-time (build/) vs run-time code (src/)
D. Key Technologies / Libraries:
• Vanilla JS modules (ES6)
• EventEmitter pattern for pub/sub
• CDN-loaded: js-base64, pako, matcha-css
• Build tools: Node scripts in build/, package.json scripts
• Blue rectangles for internal modules (components, store, utils)
• Injection flow (Bookmarklet → Toolbar)
• Data flow (AxureToMermaid → SitemapProcessor → MermaidStore → Toolbar)
• Related modules (e.g., src/components) with a shaded border or container