Complete declarative prop coverage for Two.js objects - #37
Conversation
Adds a full Two.js v0.8.23 property matrix (library export + docs) and tests for declarative coverage across all components. This update exposes missing prop union types publicly, adds support for `mask`/`clip`/`strokeAttenuation` on key shape components, enables `origin` ergonomics on rectangle-derived components (`Vector`, object, tuple), and allows `Sprite.src` to accept `Two.Texture` for better parity with upstream Two.js APIs.
There was a problem hiding this comment.
🟡 Changes recommended
The new public “property list” exports currently include internal/read-only fields and there is at least one avoidable runtime import that should be corrected before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR implements Issue #30 by bringing react-two.js component props into closer declarative parity with Two.js v0.8.23, adding a checked property matrix, documentation, and targeted tests to validate both typing and runtime behavior.
Changes:
- Expanded declarative prop coverage across shapes (e.g.,
mask,clip,strokeAttenuation) and addedoriginergonomics for rectangle-derived effects plusTwo.Texturesupport forSprite.src. - Introduced a typed
PROPERTY_MATRIX/SUPPORTED_TWO_VERSIONcontract and documented supported vs intentionally-omitted properties. - Added compile-time and runtime tests to validate prop typing, reconciliation, and re-render updates.
File summaries
| File | Description |
|---|---|
| tests/propertyMatrix.test.tsx | Adds compile-time + runtime tests validating the new prop surface and PROPERTY_MATRIX. |
| lib/propertyMatrix.ts | Defines the typed property matrix and omission categories for Two.js v0.8.23. |
| docs/property-matrix.md | Documents the matrix, additions, omissions, and ref-based escape hatches. |
| lib/main.ts | Re-exports prop types, shared property lists, and the property matrix APIs from the library entry. |
| lib/Properties.ts | Adds translation and exports static property arrays for element/shape/gradient props. |
| lib/Path.tsx | Extends PathProps with mask, clip, and strokeAttenuation. |
| lib/Group.tsx | Extends and exports GroupProps to include mask, beginning, ending, strokeAttenuation. |
| lib/SVG.tsx | Reuses GroupProps for SVG prop parity and exports SVGProps. |
| lib/Text.tsx | Exports TextProps and extends it with mask, clip, strokeAttenuation. |
| lib/Points.tsx | Exports PointsProps and adds strokeAttenuation. |
| lib/Rectangle.tsx | Adds declarative origin support (including tuple/object-literal ergonomics) and exports RectangleProps. |
| lib/Image.tsx | Adds origin support and exports ImageProps. |
| lib/Sprite.tsx | Adds origin support, widens src to accept Texture, and exports SpriteProps. |
| lib/ImageSequence.tsx | Adds origin support and exports ImageSequenceProps. |
| lib/Polygon.tsx | Exports PolygonProps and adds radius. |
| lib/RoundedRectangle.tsx | Exports RoundedRectangleProps. |
| lib/Star.tsx | Exports StarProps. |
| lib/Line.tsx | Exports LineProps. |
| lib/Circle.tsx | Exports CircleProps. |
| lib/Ellipse.tsx | Exports EllipseProps. |
| lib/ArcSegment.tsx | Exports ArcSegmentProps. |
| lib/LinearGradient.tsx | Exports LinearGradientProps. |
| lib/RadialGradient.tsx | Exports RadialGradientProps. |
Review details
- Files reviewed: 23/23 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Remove internal/read-only properties ('renderer', 'worldMatrix') from ElementProps, ShapeProps, ELEMENT_PROPERTIES, and SHAPE_PROPERTIES
- Extract shared applyOrigin helper and OriginProp type, reusing across Rectangle, Image, Sprite, and ImageSequence
- Use type-only import for GroupProps in lib/SVG.tsx
- Add unit and type tests for applyOrigin, OriginProp, and property exclusions
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive, covered by extensive compile-time/runtime tests, and the new property matrix + documentation align with the stated parity goals for Two.js v0.8.23.
Review details
- Files reviewed: 23/23 changed files
- Comments generated: 0 new
- Review effort level: Lite
Walkthrough: Complete Declarative Prop Coverage for Two.js Objects (Issue #30)
Completed declarative prop coverage and parity for Two.js objects in
react-two.json branchfix_github_issue_30against Two.jsv0.8.23.Summary of Changes
1. Component Props & Parity Updates
Pathand Path-derived shapes (Circle,Ellipse,Line,Polygon,RoundedRectangle,Star,ArcSegment,Rectangle,Image,Sprite,ImageSequence):mask,clip, andstrokeAttenuation.radiustoPolygonProps.PathProps,CircleProps,EllipseProps,LineProps,PolygonProps,RoundedRectangleProps,StarProps,ArcSegmentProps).GroupandSVG:mask,beginning,ending, andstrokeAttenuation.opacityandvisibletoSVGProps.GroupPropsandSVGProps.Text:mask,clip, andstrokeAttenuation.TextProps.Points:strokeAttenuation.PointsProps.Rectangle,Image,Sprite,ImageSequence:originsupport acrossRectangle,Image,Sprite, andImageSequence.Two.Vector, object literals{ x?: number; y?: number }, and tuples[number, number].TypeError: this._origin.bind is not a function.RectangleProps,ImageProps,SpriteProps,ImageSequenceProps.Sprite.src:Sprite.srctype to acceptstring | Texture(allowingTwo.Texturedirectly in addition to string URLs).Properties.ts:translationtoShapeProps.ELEMENT_PROPERTIES,SHAPE_PROPERTIES,GRADIENT_PROPERTIES.LinearGradient,RadialGradient,Texture:LinearGradientProps,RadialGradientProps,TextureProps.main.ts:2. Checked Property Matrix & Documentation
PROPERTY_MATRIXmapping every exported component (19 components total) against supported Two.jsv0.8.23properties.read-only,renderer-internal,managed-by-react, orimperative-method.RefPath,RefRectangle,RefSprite, etc.) anduseFrame.3. Verification & Automated Tests
mask,clip,strokeAttenuation,origin(Vector | { x, y } | [x, y]),Sprite.src(string | Two.Texture), andbeginning/ending.maskandcliponPath,Group,Text, andRectangle.strokeAttenuationonPath,Group,Text,Points,Circle.beginningandendingonGroupandSVG.originsupport acrossRectangle,Image,Sprite,ImageSequencewithTwo.Vector,{ x, y }, and[x, y].Sprite.srcwithTwo.Texture.originandstrokeAttenuation.Canvas.Test Results
Build and lint verification:
npm run build: built production bundle + generated.d.tsdeclaration files successfully.npm run lint: clean pass with 0 errors and 0 warnings.