Add alpha splice method to TreeArrayNode#26740
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new splice API to TreeArrayNode to support combined remove/insert operations with Array.prototype.splice-like behavior, including negative start indices and optional deleteCount, and updates the public API surface accordingly.
Changes:
- Adds
TreeArrayNode.spliceto the public interface and implements it inarrayNode.ts(wrapping hydrated edits in a transaction). - Adds unit tests covering several
splicescenarios. - Updates API reports and adds a changeset entry documenting the new API.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/dds/tree/src/test/simple-tree/node-kinds/arrayNode.spec.ts | Adds new splice test cases for array nodes |
| packages/dds/tree/src/simple-tree/node-kinds/array/arrayNode.ts | Adds splice to the interface and implements the method |
| packages/dds/tree/api-report/tree.public.api.md | Updates public API report to include splice |
| packages/dds/tree/api-report/tree.legacy.public.api.md | Updates legacy public API report to include splice |
| packages/dds/tree/api-report/tree.legacy.beta.api.md | Updates legacy beta API report to include splice |
| packages/dds/tree/api-report/tree.beta.api.md | Updates beta API report to include splice |
| packages/dds/tree/api-report/tree.alpha.api.md | Updates alpha API report to include splice |
| .changeset/plain-tires-melt.md | Adds a minor changeset describing the new splice method and usage |
5839e19 to
f5e0b9d
Compare
jzaffiro
left a comment
There was a problem hiding this comment.
Small nit but approved for docs
CraigMacomber
left a comment
There was a problem hiding this comment.
Despite having approval from an API Reviewer, this has not been api reviewed (GitHub doesn't let people approve for a subset of their review groups), so I'm going to use my requesting of changes as a placeholder for the need for an API review. If approving for API review, feel free to dismiss this.
5984a6b to
96a5ad9
Compare
09f5f0e to
29e654b
Compare
noencke
left a comment
There was a problem hiding this comment.
Implementation looks good to me
| true, | ||
| options ?? {}, | ||
| ); | ||
| ) as unknown as ArrayNodeCustomizableSchemaAlpha< |
There was a problem hiding this comment.
Is there any way to avoid this cast? My guess is no, but curious what @CraigMacomber thinks
…pes.ts Co-authored-by: Noah Encke <78610362+noencke@users.noreply.github.com>
Abe27342
left a comment
There was a problem hiding this comment.
Did not review the tree code.
Approving for merge-tree, which doesn't actually have any changes we care about in this PR. Talked with Brennan offline and this is probably just a sticky GH check.
Also approving for API council as the PR contains only alpha API changes. I can see that this is also a sticky check from a previous revision that touched more broadly visible API files.
Co-authored-by: jzaffiro <110866475+jzaffiro@users.noreply.github.com>
Api, tree, and docs approval received after Api moved from public to alpha
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
## Summary Adds `splice` method to a new alpha `TreeArrayNode` interface, `TreeArrayNodeAlpha`, that follows `Array.prototype.splice` semantics. Supports removing and inserting items in a single opertaion, with optional `deleteCount` and negative `start` indices. Wraps remove + insert in a transaction for hydrated nodes to enable atomic undo/redo. Users opt into using the new api by doing `asAlpha(<TreeArrayNode>)` which then allows them to use splice and also still interact with other non-alpha `TreeArrayNodes` --------- Co-authored-by: Noah Encke <78610362+noencke@users.noreply.github.com> Co-authored-by: jzaffiro <110866475+jzaffiro@users.noreply.github.com>
Summary
Adds
splicemethod to a new alphaTreeArrayNodeinterface,TreeArrayNodeAlpha, that followsArray.prototype.splicesemantics. Supports removing and inserting items in a single opertaion, with optionaldeleteCountand negativestartindices. Wraps remove + insert in a transaction for hydrated nodes to enable atomic undo/redo. Users opt into using the new api by doingasAlpha(<TreeArrayNode>)which then allows them to use splice and also still interact with other non-alphaTreeArrayNodes