Skip to content

[WIP] debug tree#9

Draft
sharptrip wants to merge 22 commits into
mainfrom
debug-edit
Draft

[WIP] debug tree#9
sharptrip wants to merge 22 commits into
mainfrom
debug-edit

Conversation

@sharptrip
Copy link
Copy Markdown
Owner

@sharptrip sharptrip commented Oct 28, 2022

Cherry-picked Tree-related commits to avoid version bumping since it currently breaks debugging.

yann-achard-MS and others added 16 commits October 28, 2022 12:31
## Description

The new format handles global field keys, and since it avoids using
FieldKeys and object keys, it avoids potential issues with special field
key names (like __proto__ or hasOwnKey etc.) which could collide with JS
members from the prototype.

This change also factors the encoding logic into its own file, which
will help with compatibility and versioning in the future.

## Does this introduce a breaking change?

Yes: the persisted changeset format is updated: Existing documents with
trailing ops will be broken, and collab between before and after
versions will not work.
## Description

Update forest APIs for new cursor API that supports both fields and node
modes.
## Description

Reduces unneeded export (mainly sequence-change-family and misc package
level exports).

Note that FieldKinds namespace is removed from package exports because
it has not undergone any filtering of its exports. The way it's exported
it isn't trivial to remove items that are only needed internally.
…to the Forest (microsoft#12623)

This workaround enables a very simple "notification"-like mechanics to
let clients using the new SharedTree to know that the Forest has been
changed.

It is implemented with a function, which is not exported elsewhere on
purpose, as this totally misuses the invalidation system. All this code
must be removed as soon as a proper notification/eventing system will be
introduced.

Note that `afterChangeToken` is exported into the core (but not to the
tree), as it will be used by `EditableTree` to safely distinguish
"afterChange" and `beforeChange` invalidations. I'd just like to be on a
safe side in case somebody would start using invalidation tokens in the
forest.
## Description

This removes the modules.md. Its content is either already covered in
existing per module documentation, or moved into `feature-libraries`
readme.

The moved content has been edited somewhat, but the scenario list
remains is an unfinished state. It seems better to have it in its new
location that where it was, even if it's not done.
## Description

This adds ITreeSubscriptionCursor.buildFieldAnchor and
ITreeCursor.getFieldPath to support it.

Additionally, this tweaks the Cursor tests cover a few more cases, and
caught and fixes a bug in the handling of fields named __proto__:
object.DefineProperty must be used to set such fields on objects!

This also changes a few uses of Object.getOwnPropertyNames() to
Object.keys() where enumerating fields from map like objects. Both
actually work (as long as there are no non enumerable properties like
methods), but only including enumerable properties seems more
semantically correct and would work in more cases (though we don't care
about those cases, it seems more robust).
## Description

Fix same bug as in microsoft#12687 except in cursorToJsonObject and generic JS
object clone code for perf comparison.

The old code would change the prototype of the object (via the __proto__
field defined on the prototype), while the new code adds an enumerable
own property that shadows __proto__.

benchmarks show a slight slowdown with this change, around 2-3% for
cursorToJsonObject, and around 6% for the raw JS object clone reference.
…#12698)

This PR fixes two things:
1. `getFieldPath` properly returns the parent node index within the
parent path. The issue was caused by the fact that, when being in the
field and using `getOffsetPath`, `this.index` actually gives an
"initial" state of the cursor, as the parent node's index is already
"stacked", so the index must be fetched from the stack instead.
2. It allows to `fork` cursors in field mode by means of `getFieldPath`.
## Description

Fix bug in microsoft#12692 . Old version of the assignment was accidently left in
one spot after restoring it to do performance comparison.
## Description

Cleanup cursor test organization. Adds more test coverage more mapTree and forest cursors.
)

Same as
[microsoft#12488](microsoft#12512), but
using a new cursor API.

## Description

This PR implements `EditableField` as an array-like sequence of nodes
(`EditableTrees`), which
1) replaces handling of sequence fields with arrays,
2) allows to access nodes lazily by their indices with and without
unwrapping, and
3) is a required change to implement editing of `EditableTree`.

## Reviewer Guidance

Everything around "root" probably might be considered as a workaround as
currently `cursor.getPath()` and anchors do not support fields.

Also, it seems that "primaryField" property of `FieldProxyTarget` is
redundant, as `fieldKey` is also there, but it adds clarity, and we
might make use of it when implementing editing.

## Other information or known dependencies

**Step 4** in a series to push code from microsoft#12182 to enable editing of
EditableTree.

[Step 3](microsoft#12428)
[Step 2](microsoft#12306)
[Step 1](microsoft#12300)

Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
@sharptrip sharptrip closed this Oct 31, 2022
@sharptrip sharptrip deleted the debug-edit branch October 31, 2022 09:00
@sharptrip sharptrip restored the debug-edit branch October 31, 2022 09:00
@sharptrip sharptrip reopened this Oct 31, 2022
@sharptrip sharptrip marked this pull request as draft October 31, 2022 09:01
@sharptrip sharptrip changed the title [WIP] Tree: editing with EditableTree [WIP] debug tree Oct 31, 2022
@sharptrip sharptrip changed the base branch from main to editableTree-refactoring October 31, 2022 09:51
@sharptrip sharptrip changed the base branch from editableTree-refactoring to main October 31, 2022 09:51
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