refactor: introduce internal extension mechanism for BPMN extensions#3519
Merged
Conversation
|
🎊 PR Preview c966a8d has been successfully built and deployed to https://process-analytics-bpmn-visualization-js-doc_preview-pr-3519.surge.sh 🕐 Build time: 0.012s 🤖 By surge-preview |
|
🎊 PR Preview c966a8d has been successfully built and deployed to https://process-analytics-bpmn-visualization-js-demo_preview-pr-3519.surge.sh 🕐 Build time: 0.01s 🤖 By surge-preview |
Add a generic mechanism for managing BPMN extensions in bpmn-visualization, and migrate the existing
hardcoded BPMN in Color implementation as its first user. The scope is an internal refactoring to validate
the extension mechanism: existing public interfaces of DiagramConverter, StyleComputer and BpmnVisualization
are unchanged, the built-in extension is hardcoded in the components that consume it, and external injection
of extensions is deferred to follow-up work.
Code:
- New extension point interfaces in src/component/extension/extension-points.ts:
- ParsingExtensionPoint: onShapeDeserialized, onEdgeDeserialized, hasLabelExtensionData
- StyleExtensionPoint: enrichShapeStyle, enrichEdgeStyle, enrichMessageFlowIconStyle
- New BPMN in Color extension at src/component/extension/bpmn-in-color/:
- types.ts: module augmentation on JSON model (BPMNShape, BPMNEdge, BPMNLabel) and on internal model
(ShapeExtensions, EdgeExtensions, LabelExtensions). Uses `export {}` so the file remains a module
under any tsconfig setting (verbatimModuleSyntax-safe).
- parsing-extension.ts: logic moved from setColorExtensionsOnShape/Edge in DiagramConverter.
- style-extension.ts: color-to-mxGraph-style mapping moved from StyleComputer, including the previously
hardcoded message flow icon stroke color.
- ShapeExtensions / EdgeExtensions / LabelExtensions converted from type aliases to empty interfaces.
- DiagramConverter and StyleComputer call registered extension points; no BPMN in Color logic remains in
the core.
Documentation:
- New ADR at docs/contributors/adr/001-bpmn-extensions-management.md documenting the data layers, the
pipeline phases, the two extension point interfaces, the scope of this refactoring vs. follow-up work,
the migration plan and open questions.
- docs/contributors/README.md references the new ADR.
Tests:
- 30 dedicated unit tests at test/unit/component/extension/bpmn-in-color/ covering parsing (BPMN in Color
spec attributes, bpmn.io fallbacks, spec-over-fallback priority, label color, hasLabelExtensionData
table-driven cases, non-pollution of extensions when source values are absent) and style (shape, edge,
message flow icon, pool/lane swimlane fill color, font color via label).
- All existing tests pass without modification.
41204e0 to
805080e
Compare
|
Added example of DF-BPMN extension for data modeling. [skip ci]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Overview
This PR introduces a generic mechanism for managing BPMN extensions in
bpmn-visualization, validated by migrating the existing hardcoded BPMN in Color implementation. The scope is an internal refactoring to validate the extension mechanism: existing public interfaces ofDiagramConverter,StyleComputerandBpmnVisualizationare unchanged, the built-in extension is hardcoded in the components that consume it, and external injection (a publicbpmnExtensionsoption) is deferred to follow-up work.ADR
docs/contributors/adr/001-bpmn-extensions-management.mddocuments the design:BPMNShape,BPMNEdge,BPMNLabel) and the internal model (ShapeExtensions,EdgeExtensions,LabelExtensions) — migrated from type aliases to empty interfaces.ParsingExtensionPoint(onShapeDeserialized,onEdgeDeserialized,hasLabelExtensionData) andStyleExtensionPoint(enrichShapeStyle,enrichEdgeStyle,enrichMessageFlowIconStyle).BpmnExtensiongrouping interface, no publicbpmnExtensions: [...]option, noRenderingExtensionPoint, no icon painter injection. These are listed as deferred and explain consequences such as the asymmetricignoreBpmnColorsgating (parsing always runs, only style is gated).enrichnaming, icon painter strategy).Code
src/component/extension/extension-points.ts— the two interfaces above, marked@internaland@since 0.48.0.src/component/extension/bpmn-in-color/— 4 files:types.ts(module augmentations on JSON + internal models, usingexport {}so the file remains a module underverbatimModuleSyntax: true),parsing-extension.ts,style-extension.ts.DiagramConverterandStyleComputerto call registered extensions instead of containing BPMN in Color logic. The dedicated functions and color-specific branches are removed from the core, including the message flow icon stroke color which previously still readedge.extensions.strokeColordirectly. An inline comment in each file explains why the extension list is hardcoded.ShapeExtensions/EdgeExtensions/LabelExtensionsconverted from type aliases to empty interfaces (allow module augmentation by extensions).Test plan
tsc --noEmitpassesnpm run lint-checkcleannpm run test:unit— 3152 unit tests pass (including the 30 new dedicated ones)npm run all— to be confirmed by CIOut of scope (follow-up work)
RenderingExtensionPointand the Bonita Connector implementation as a validation target.BpmnExtensiongrouping interface and publicbpmnExtensions: [...]registration API.ignoreBpmnColorsgating (currently the parsing extension always runs; only style is gated).Bundle size comparison
NPM bundle size comparison between two commits on
docs/adr_bpmn_extension_management(raw bytes).80a7bdc94(chore(deps): bump fast-xml-parser from 5.7.1 to 5.8.0)c966a8d97(Merge branch 'master' into docs/adr_bpmn_extension_management)NPM package bundles
Source:
npm run build-bundles+stat --format=%son each bundle.Summary
All three bundles grow slightly. The minified and full bundles gain ~0.11% (a bit over 1 kB each),
while the ESM bundle gains +1 825 bytes (+0.88%) — proportionally the largest increase since the
ESM bundle is the smallest baseline.