Skip to content

Commit a9a6157

Browse files
Upgrade ng 16-21 compat (#101)
* upd style scope & remove keyframe * bump * Add CLAUDE.md with comprehensive project documentation Provides AI assistants with repository structure, build commands, architecture overview, code style conventions, testing setup, and important development guidelines for the ng-flowchart library. https://claude.ai/code/session_01BU8PBBZH5dS43JHhPS14Xa * Add comprehensive documentation for all major features Documents all undocumented features from michaelmarcuccio's PRs: - Horizontal/vertical orientation with runtime switching - Drag-scroll canvas panning with configurable mouse buttons - Manual connectors (drawing, selecting, deleting arrows between steps) - Connector validation overrides (isConnectorPadEnabled, isValidConnectorDropTarget) - destroyConnectors() public step method - onLinkConnector and afterDeleteConnector callbacks - zoom.skipRender performance optimization - OnPush change detection support - Nested canvas zoom synchronization (setNestedScale) - Angular 17+ REMOVE_STYLES_ON_COMPONENT_DESTROY setup instructions - Updated JSON format with connectors array - Complete changelog from beta.17 through beta.31 - Updated CLAUDE.md with major features summary https://claude.ai/code/session_01BU8PBBZH5dS43JHhPS14Xa * Trim verbose and duplicate sections from README docs - Condense changelog to major feature releases only, removing patch-level bug fix entries that don't help users - Remove Manual Connectors sub-sections (Connector Callbacks, JSON Format, Theming Connectors, Programmatic Deletion) that duplicate content already in the Callbacks, JSON Output, Theming, and Step Methods sections; replaced with cross-reference links - Remove OnPush FAQ entry ("it works" is not a useful FAQ) - Tighten Nested Canvas Zoom FAQ prose https://claude.ai/code/session_01QxztW59tMtjVngA3DtUg1r * Restore original feature list section name Keep original "Current and Upcoming Feature List" heading rather than renaming it to "Feature List" -- minimizes structural changes. https://claude.ai/code/session_01QxztW59tMtjVngA3DtUg1r * Add Angular 14-21 support with dev toolchain upgrade to Angular 19 - Widen library peer dependencies from "14 - 18" to "14 - 21" for @angular/common and @angular/core - Upgrade dev toolchain to Angular 19.2 (TypeScript 5.7, ng-packagr 19.2, zone.js 0.15) for building the library with partial compilation mode - Add explicit standalone: false to all components and directives to accommodate Angular 19's default standalone: true behavior while maintaining NgModule compatibility - Remove deprecated strictMetadataEmit tsconfig option (View Engine remnant) The library continues to use compilationMode: "partial" which produces forward-compatible output that Angular's linker processes at the consumer's build time, ensuring compatibility across Angular 14 through 21. https://claude.ai/code/session_01Cr6QL4PQib5XRZdWkVVgXK * Add Angular compatibility test matrix to CI Split the single build+publish job into three jobs: - build: builds library and uploads artifact - compat-test: matrix job testing Angular 14, 18, and 21 compatibility - publish: gated on compat tests passing Each compat test creates a fresh Angular project at the target version, installs the built library, adds an import, and verifies the build succeeds. https://claude.ai/code/session_01Cr6QL4PQib5XRZdWkVVgXK * Fix CI compat-test workflow bugs found during review Four bugs prevented the matrix tests from actually exercising the library: 1. NgModule sed pattern only matched single-line imports arrays. Angular CLI generates multi-line: imports: [ BrowserModule ] Fixed pattern matches BrowserModule at end of line. 2. Standalone path hardcoded src/app/app.component.ts but Angular 21+ renamed this to src/app/app.ts. Now detects which file exists. 3. npm install of an unpacked directory creates a symlink, which breaks peer-dep resolution by traversing into the library dev's node_modules. Now packs into a .tgz and installs the tarball, mirroring real publish. 4. Angular 14 fresh projects no longer build cleanly in 2026 due to transitive @types/node@25 incompatible with TypeScript 4.7. Bumped oldest matrix entry to Angular 16, which still tests the NgModule path and is closer to what real users have. https://claude.ai/code/session_01Cr6QL4PQib5XRZdWkVVgXK * Narrow supported Angular range to 16-21 Drop Angular 14-15 from peer dependencies. The Angular 14 ecosystem no longer builds cleanly (transitive @types/node@25 incompatible with TypeScript 4.7), and 15 is similarly affected. Angular 16 is the oldest version we can realistically test in CI, so make that the floor. Updates peer deps, README, CLAUDE.md, and removes the stale workflow comment about ecosystem rot. https://claude.ai/code/session_01Cr6QL4PQib5XRZdWkVVgXK * Bump to 1.0.0-beta.32 and gate publish to upstream repo Add a repository guard so the npm publish step only runs on joel-wenzel/ng-flowchart, allowing forks to merge to 1.0.0-beta and run the build + compat-test matrix without triggering a publish. https://claude.ai/code/session_01Cr6QL4PQib5XRZdWkVVgXK * Document Angular 16-21 support range in README The supported-versions line said "Angular 16+", which is open-ended and didn't reflect the upper bound declared in the library peer-deps. Tighten to the actual range and add a beta.32 changelog entry covering Angular 19/20/21 support. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: michaelmarcuccio <michaelmarcuccio@users.noreply.github.com>
1 parent 793c584 commit a9a6157

19 files changed

Lines changed: 13010 additions & 23495 deletions

File tree

.github/workflows/main.yml

Lines changed: 91 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,113 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the 1.0.0-beta branch
84
push:
95
branches: [1.0.0-beta]
106

11-
# Allows you to run this workflow manually from the Actions tab
127
workflow_dispatch:
138

14-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
159
jobs:
16-
# This workflow contains a single job called "build"
1710
build:
18-
# The type of runner that the job will run on
1911
runs-on: ubuntu-latest
20-
21-
# Steps represent a sequence of tasks that will be executed as part of the job
2212
steps:
23-
- uses: actions/setup-node@v3
24-
with:
25-
node-version: 18
26-
registry-url: 'https://registry.npmjs.org'
13+
- uses: actions/checkout@v4
2714

28-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29-
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
3018

31-
# Build
32-
- name: Build Library
19+
- name: Install and Build Library
3320
run: |
3421
npm install
3522
npm run build
3623
24+
- name: Pack Library
25+
run: npm pack
26+
working-directory: dist/ng-flowchart
27+
28+
- name: Upload Library Artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: ng-flowchart-dist
32+
path: dist/ng-flowchart
33+
retention-days: 1
34+
35+
compat-test:
36+
needs: build
37+
runs-on: ubuntu-latest
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
# Oldest supported Angular version
43+
- angular-version: 16
44+
node-version: 18
45+
# Mid-range Angular version
46+
- angular-version: 18
47+
node-version: 20
48+
# Latest supported Angular version
49+
- angular-version: 21
50+
node-version: 22
51+
name: Compat (Angular ${{ matrix.angular-version }})
52+
steps:
53+
- uses: actions/setup-node@v4
54+
with:
55+
node-version: ${{ matrix.node-version }}
56+
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: ng-flowchart-dist
60+
path: ng-flowchart-dist
61+
62+
- name: Create Angular ${{ matrix.angular-version }} Project
63+
run: |
64+
npx -y @angular/cli@${{ matrix.angular-version }} new compat-test \
65+
--minimal --skip-git --skip-tests --defaults
66+
67+
- name: Install Library
68+
working-directory: compat-test
69+
run: npm install ${{ github.workspace }}/ng-flowchart-dist/joelwenzel-ng-flowchart-*.tgz
70+
71+
- name: Add Library Import
72+
working-directory: compat-test
73+
run: |
74+
if [ -f src/app/app.module.ts ]; then
75+
# NgModule-based app (Angular 16): patch app.module.ts
76+
sed -i '1i import { NgFlowchartModule } from "@joelwenzel/ng-flowchart";' src/app/app.module.ts
77+
# imports array spans multiple lines; match BrowserModule at end of line
78+
sed -i 's/^\(\s*\)BrowserModule$/\1BrowserModule, NgFlowchartModule/' src/app/app.module.ts
79+
else
80+
# Standalone app: file is app.ts (Angular 21+) or app.component.ts (Angular 17-20)
81+
if [ -f src/app/app.ts ]; then
82+
APP_FILE=src/app/app.ts
83+
else
84+
APP_FILE=src/app/app.component.ts
85+
fi
86+
sed -i '1i import { NgFlowchartModule } from "@joelwenzel/ng-flowchart";' "$APP_FILE"
87+
sed -i 's/imports: \[/imports: [NgFlowchartModule, /' "$APP_FILE"
88+
fi
89+
90+
- name: Build Project
91+
working-directory: compat-test
92+
run: npx ng build
93+
94+
publish:
95+
needs: [build, compat-test]
96+
runs-on: ubuntu-latest
97+
if: github.repository == 'joel-wenzel/ng-flowchart'
98+
steps:
99+
- uses: actions/setup-node@v4
100+
with:
101+
node-version: 20
102+
registry-url: 'https://registry.npmjs.org'
103+
104+
- uses: actions/download-artifact@v4
105+
with:
106+
name: ng-flowchart-dist
107+
path: ng-flowchart-dist
108+
37109
- name: Publish
38110
run: npm publish --access public
39-
working-directory: dist/ng-flowchart
111+
working-directory: ng-flowchart-dist
40112
env:
41113
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

CLAUDE.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# CLAUDE.md - AI Assistant Guide for ng-flowchart
2+
3+
## Project Overview
4+
5+
**ng-flowchart** is a lightweight Angular library for building drag-and-drop flowcharts. It provides customizable chart behavior, step components, and JSON import/export capabilities. Published as `@joelwenzel/ng-flowchart` on NPM.
6+
7+
- **Angular version:** 18.0.3
8+
- **TypeScript version:** 5.4.5
9+
- **License:** Apache 2.0
10+
11+
## Repository Structure
12+
13+
This is a monorepo containing two Angular projects:
14+
15+
```
16+
projects/
17+
ng-flowchart/ # The library (published to NPM)
18+
src/
19+
lib/
20+
model/ # Core types and Flow API (flow.model.ts)
21+
services/ # Core services (canvas-renderer, dropdata, options, step-manager)
22+
ng-flowchart-arrow/ # SVG arrow connector component
23+
ng-flowchart-connector/ # Manual connector component
24+
ng-flowchart-connector-pad/ # Connection pad component
25+
ng-flowchart-pad-arrow/ # Pad arrow component
26+
ng-flowchart-step/ # Base step component (extendable)
27+
ng-flowchart-canvas.directive.ts # Main canvas directive
28+
ng-flowchart-canvas.service.ts # Canvas state/rendering service
29+
ng-flowchart-step.directive.ts # Step drag directive
30+
ng-flowchart-step-registry.service.ts # Custom step type registry
31+
ng-flowchart.module.ts # NgFlowchartModule
32+
index.ts # Public API surface
33+
assets/
34+
styles.scss # Base library styles
35+
ng-package.json # ng-packagr configuration
36+
workspace/ # Demo application
37+
src/app/
38+
custom-step/ # Example custom step component
39+
form-step/ # Example form step component
40+
nested-flow/ # Example nested flowchart component
41+
app.component.ts # Main demo with all features
42+
```
43+
44+
## Build Commands
45+
46+
| Command | Purpose |
47+
|---------|---------|
48+
| `npm start` | Serve the demo application locally (`ng serve`) |
49+
| `npm run build` | Build library for production (`ng build ng-flowchart --configuration production`) |
50+
| `npm test` | Run unit tests with Karma/Jasmine (`ng test`) |
51+
| `npm run lint` | Run ESLint with auto-fix (`ng lint --fix`) |
52+
| `npm run prettier` | Format all files with Prettier (`npx prettier --write .`) |
53+
| `npm run e2e` | Run end-to-end tests with Protractor (`ng e2e`) |
54+
55+
## Architecture
56+
57+
### Design Pattern
58+
59+
- **Directive-based API:** Core functionality exposed via `NgFlowchartCanvasDirective` (canvas host) and `NgFlowchartStepDirective` (draggable palette items)
60+
- **Service-oriented internals:** Rendering, options, step lifecycle, and drag/drop state are separated into dedicated services
61+
- **Extendable step components:** Users create custom steps by extending `NgFlowchartStepComponent`
62+
- **Tree data structure:** The flow is represented as a linked tree with parent-child relationships
63+
64+
### Key Files
65+
66+
| File | Role |
67+
|------|------|
68+
| `model/flow.model.ts` | Core `NgFlowchart` namespace with `Flow` class, `Options`, `Callbacks`, step/drop types |
69+
| `ng-flowchart-canvas.directive.ts` | Main directive handling drop/drag events, zoom, scrolling |
70+
| `ng-flowchart-canvas.service.ts` | Manages flow state and rendering orchestration |
71+
| `ng-flowchart-step/ng-flowchart-step.component.ts` | Base step component class (extend for custom steps) |
72+
| `ng-flowchart-step-registry.service.ts` | Registry for resolving custom step types during JSON import |
73+
| `services/canvas-renderer.service.ts` | Positioning, layout, and SVG rendering logic |
74+
| `services/step-manager.service.ts` | Step lifecycle (creation, deletion, movement) |
75+
| `services/options.service.ts` | Options management |
76+
| `services/dropdata.service.ts` | Drag/drop transfer state |
77+
| `index.ts` | Public API exports |
78+
79+
### Module Exports
80+
81+
`NgFlowchartModule` exports two directives:
82+
- `NgFlowchartCanvasDirective` - Applied to a container element to create a flowchart canvas
83+
- `NgFlowchartStepDirective` - Applied to elements to make them draggable step sources
84+
85+
### Major Features
86+
87+
- **Horizontal & Vertical Orientation:** `orientation` option (`'VERTICAL'` | `'HORIZONTAL'`) with runtime switching via `setOrientation()`
88+
- **Drag-Scroll:** Canvas panning via configurable mouse buttons (`dragScroll` option)
89+
- **Manual Connectors:** Draw arrows between any two steps independent of the tree structure (`manualConnectors` option). Includes connector pads, selectable/deletable arrows, per-step validation overrides (`isConnectorPadEnabled()`, `isValidConnectorDropTarget()`), and callbacks (`onLinkConnector`, `afterDeleteConnector`)
90+
- **Zoom:** Mouse wheel or manual zoom with `skipRender` performance optimization for large workflows
91+
- **Nested Canvases:** Steps can contain their own flowchart canvases with scale synchronization (`setNestedScale()`)
92+
- **OnPush Change Detection:** Full support for `ChangeDetectionStrategy.OnPush`
93+
- **JSON with Connectors:** Export/import includes both `root` tree and `connectors` array
94+
95+
## Code Style & Conventions
96+
97+
### Formatting (Prettier)
98+
99+
- 2-space indentation, no tabs
100+
- Single quotes for strings
101+
- Semicolons required
102+
- Trailing commas in ES5 positions
103+
- 80 character print width
104+
- Arrow function parens avoided for single params (`avoid`)
105+
- Brackets on same line as opening tag (`bracketSameLine: true`)
106+
107+
### Linting (ESLint)
108+
109+
- Extends: `@angular-eslint/recommended` + `prettier/recommended`
110+
- Component selectors: **kebab-case** with `lib` prefix (e.g., `lib-my-component`)
111+
- Directive selectors: **camelCase** with `lib` prefix (e.g., `libMyDirective`)
112+
- Empty lifecycle methods are allowed (`@angular-eslint/no-empty-lifecycle-method: 0`)
113+
- HTML templates use Angular template linting rules
114+
115+
### TypeScript
116+
117+
- Target: ES2022, Module: ESNext
118+
- Strict Angular compiler options enabled (`strictInjectionParameters`, `strictInputAccessModifiers`, `strictTemplates`)
119+
- `useDefineForClassFields: false` (required for Angular decorator compatibility)
120+
- Path alias: `ng-flowchart` maps to `dist/ng-flowchart/`
121+
122+
### EditorConfig
123+
124+
- UTF-8 charset
125+
- 2-space indentation
126+
- Final newline inserted
127+
- Trailing whitespace trimmed (except `.md` files)
128+
- Single quotes for `.ts` files
129+
130+
## Testing
131+
132+
- **Framework:** Jasmine 5.1.2 + Karma 6.4.3
133+
- **Browser:** Chrome
134+
- **Test files:** Co-located with source using `.spec.ts` suffix
135+
- **Coverage:** Istanbul reporter generating HTML, LCOV, and text-summary in `coverage/ng-flowchart/`
136+
- **Teardown config:** `destroyAfterEach: false`
137+
- Run tests: `npm test`
138+
139+
## CI/CD
140+
141+
GitHub Actions workflow (`.github/workflows/main.yml`):
142+
- Triggers on push to `1.0.0-beta` branch or manual dispatch
143+
- Runs on `ubuntu-latest` with Node 18
144+
- Steps: `npm install` -> `npm run build` -> `npm publish --access public`
145+
- Publishes from `dist/ng-flowchart` to NPM using `NPM_AUTH_TOKEN` secret
146+
147+
## Important Notes for AI Assistants
148+
149+
1. **Library vs Demo:** Changes to the library go in `projects/ng-flowchart/`. The `projects/workspace/` directory is the demo app for testing. Do not confuse the two.
150+
2. **Public API:** Only items exported through `projects/ng-flowchart/src/index.ts` are part of the public API. Internal services should not be exported.
151+
3. **Build before test with demo:** The demo app (`workspace`) imports the library from `dist/ng-flowchart` via the tsconfig path alias. Build the library first (`npm run build`) before serving the demo.
152+
4. **ng-packagr:** The library is packaged with ng-packagr. The `ng-package.json` file controls entry points and assets. SCSS assets are bundled from the `assets/` directory.
153+
5. **Angular version support:** The library supports Angular 16-21 via peer dependencies. Avoid using APIs exclusive to Angular 19+ to maintain backward compatibility.
154+
6. **No standalone components:** The library uses `NgModule` declarations, not standalone components. Follow this pattern for new components.
155+
7. **Custom steps pattern:** Users extend `NgFlowchartStepComponent` and register types via `NgFlowchartStepRegistryService` for JSON serialization/deserialization. Refer to the demo app's `custom-step/`, `form-step/`, and `nested-flow/` for examples.

0 commit comments

Comments
 (0)