Skip to content

Conversation

@marklundin
Copy link
Contributor

@marklundin marklundin commented Aug 12, 2025

marklundin and others added 7 commits August 12, 2025 12:04
* Implement script asset error handling and UI improvements. Added a new error container for invalid script attributes in the inspector, enhanced error logging in the script parsing process, and updated the code editor integration to handle metadata. (#1361)

* updated types

* Enhance SerializableParsingError type by adding 'type' property to categorize errors in the ESM script worker.

* Update error handling in ESM script worker to include 'type' property and default name fallback for SerializableParsingError.

* updates

* reverting the integration model markers

* reverting model marker data in editor

* Enhance script asset inspector with improved error handling and styling

* Introduced new color variables for status indicators and updated styles for error and warning messages in the script asset inspector.
* Refactored the script attribute display logic to handle inline error and warning messages more effectively, allowing for better user interaction with clickable error links.
* Updated tooltip functionality to provide detailed information about script attributes, including warnings and errors, enhancing the overall user experience in the editor.
* Improved error logging in the console for better debugging and user guidance.

* Add icons for warning and error indicators in script asset inspector

* linting

* remove console open

* linting

* Update @playcanvas/attribute-parser to version 1.10.1 in package.json and package-lock.json

* refactor: streamline script attribute display logic in ScriptAssetInspector

- Renamed parameter in _displayScriptAttributes method for clarity.
- Removed unused variable assignment and debug logging for cleaner code.
- Updated link method to directly pass script data to _displayScriptAttributes.

* remove redundant error messages. These are now in editor console

* feat: implement message-based communication for code editor initialization

- Added postMessage call in CodeEditor to signal 'start' event.
- Introduced message event listener in toolbar-code-editor to trigger asset selection when 'start' message is received.

* fix: enhance message handling for code editor initialization

- Updated postMessage to use the opener's origin for security.
- Refactored message event listener in toolbar-code-editor to remove itself after handling the 'start' message.

* fix: remove redundant status error call in console event handler

* refactor: improve error handling and styling in ScriptAssetInspector

- Enhanced the display of script errors with clickable labels for better user interaction.
- Updated SCSS styles for error labels to ensure consistent hover effects.
- Removed redundant code and improved clarity in error message handling.

* reverting the asset inspector changes. Separate PR
* Refactor JSDoc handling in attribute autofill logic

* Introduced JSDocUtils class for managing JSDoc operations, including analysis, creation, and cleaning of JSDoc blocks.
* Enhanced modifyJSDocAttribute function to handle adding and removing JSDoc attributes more effectively.
* Updated code lens provider to support new JSDoc actions for attributes, including adding slider functionality.
* Improved error handling in the ESM script worker by clarifying error property names in documentation.

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: Copilot <[email protected]>

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: Copilot <[email protected]>

* Fix model markers issues

* Fix regex in JSDocUtils.cleanSingleLineJSDoc to correctly handle attribute tags without redundant replacements.

* Remove commented-out code in attribute autofill commands for cleaner implementation.

* Clean up comments in attribute autofill logic for improved readability.

* Refactor comments in attribute autofill to enhance clarity and remove unnecessary lines.

* Enhance attribute autofill logic by caching last-known lenses to prevent flicker during analysis. Introduce a no-op command for inactive lenses and update the handling of active/inactive lenses based on model attributes.

* Refactor attribute autofill implementation to use TypeScript types for improved type safety and clarity. Update function signatures and interfaces, and streamline the handling of JSDoc attributes.

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

* Refactor JSDoc utility methods in attribute-autofill.ts to use TypeScript types for parameters and return values. Simplify JSDoc analysis logic and update related function calls to improve clarity and maintainability.

* Refactor JSDoc utility methods in attribute-autofill.ts to explicitly define return types for improved type safety and clarity.

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

* Update src/code-editor/monaco/intellisense/attribute-autofill.ts

Co-authored-by: KPal <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: KPal <[email protected]>
* Enhance tooltips and attribute warnings in inspector

* Added optional warnings section to tooltips for better user feedback.
* Implemented warning styling for attributes in the inspector to highlight potential issues.

* Update src/editor/inspector/components/script.ts

Co-authored-by: Copilot <[email protected]>

* fix: update postMessage to use window.opener.origin

* refactor: enhance validation error handling in Script Inspector

- Introduced a new error container for displaying validation issues related to script attributes.
- Improved the logic for clearing and rendering validation issues, ensuring a more user-friendly experience.
- Updated the ESM script worker to filter out invalid attributes more effectively.
- Enhanced error logging in the console for better debugging and user guidance.

* style: update warning styling in Script Asset Inspector

- Refactored the warning label styles to enhance visibility.
- Introduced a new color for the .pcui-label class to align with the warning status.
- Removed unused icon styling for a cleaner codebase.

* refactor: clean up type assertions and improve code readability

- Removed unnecessary type assertions in attribute autofill and script inspector components for better type safety.
- Simplified condition checks for warnings in tooltips to leverage optional chaining.
- Enhanced clarity by directly accessing properties without casting to 'any'.

* refactor: streamline tooltip handling in AttributesInspector

- Removed the warnings section from the tooltipRefItem function and integrated it directly into the AttributesInspector.
- Enhanced tooltip item creation to conditionally append warnings if provided, improving code organization and readability.

* refactor: update type definitions and improve error handling

- Changed the interface 'Fix' to a type definition for better clarity in attribute autofill.
- Simplified the handling of potential undefined values in the ScriptInspector by using optional chaining and nullish coalescing.
- Enhanced the SerializableParsingError type to include a 'code' property and refined the structure for improved error handling in the ESM script worker.

---------

Co-authored-by: Copilot <[email protected]>
@marklundin marklundin marked this pull request as ready for review August 13, 2025 10:17
@marklundin marklundin requested a review from kpal81xd August 13, 2025 10:18
Copy link
Contributor

@kpal81xd kpal81xd left a comment

Choose a reason for hiding this comment

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

🎉

@marklundin marklundin merged commit d6ff2fd into main Aug 13, 2025
3 checks passed
@marklundin marklundin deleted the feat-attr-parsing-ux branch August 13, 2025 10:39
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.

3 participants