Merged
Conversation
Comprehensive audit identifying DRY violations, type safety issues, and maintainability concerns with prioritized refactoring roadmap.
This addresses Critical Issue #1 from the TypeScript audit: - Create src/types/ directory with centralized type definitions: - psd.ts: PSD layer types (SpriteLayer, TilesetLayer, etc.) - plugin.ts: Plugin configuration types - index.ts: Re-exports all types - Add type guards for safe type narrowing: - isSpriteLayer, isTilesetLayer, isZoneLayer, isPointLayer, isGroupLayer - isAtlasSprite, isSpritesheetSprite, isAnimationSprite, isDefaultSprite - Update all modules to use proper types instead of `any`: - PsdToPhaser.ts: Use ProcessedPsdData type - place modules: Use PsdLayer union with type guards - load modules: Use SpriteLayer, TilesetLayer, CategorizedLayers - shared utilities: Use typed parameters - Add public getAllKeys() method to plugin to avoid private member access
Support for layer and group masks exported by psd-to-json with `mask: true` and `maskPath: "masks/layer_mask.png"` properties. Features: - Masks automatically applied during place() for sprites, tiles, and groups - New getMask() method for independent mask retrieval - New applyMask shared utility for consistent mask application - Mask images loaded alongside their parent layers Type updates: - Add mask and maskPath properties to BaseLayer - Add hasMask() type guard function - Export new types and guards from types/index.ts Usage: - Automatic: Just call place() - masks are applied automatically - Manual: Use psd.getMask(scene, 'psdKey', 'layerPath') to get the bitmap mask for independent use
Addresses Critical Issue #2 from the TypeScript audit: The addDebugVisualization function was copy-pasted across 4 files with only color variations. Changes: - Rewrote shared/debugVisualizer.ts with a consolidated API - Removed duplicate addDebugVisualization functions from: - sprites/index.ts (was 38 lines) - tiles.ts (was 34 lines) - zones.ts (was 46 lines) - points.ts (was 28 lines) - Total: ~146 lines of duplicated code removed The new shared utility: - Takes consistent parameters (scene, plugin, group, options) - Supports all layer types with appropriate visualizations: - sprite: green rectangle - tileset: red rectangle - zone: blue polygon/rectangle - point: red circle - group: yellow rectangle - Handles type-specific label positioning - Exports DEBUG_COLORS constant for customization
- Create shared spriteSetup.ts with common utilities: - setupSprite() for single sprite configuration - setupSpriteGroup() for group configuration - applyMaskToGroupChildren() for mask application - getTextureKey() for texture key resolution - setupSpriteInstance() for individual instances - Refactor all four sprite placement files to use shared utilities - Bump version to 0.0.6 in package.json and console log
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.
No description provided.