Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zakariaf
Copy link
Owner

@zakariaf zakariaf commented Jun 15, 2025

Description

This MR renames the core library class from SvgZoom to SvgToolbelt and its initializer function from initializeSvgZoom to initializeSvgToolbelt across the entire codebase. This change better reflects the library's broader capabilities beyond just zoom. Deprecated aliases for the old names have been added with console warnings to ensure backward compatibility and guide users through the migration. Additionally, new project planning and checklist documents (Improvement-Plan.md, Post-Code-Writing-Checklist.md) have been introduced and referenced in the README.md.

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
    • Note: This is a breaking change due to renaming core exports. However, deprecated aliases (SvgZoom, initializeSvgZoom) have been provided with console warnings to facilitate a smoother transition for users.
  • Documentation update

Changes Made

  • Core Renaming & Aliasing:
    • Renamed SvgZoom class to SvgToolbelt in src/index.ts.
    • Renamed initializeSvgZoom function to initializeSvgToolbelt in src/index.ts.
    • Added deprecated aliases for SvgZoom and initializeSvgZoom that log console warnings upon use.
  • Codebase-wide Updates:
    • Updated all internal references, examples, and usages in src/, demo/, and test/ directories to use the new SvgToolbelt and initializeSvgToolbelt names.
  • Documentation Enhancements:
    • Updated README.md and MIGRATION.md with the new names, updated API references, and migration guidance.
    • Added new Improvement-Plan.md and Post-Code-Writing-Checklist.md files.
    • Incorporated a "Development" section in README.md linking to these new planning and checklist documents.
  • Test Suite Adjustments:
    • Updated all relevant test files in the test/ directory to reflect the renaming.
    • Added specific tests to verify the correct functioning of the deprecated aliases and the emission of their console warnings.

Testing

  • Automated Tests:
    • All existing unit and integration tests were updated and confirmed to pass.
    • New tests were specifically added to cover the deprecated aliases and their associated warning messages.
    • The test suite maintains 100% code coverage.
  • Manual Testing:
    • Verified that all demo pages (demo/index.html, demo/examples/simple.html, demo/examples/multiple.html) function correctly with the new SvgToolbelt naming.
    • Confirmed that using the deprecated SvgZoom aliases works as expected and correctly logs warnings to the console.
  • Environment Tested:
    • Local development environment (macOS, Node.js v20.19.1)
    • Browsers: Chrome, Firefox, Safari (as per standard testing procedure)

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (other than the intentional deprecation warnings for aliases)
  • Bundle size impact is acceptable (renaming has minimal impact; new markdown files do not affect bundle)

Screenshots (if applicable)

N/A

Related Issues

#10

zakariaf added 11 commits June 14, 2025 19:03
Introduces an `isDestroyed` boolean property to `KeyboardFeature`
and `ControlsFeature`. This property is set to `true` in their
respective `destroy()` methods.

This change is necessary to align with existing test assertions
that verify the destroyed state of these features.
- Updated all test files to replace instances of SvgZoom with SvgToolbelt.
- Adjusted initialization and destruction methods accordingly.
- Ensured that all edge cases, error handling, and feature tests reflect the new class name.
- Verified that all functionality remains intact after renaming.
@github-actions
Copy link

size-limit report 📦

Path Size
dist/svg-toolbelt.cjs.production.min.js 3.62 KB (+2.58% 🔺)
dist/svg-toolbelt.esm.js 3.45 KB (+2.56% 🔺)

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @zakariaf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a significant naming change, renaming the core library components from SvgZoom to SvgToolbelt to better represent its feature set. This is a breaking change, accompanied by thorough documentation updates and temporary deprecated aliases to aid migration. Additionally, a new checklist is introduced to standardize post-code-writing quality assurance steps, enhancing the development workflow.

Highlights

  • Core Renaming: The primary class SvgZoom has been renamed to SvgToolbelt and the initialization function initializeSvgZoom is now initializeSvgToolbelt. This is a breaking change reflecting the library's expanded functionality.
  • Backward Compatibility: Deprecated aliases (SvgZoom, initializeSvgZoom) are provided for a smoother transition, logging console warnings when used. They are planned for removal in a future major version.
  • Documentation Updates: The README.md and MIGRATION.md files have been comprehensively updated to reflect the new naming, including examples, API references, and detailed migration steps for various usage patterns (ESM, UMD/IIFE, frameworks).
  • Development Process Improvement: A new Post-Code-Writing-Checklist.md has been added, outlining required steps for code quality, testing, documentation, and build verification before merging changes.
  • Testing & Demos: All test files and demo examples have been updated to use the new SvgToolbelt and initializeSvgToolbelt names, ensuring continued functionality and providing up-to-date usage examples.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully implements the renaming of SvgZoom to SvgToolbelt and initializeSvgZoom to initializeSvgToolbelt, which is a significant step towards aligning the library's name with its expanded functionality. The inclusion of deprecated aliases with console warnings is a good practice for managing this breaking change and providing a smoother migration path for users. The updates to the README.md and the creation of the MIGRATION.md are comprehensive and clearly guide users through the necessary changes. The new Post-Code-Writing-Checklist.md is a valuable addition for ensuring code quality and consistency across future contributions. The test updates correctly reflect the naming changes and include specific tests for the deprecated aliases, which is excellent for verifying backward compatibility and the warning mechanism. The addition of test:coverage and npm audit to the prepublishOnly script enhances the project's quality gates. Overall, this is a well-executed breaking change with thorough documentation and testing updates.

"type-check": "tsc --noEmit",
"prepare": "husky",
"prepublishOnly": "npm run lint && npm run type-check && npm test -- --run && npm run build",
"prepublishOnly": "npm run lint && npm run type-check && npm test -- --run && npm run test:coverage && npm audit && npm run build",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding npm run test:coverage and npm audit to the prepublishOnly script is a good practice to ensure code quality and security before publishing.

"prepublishOnly": "npm run lint && npm run type-check && npm test -- --run && npm run test:coverage && npm audit && npm run build",

Comment on lines +778 to +791
it('should handle SvgToolbelt constructor with no SVG (covers index.ts early return)', () => {
// Test SvgToolbelt specifically (not just SvgEnhancer) with no SVG
const emptyContainer = document.createElement('div');
const svgZoom = new SvgZoom(emptyContainer);
const svgToolbelt = new SvgToolbelt(emptyContainer);

// Should be destroyed and features should be empty
expect(svgZoom.isDestroyed).toBe(true);
expect(Object.keys(svgZoom.features)).toHaveLength(0);
expect(svgToolbelt.isDestroyed).toBe(true);
expect(Object.keys(svgToolbelt.features)).toHaveLength(0);

// Methods should be safe to call even when destroyed
expect(() => svgZoom.zoomIn()).not.toThrow();
expect(() => svgZoom.zoomOut()).not.toThrow();
expect(() => svgZoom.init()).not.toThrow();
expect(() => svgToolbelt.zoomIn()).not.toThrow();
expect(() => svgToolbelt.zoomOut()).not.toThrow();
expect(() => svgToolbelt.init()).not.toThrow();
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test correctly verifies the behavior of the new SvgToolbelt constructor when no SVG is found, ensuring the early return and isDestroyed flag are handled.

@zakariaf zakariaf changed the title Feature/mr0 naming consistency Refactor: Rename SvgZoom to SvgToolbelt and update documentation Jun 15, 2025
@zakariaf zakariaf merged commit 549c1dd into main Jun 15, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants