@zenuml/core 3.32.4 → 3.32.6

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,21 @@
1
+ {
2
+ "name": "Node.js & Browser Tools",
3
+ "image": "mcr.microsoft.com/devcontainers/typescript-node:20",
4
+ "features": {
5
+ "ghcr.io/devcontainers/features/node:1": {
6
+ "version": "none"
7
+ }
8
+ },
9
+ "forwardPorts": [9323],
10
+ "customizations": {
11
+ "vscode": {
12
+ "extensions": [
13
+ "dbaeumer.vscode-eslint",
14
+ "esbenp.prettier-vscode"
15
+ ]
16
+ }
17
+ },
18
+ // Add your source code to the container
19
+ "postCreateCommand": "pnpm install",
20
+ "remoteUser": "node"
21
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,98 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Development Commands
6
+
7
+ - **Start development server**: `pnpm dev` (runs on port 8080)
8
+ - **Build library**: `pnpm build` (builds library with vite.config.lib.ts)
9
+ - **Build site**: `pnpm build:site` (builds demo site with vite.config.ts)
10
+ - **Run tests**: `pnpm test` (runs Vitest unit tests)
11
+ - **Run E2E tests**: `pnpm pw` (runs Playwright tests)
12
+ - **Run E2E tests (CI)**: `pnpm pw:ci` (runs with GitHub reporter for CI)
13
+ - **Open Playwright UI**: `pnpm pw:ui`
14
+ - **Update Playwright snapshots**: `pnpm pw:update`
15
+ - **Install Playwright browsers**: `pnpm pw:install`
16
+ - **Run smoke tests**: `pnpm pw:smoke`
17
+ - **Lint code**: `pnpm eslint` (runs ESLint with auto-fix)
18
+ - **Format code**: `pnpm prettier` (runs Prettier)
19
+ - **Generate ANTLR parser**: `pnpm antlr` (generates JavaScript parser from grammar)
20
+
21
+ ## Project Architecture
22
+
23
+ ZenUML is a JavaScript-based diagramming library for creating sequence diagrams from text definitions. The project has two main parts:
24
+
25
+ ### 1. DSL Parser (ANTLR-based)
26
+
27
+ - **Grammar files**: `src/g4/` contains ANTLR grammar definitions
28
+ - **Generated parser**: `src/generated-parser/` contains generated JavaScript parser
29
+ - **Parser enhancements**: `src/parser/` contains custom functionality layered on top of ANTLR
30
+
31
+ ### 2. React-based Renderer
32
+
33
+ - **Core entry point**: `src/core.tsx` - main library export and ZenUml class
34
+ - **Component structure**: `src/components/` - React components for rendering diagrams
35
+ - **Store management**: `src/store/Store.ts` - Jotai-based state management
36
+ - **Positioning engine**: `src/positioning/` - algorithms for layout and positioning
37
+
38
+ ### Key Components Architecture
39
+
40
+ - **DiagramFrame**: Main container component that orchestrates the entire diagram
41
+ - **SeqDiagram**: Core sequence diagram renderer with layers:
42
+ - **LifeLineLayer**: Renders participants and their lifelines
43
+ - **MessageLayer**: Renders messages and interactions between participants
44
+ - **Statement components**: Individual renderers for different UML elements (interactions, fragments, etc.)
45
+
46
+ ### Parser Architecture
47
+
48
+ The parser uses a two-stage approach:
49
+
50
+ 1. **ANTLR-generated parser**: Converts text to parse tree
51
+ 2. **Custom parser layer**: Transforms parse tree into structured data for rendering
52
+
53
+ Key parser modules:
54
+
55
+ - **Participants.ts**: Manages participant detection and ordering
56
+ - **MessageContext.ts**: Handles message parsing and context
57
+ - **FrameBuilder.ts**: Builds the overall diagram structure
58
+ - **Fragment handling**: Support for UML fragments (alt, opt, loop, par, etc.)
59
+
60
+ ## Build System
61
+
62
+ The project uses Vite with two configurations:
63
+
64
+ - **vite.config.ts**: Development server and demo site build
65
+ - **vite.config.lib.ts**: Library build (ESM and UMD outputs)
66
+
67
+ Output formats:
68
+
69
+ - **ESM**: `dist/zenuml.esm.mjs` for modern bundlers
70
+ - **UMD**: `dist/zenuml.js` for browser scripts
71
+
72
+ ## Testing Strategy
73
+
74
+ - **Unit tests**: Vitest for parser and utility functions
75
+ - **Component tests**: React Testing Library for component logic
76
+ - **E2E tests**: Playwright for full integration testing with visual snapshots
77
+ - **Test files**: Co-located with source files using `.spec.ts` extension
78
+
79
+ ## Key Dependencies
80
+
81
+ - **React 19**: UI framework
82
+ - **ANTLR4**: Parser generation
83
+ - **Jotai**: State management
84
+ - **Tailwind CSS**: Styling framework
85
+ - **html-to-image**: PNG export functionality
86
+ - **Vite**: Build tool and development server
87
+
88
+ ## Package Management
89
+
90
+ Uses pnpm with volta for Node.js version management. Always use `npx pnpm` for the first install.
91
+
92
+ ## Development Notes
93
+
94
+ - The project builds both a library and a demo site
95
+ - Parser generation requires Java and ANTLR4
96
+ - E2E tests use visual snapshots for regression testing
97
+ - The library is published as `@zenuml/core` to npm
98
+ - GitHub Pages deployment is automated via GitHub Actions
@@ -0,0 +1,34 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
+ <title>Nested Interaction with Fragment Test</title>
8
+ <style>
9
+ body {
10
+ margin: 0; /* mostly for demo on mobile */
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div id="diagram" class="diagram">
16
+ <pre class="zenuml" style="margin: 0">
17
+ title Nested Interaction with Fragment and Self-Invocation
18
+ A.Read() {
19
+ B.Submit() {
20
+ Process() {
21
+ if (true) {
22
+ ProcessCallback() {
23
+ A.method
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }</pre
29
+ >
30
+ </div>
31
+ <!-- built files will be auto injected -->
32
+ <script type="module" src="/src/main-cy.ts"></script>
33
+ </body>
34
+ </html>
@@ -0,0 +1,34 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
+ <title>Nested Interaction with Outbound Message and Fragment Test</title>
8
+ <style>
9
+ body {
10
+ margin: 0; /* mostly for demo on mobile */
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div id="diagram" class="diagram">
16
+ <pre class="zenuml" style="margin: 0">
17
+ title Nested Interaction with Outbound Message and Fragment
18
+ A.Read() {
19
+ B.Submit() {
20
+ C->B.method {
21
+ if (true) {
22
+ ProcessCallback() {
23
+ A.method
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }</pre
29
+ >
30
+ </div>
31
+ <!-- built files will be auto injected -->
32
+ <script type="module" src="/src/main-cy.ts"></script>
33
+ </body>
34
+ </html>