Skip to content

Add dynamic mapping support and improve state synchronization - #8

Merged
HMAZonderland merged 15 commits into
mainfrom
feat/dynamic-mapping
Aug 4, 2025
Merged

Add dynamic mapping support and improve state synchronization#8
HMAZonderland merged 15 commits into
mainfrom
feat/dynamic-mapping

Conversation

@HMAZonderland

@HMAZonderland HMAZonderland commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Implement dynamic mapping with re-evaluation on selection changes
  • Add comprehensive documentation with consistent bicycle examples
  • Clean up dead code and simplify README files

Changes

Dynamic mapping implementation

  • Add hasDynamicMapping() detection to AttributeService
  • Re-evaluate entire mapping when selections change
  • Update context with current selections for dynamic functions
  • Preserve existing attribute references (no recreation)
  • Fix lint error by extracting getVisibleNodesForAttribute() helper

Documentation overhaul

  • Create mapping-concept.md with bicycle configurator example
  • Create static-mapping-examples.md for simple configurations
  • Create dynamic-mapping-examples.md showing frame size dependencies
  • Use consistent bicycle example throughout all docs
  • Add component positioning concept (parts move with frame geometry)

Code cleanup

  • Remove unused Attribute.select() method
  • Remove SNAPSHOT_DEVELOPED event (never used)
  • Remove MessageType type alias (redundant)
  • Delete attribute.test.ts (tests removed method)

README improvements

  • Simplify README.md to show only high-level mapping concepts
  • Move detailed explanations to dedicated documentation
  • Simplify README.npm.md to prevent sync issues
  • Fix "Zero dependencies" to "Minimal dependencies"

Test plan

  • All existing tests pass
  • Dynamic mapping re-evaluates correctly
  • Lint and build succeed
  • Documentation is consistent and clear

- Add DynamicValue<T> type for static or function-based values
- Make containsDynamicValues public in MappingValidator
- Implement re-evaluation of dynamic mappings on selection changes
- Add hasDynamicMapping() method to detect dynamic configurations
- Add comprehensive tests for dynamic mapping behavior

Dynamic mappings allow attribute values to depend on other selections,
enabling complex product configurations where available options change
based on previous choices.
- Add basic state sync tests for server state changes
- Add edge case tests for mapping changes and state updates
- Add 3D viewer synchronization tests for onChange callbacks
- Add UI synchronization tests for live value updates
- Add edge case tests for onChange callback behavior

These tests ensure proper separation between client mutations
and server state updates, validating that state only changes
via STATE_CHANGED events from the server.
- Remove unused Attribute.select() method (only used in tests)
- Remove unused getAttributeValueForNode() private method
- Remove unused SNAPSHOT_DEVELOPED event name
- Remove unused MessageType type alias
- Remove associated test files for unused methods

These methods and types were identified as dead code through
static analysis and were not used anywhere in production code.
- Fix max-depth lint error in updateCurrentState by extracting helper method
- Fix import formatting in snapshot test file
- Apply prettier formatting to snapshot demo HTML
- Add new node test helpers for creating test nodes
- Update create-element helper for better test support
- Update DOM helpers for improved test utilities
- Update package dependencies
- Update pnpm lock file
- Fix setUiConfig to properly accept Partial<UIConfig>
- Fix setViewerConfig to properly accept Partial<ViewerConfig>
- This allows partial updates instead of requiring full config objects
- Update camera config messaging tests
- Update camera reset tests
- Update camera tests
- Update snapshot photo tests
- Update snapshot message handler tests
- Update snapshot tests

These updates ensure all tests work correctly with the
refactored code and new type definitions.
@HMAZonderland HMAZonderland self-assigned this Aug 1, 2025
@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown

Size Change: +2.42 kB (+1.67%)

Total Size: 147 kB

Filename Size Change
./dist/virtualdisplay.client.cjs.js 43.1 kB +662 B (+1.56%)
./dist/virtualdisplay.client.es.js 60.9 kB +1.1 kB (+1.83%)
./dist/virtualdisplay.client.umd.js 43.2 kB +664 B (+1.56%)

compressed-size-action

- Add mapping-concept.md explaining core concepts with bicycle example
- Add static-mapping-examples.md for simple configurations
- Add dynamic-mapping-examples.md for advanced dependencies
- Use consistent bicycle configurator example throughout
- Include positioning concept where components move with frame size
- Remove unused select() method from Attribute class
- Remove SNAPSHOT_DEVELOPED event name (never used)
- Remove MessageType type alias (redundant)
- Remove attribute.test.ts file (method no longer exists)
- Clean up codebase by removing unused functionality
- Simplify README.md mapping section to show only high-level concepts
- Move detailed mapping explanations to dedicated documentation
- Simplify README.npm.md to minimal content with GitHub reference
- Fix 'Zero dependencies' claim to 'Minimal dependencies'
- Prevent future sync issues between NPM and GitHub READMEs
- Simplify README.md mapping section to show only high-level concepts
- Move detailed mapping explanations to dedicated documentation
- Simplify README.npm.md to minimal content with GitHub reference
- Fix 'Zero dependencies' claim to 'Minimal dependencies'
- Prevent future sync issues between NPM and GitHub READMEs
- Apply prettier formatting to dynamic-mapping-examples.md
- Move 'Why do we use mapping' section above example in mapping-concept.md
- Improve document flow and readability
@github-actions

github-actions Bot commented Aug 4, 2025

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 90.59% 1194 / 1318
🔵 Statements 90.59% 1194 / 1318
🔵 Functions 86.26% 157 / 182
🔵 Branches 95.11% 331 / 348
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/attributes/attribute-service.ts 96.11% 94.02% 95.45% 96.11% 51-54, 186-187, 250-251
src/attributes/attribute.ts 94.44% 100% 90.9% 94.44% 52-53
src/attributes/mapping-types.ts 100% 100% 100% 100%
src/attributes/mapping-validator.ts 83.33% 80% 100% 83.33% 63, 72-73, 76-77, 81-82, 85-86
src/events/event-names.ts 100% 100% 100% 100%
src/messaging/message-types.ts 100% 100% 100% 100%
src/ui/virtualdisplay-viewer-service.ts 77.55% 100% 64.28% 77.55% 103-105, 111-113, 130-136, 142-148, 154-155
Generated in workflow #19 for commit 4262ed2 by the Vitest Coverage Report Action

- Rename files to remove 'examples' suffix for cleaner URLs
- Add conceptual introductions to static and dynamic mapping guides
- Improve navigation with contextual links between documents
- Remove duplicate content between guides
- Clarify when to use static vs dynamic mapping
- Maintain consistent bicycle example throughout
- Use sentence case for all headings
- Simplify README files to prevent sync issues
- Remove trailing punctuation from headings
- Fix line length violations
- Add blank lines around lists
- Maintain consistent formatting
@HMAZonderland
HMAZonderland merged commit 456ec47 into main Aug 4, 2025
3 checks passed
@HMAZonderland
HMAZonderland deleted the feat/dynamic-mapping branch August 4, 2025 19:37
HMAZonderland added a commit that referenced this pull request Aug 5, 2025
The previous PR #8 included:
- Dynamic mapping support with DynamicValue<T> type
- Automatic re-evaluation of mappings on selection changes
- Comprehensive documentation for static and dynamic mapping
- Dead code removal from attribute system
- Bug fixes for setConfig parameter types
HMAZonderland added a commit that referenced this pull request Aug 5, 2025
The previous PR #8 included:
- Dynamic mapping support with DynamicValue<T> type
- Automatic re-evaluation of mappings on selection changes
- Comprehensive documentation for static and dynamic mapping
- Dead code removal from attribute system
- Bug fixes for setConfig parameter types
HMAZonderland pushed a commit that referenced this pull request Aug 5, 2025
## [3.7.0](v3.6.0...v3.7.0) (2025-08-05)

### ✨ Features

* dynamic mapping - proxy release ([#9](#9)) ([a95f0e7](a95f0e7)), closes [#8](#8)

### 🔧 Maintenance

* various fixes and documentation updates ([#7](#7)) ([325150b](325150b))
@HMAZonderland

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 3.7.0 🎉

The release is available on:

Your pull request is in this release 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant