@fluidframework/tree 2.0.0-rc.3.0.2 → 2.0.0-rc.4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +35 -2
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +17 -0
- package/README.md +17 -5
- package/api-report/tree.api.md +66 -62
- package/dist/beta.d.ts +5 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/core/change-family/changeFamily.d.ts +2 -1
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +2 -1
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
- package/dist/core/rebase/revisionTagCodec.js.map +1 -1
- package/dist/core/rebase/types.d.ts +1 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +12 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +2 -2
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +16 -9
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/rebase/verifyChangeRebaser.js +1 -1
- package/dist/core/rebase/verifyChangeRebaser.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +3 -3
- package/dist/core/schema-stored/schema.js +3 -3
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.js +1 -0
- package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/dist/core/tree/treeTextFormat.d.ts +2 -0
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/domains/index.d.ts +0 -1
- package/dist/domains/index.d.ts.map +1 -1
- package/dist/domains/index.js +1 -5
- package/dist/domains/index.js.map +1 -1
- package/dist/domains/json/jsonCursor.d.ts.map +1 -1
- package/dist/domains/json/jsonCursor.js +2 -1
- package/dist/domains/json/jsonCursor.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdCodec.js +2 -2
- package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/dist/feature-libraries/contextuallyTyped.d.ts.map +1 -1
- package/dist/feature-libraries/contextuallyTyped.js +1 -1
- package/dist/feature-libraries/contextuallyTyped.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +2 -2
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts +27 -0
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -0
- package/dist/feature-libraries/default-schema/schemaChecker.js +120 -0
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -0
- package/dist/feature-libraries/deltaUtils.d.ts +2 -2
- package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/dist/feature-libraries/deltaUtils.js +2 -2
- package/dist/feature-libraries/deltaUtils.js.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.js +1 -1
- package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +12 -19
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +15 -29
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -13
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -10
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +10 -40
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -6
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +7 -30
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js +5 -5
- package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +5 -5
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -5
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +1 -0
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -10
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +4 -3
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +16 -9
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +2 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +23 -8
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +145 -117
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/node-key/index.d.ts +1 -1
- package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
- package/dist/feature-libraries/node-key/index.js +1 -2
- package/dist/feature-libraries/node-key/index.js.map +1 -1
- package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -8
- package/dist/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
- package/dist/feature-libraries/node-key/nodeKey.js +1 -9
- package/dist/feature-libraries/node-key/nodeKey.js.map +1 -1
- package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +20 -2
- package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
- package/dist/feature-libraries/node-key/nodeKeyManager.js +27 -5
- package/dist/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts +2 -2
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +85 -63
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
- package/dist/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
- package/dist/feature-libraries/schema-aware/schemaAware.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts +3 -4
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +46 -48
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/format.d.ts +40 -40
- package/dist/feature-libraries/sequence-field/invert.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +20 -20
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/markQueue.d.ts +1 -3
- package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/markQueue.js +2 -3
- package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js +5 -5
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.d.ts +1 -2
- package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +51 -52
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +2 -2
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +8 -0
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -0
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +63 -0
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +2 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +22 -27
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +7 -7
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +10 -10
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +28 -32
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/valueUtilities.d.ts +1 -2
- package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/valueUtilities.js +7 -25
- package/dist/feature-libraries/valueUtilities.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +5 -1
- package/dist/shared-tree/defaultCommitEnricher.d.ts +91 -0
- package/dist/shared-tree/defaultCommitEnricher.d.ts.map +1 -0
- package/dist/shared-tree/defaultCommitEnricher.js +121 -0
- package/dist/shared-tree/defaultCommitEnricher.js.map +1 -0
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +2 -4
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +6 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +11 -9
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +24 -0
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -0
- package/dist/shared-tree/sharedTreeChangeEnricher.js +65 -0
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -0
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +12 -3
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +83 -7
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +208 -16
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +39 -18
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +7 -9
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/treeView.d.ts +2 -4
- package/dist/shared-tree/treeView.d.ts.map +1 -1
- package/dist/shared-tree/treeView.js +3 -4
- package/dist/shared-tree/treeView.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +22 -2
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +18 -12
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/commitEnricher.d.ts +35 -0
- package/dist/shared-tree-core/commitEnricher.d.ts.map +1 -0
- package/dist/{domains/nodeKey/index.d.ts → shared-tree-core/commitEnricher.js} +3 -2
- package/dist/shared-tree-core/commitEnricher.js.map +1 -0
- package/dist/shared-tree-core/editManager.d.ts +8 -5
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +11 -3
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +22 -7
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormat.d.ts +6 -7
- package/dist/shared-tree-core/editManagerFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/index.d.ts +1 -0
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +12 -4
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +12 -5
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +50 -15
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +20 -6
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +252 -234
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +3 -11
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +84 -133
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/{lib/feature-libraries/flex-tree → dist/simple-tree}/nodeKeys.d.ts +10 -11
- package/dist/simple-tree/nodeKeys.d.ts.map +1 -0
- package/{lib/domains/nodeKey/index.js → dist/simple-tree/nodeKeys.js} +3 -2
- package/dist/simple-tree/nodeKeys.js.map +1 -0
- package/dist/simple-tree/objectNode.d.ts +16 -7
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +66 -56
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts +1 -1
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +7 -6
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/proxyBinding.d.ts +2 -2
- package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
- package/dist/simple-tree/proxyBinding.js +2 -2
- package/dist/simple-tree/proxyBinding.js.map +1 -1
- package/dist/simple-tree/schemaFactory.d.ts +24 -17
- package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/schemaFactory.js +46 -61
- package/dist/simple-tree/schemaFactory.js.map +1 -1
- package/dist/simple-tree/schemaFactoryRecursive.d.ts +2 -2
- package/dist/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/schemaFactoryRecursive.js +2 -2
- package/dist/simple-tree/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +45 -22
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +23 -9
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +2 -2
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +5 -6
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +12 -4
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js +41 -30
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/{treeApi.d.ts → treeNodeApi.d.ts} +18 -5
- package/dist/simple-tree/treeNodeApi.d.ts.map +1 -0
- package/dist/simple-tree/{treeApi.js → treeNodeApi.js} +62 -24
- package/dist/simple-tree/treeNodeApi.js.map +1 -0
- package/dist/simple-tree/types.d.ts +63 -0
- package/dist/simple-tree/types.d.ts.map +1 -1
- package/dist/simple-tree/types.js +109 -1
- package/dist/simple-tree/types.js.map +1 -1
- package/dist/simple-tree/typesUnsafe.d.ts +2 -2
- package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/typesUnsafe.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +12 -14
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/typeboxBrand.d.ts +3 -3
- package/dist/util/typeboxBrand.d.ts.map +1 -1
- package/dist/util/typeboxBrand.js +1 -1
- package/dist/util/typeboxBrand.js.map +1 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/docs/.attachments/merge-semantics.drawio +835 -0
- package/docs/.attachments/ms-set-color-red-and-blue.png +0 -0
- package/docs/.attachments/ms-set-color-red-then-blue.png +0 -0
- package/docs/.attachments/ms-set-color-red.png +0 -0
- package/docs/SharedTree Philosophy.md +319 -0
- package/docs/main/merge-semantics.md +529 -0
- package/lib/beta.d.ts +5 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +2 -1
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +2 -1
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/revisionTagCodec.d.ts.map +1 -1
- package/lib/core/rebase/revisionTagCodec.js.map +1 -1
- package/lib/core/rebase/types.d.ts +1 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +10 -0
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +2 -2
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +17 -10
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/rebase/verifyChangeRebaser.js +1 -1
- package/lib/core/rebase/verifyChangeRebaser.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +3 -3
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.js +1 -0
- package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/lib/core/tree/treeTextFormat.d.ts +2 -0
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/domains/index.d.ts +0 -1
- package/lib/domains/index.d.ts.map +1 -1
- package/lib/domains/index.js +0 -1
- package/lib/domains/index.js.map +1 -1
- package/lib/domains/json/jsonCursor.d.ts.map +1 -1
- package/lib/domains/json/jsonCursor.js +2 -1
- package/lib/domains/json/jsonCursor.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdCodec.js +2 -2
- package/lib/feature-libraries/changeAtomIdCodec.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/lib/feature-libraries/contextuallyTyped.d.ts.map +1 -1
- package/lib/feature-libraries/contextuallyTyped.js +1 -1
- package/lib/feature-libraries/contextuallyTyped.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +2 -2
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts +27 -0
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -0
- package/lib/feature-libraries/default-schema/schemaChecker.js +114 -0
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -0
- package/lib/feature-libraries/deltaUtils.d.ts +2 -2
- package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/lib/feature-libraries/deltaUtils.js +3 -3
- package/lib/feature-libraries/deltaUtils.js.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.js +1 -1
- package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +12 -19
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +15 -29
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -13
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -10
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +10 -39
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -6
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +7 -29
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js +5 -5
- package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +5 -5
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +3 -3
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +1 -0
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -10
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +4 -3
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +17 -10
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +23 -8
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +147 -119
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/node-key/index.d.ts +1 -1
- package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
- package/lib/feature-libraries/node-key/index.js +1 -1
- package/lib/feature-libraries/node-key/index.js.map +1 -1
- package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -8
- package/lib/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
- package/lib/feature-libraries/node-key/nodeKey.js +0 -8
- package/lib/feature-libraries/node-key/nodeKey.js.map +1 -1
- package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +20 -2
- package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
- package/lib/feature-libraries/node-key/nodeKeyManager.js +27 -6
- package/lib/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts +2 -2
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +86 -64
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-aware/schemaAware.d.ts +1 -1
- package/lib/feature-libraries/schema-aware/schemaAware.d.ts.map +1 -1
- package/lib/feature-libraries/schema-aware/schemaAware.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts +3 -4
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +46 -48
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/format.d.ts +40 -40
- package/lib/feature-libraries/sequence-field/invert.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +20 -20
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/markQueue.d.ts +1 -3
- package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/markQueue.js +2 -3
- package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js +5 -5
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.d.ts +1 -2
- package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +51 -52
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +2 -2
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +8 -0
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -0
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +59 -0
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +2 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +2 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +23 -28
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +7 -7
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +10 -10
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +28 -32
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/valueUtilities.d.ts +1 -2
- package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/valueUtilities.js +1 -18
- package/lib/feature-libraries/valueUtilities.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +5 -1
- package/lib/shared-tree/defaultCommitEnricher.d.ts +91 -0
- package/lib/shared-tree/defaultCommitEnricher.d.ts.map +1 -0
- package/lib/shared-tree/defaultCommitEnricher.js +117 -0
- package/lib/shared-tree/defaultCommitEnricher.js.map +1 -0
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +2 -4
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +6 -7
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +13 -11
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +24 -0
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -0
- package/lib/shared-tree/sharedTreeChangeEnricher.js +61 -0
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -0
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +12 -3
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +82 -7
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +208 -16
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +37 -17
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +8 -10
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/treeView.d.ts +2 -4
- package/lib/shared-tree/treeView.d.ts.map +1 -1
- package/lib/shared-tree/treeView.js +3 -4
- package/lib/shared-tree/treeView.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +22 -2
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +18 -12
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/commitEnricher.d.ts +35 -0
- package/lib/shared-tree-core/commitEnricher.d.ts.map +1 -0
- package/{src/domains/nodeKey/index.ts → lib/shared-tree-core/commitEnricher.js} +2 -2
- package/lib/shared-tree-core/commitEnricher.js.map +1 -0
- package/lib/shared-tree-core/editManager.d.ts +8 -5
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +13 -5
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +22 -7
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormat.d.ts +6 -7
- package/lib/shared-tree-core/editManagerFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/index.d.ts +1 -0
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +12 -4
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +12 -5
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +50 -15
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +20 -6
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +252 -235
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +3 -11
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +84 -132
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/{dist/feature-libraries/flex-tree → lib/simple-tree}/nodeKeys.d.ts +10 -11
- package/lib/simple-tree/nodeKeys.d.ts.map +1 -0
- package/lib/{domains/nodeKey/index.d.ts → simple-tree/nodeKeys.js} +2 -2
- package/lib/simple-tree/nodeKeys.js.map +1 -0
- package/lib/simple-tree/objectNode.d.ts +16 -7
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +65 -56
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts +1 -1
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +2 -1
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/proxyBinding.d.ts +2 -2
- package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
- package/lib/simple-tree/proxyBinding.js +2 -2
- package/lib/simple-tree/proxyBinding.js.map +1 -1
- package/lib/simple-tree/schemaFactory.d.ts +24 -17
- package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/schemaFactory.js +47 -62
- package/lib/simple-tree/schemaFactory.js.map +1 -1
- package/lib/simple-tree/schemaFactoryRecursive.d.ts +2 -2
- package/lib/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/schemaFactoryRecursive.js +3 -3
- package/lib/simple-tree/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +45 -22
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +24 -8
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +2 -2
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +5 -6
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +12 -4
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js +40 -30
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/{treeApi.d.ts → treeNodeApi.d.ts} +18 -5
- package/lib/simple-tree/treeNodeApi.d.ts.map +1 -0
- package/lib/simple-tree/{treeApi.js → treeNodeApi.js} +64 -27
- package/lib/simple-tree/treeNodeApi.js.map +1 -0
- package/lib/simple-tree/types.d.ts +63 -0
- package/lib/simple-tree/types.d.ts.map +1 -1
- package/lib/simple-tree/types.js +106 -0
- package/lib/simple-tree/types.js.map +1 -1
- package/lib/simple-tree/typesUnsafe.d.ts +2 -2
- package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/typesUnsafe.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +12 -14
- package/lib/treeFactory.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/typeboxBrand.d.ts +3 -3
- package/lib/util/typeboxBrand.d.ts.map +1 -1
- package/lib/util/typeboxBrand.js +1 -1
- package/lib/util/typeboxBrand.js.map +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +25 -25
- package/src/codec/codec.ts +6 -4
- package/src/core/change-family/changeFamily.ts +2 -1
- package/src/core/forest/README.md +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/rebase/changeRebaser.ts +7 -1
- package/src/core/rebase/index.ts +1 -0
- package/src/core/rebase/revisionTagCodec.ts +1 -0
- package/src/core/rebase/types.ts +17 -0
- package/src/core/rebase/utils.ts +23 -15
- package/src/core/rebase/verifyChangeRebaser.ts +4 -4
- package/src/core/schema-stored/schema.ts +4 -4
- package/src/core/tree/anchorSet.ts +1 -1
- package/src/core/tree/detachedFieldIndexCodec.ts +1 -0
- package/src/core/tree/treeTextFormat.ts +2 -0
- package/src/domains/index.ts +0 -2
- package/src/domains/json/jsonCursor.ts +2 -5
- package/src/feature-libraries/changeAtomIdCodec.ts +2 -2
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -1
- package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +2 -2
- package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
- package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +8 -5
- package/src/feature-libraries/contextuallyTyped.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +2 -4
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -6
- package/src/feature-libraries/default-schema/index.ts +0 -1
- package/src/feature-libraries/default-schema/schemaChecker.ts +140 -0
- package/src/feature-libraries/deltaUtils.ts +3 -12
- package/src/feature-libraries/editableTreeBinder.ts +1 -1
- package/src/feature-libraries/flex-tree/context.ts +19 -35
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +19 -17
- package/src/feature-libraries/flex-tree/index.ts +0 -2
- package/src/feature-libraries/flex-tree/lazyField.ts +10 -54
- package/src/feature-libraries/flex-tree/lazyNode.ts +11 -44
- package/src/feature-libraries/flex-tree/utilities.ts +5 -6
- package/src/feature-libraries/index.ts +2 -4
- package/src/feature-libraries/mitigatedChangeFamily.ts +8 -1
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +18 -15
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +33 -26
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +33 -11
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +209 -209
- package/src/feature-libraries/node-key/index.ts +0 -1
- package/src/feature-libraries/node-key/nodeKey.ts +0 -9
- package/src/feature-libraries/node-key/nodeKeyManager.ts +41 -6
- package/src/feature-libraries/optional-field/optionalField.ts +112 -94
- package/src/feature-libraries/schema-aware/schemaAware.ts +3 -1
- package/src/feature-libraries/sequence-field/compose.ts +40 -96
- package/src/feature-libraries/sequence-field/invert.ts +20 -47
- package/src/feature-libraries/sequence-field/markQueue.ts +1 -5
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +5 -10
- package/src/feature-libraries/sequence-field/rebase.ts +42 -139
- package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +3 -3
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +87 -0
- package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +2 -0
- package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +40 -32
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +7 -13
- package/src/feature-libraries/sequence-field/utils.ts +22 -46
- package/src/feature-libraries/valueUtilities.ts +2 -22
- package/src/index.ts +5 -4
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/defaultCommitEnricher.ts +176 -0
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/schematizingTreeView.ts +9 -13
- package/src/shared-tree/sharedTree.ts +18 -10
- package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -0
- package/src/shared-tree/sharedTreeChangeEnricher.ts +87 -0
- package/src/shared-tree/sharedTreeChangeFamily.ts +124 -8
- package/src/shared-tree/treeApi.ts +284 -46
- package/src/shared-tree/treeCheckout.ts +17 -17
- package/src/shared-tree/treeView.ts +3 -16
- package/src/shared-tree-core/branch.ts +49 -12
- package/src/shared-tree-core/commitEnricher.ts +39 -0
- package/src/shared-tree-core/editManager.ts +32 -15
- package/src/shared-tree-core/editManagerCodecs.ts +23 -7
- package/src/shared-tree-core/index.ts +2 -0
- package/src/shared-tree-core/messageCodecs.ts +18 -4
- package/src/shared-tree-core/sharedTreeCore.ts +82 -18
- package/src/simple-tree/arrayNode.ts +411 -334
- package/src/simple-tree/index.ts +3 -2
- package/src/simple-tree/mapNode.ts +120 -169
- package/src/{feature-libraries/flex-tree → simple-tree}/nodeKeys.ts +10 -20
- package/src/simple-tree/objectNode.ts +128 -98
- package/src/simple-tree/proxies.ts +2 -2
- package/src/simple-tree/proxyBinding.ts +5 -3
- package/src/simple-tree/schemaFactory.ts +64 -96
- package/src/simple-tree/schemaFactoryRecursive.ts +8 -6
- package/src/simple-tree/schemaTypes.ts +70 -18
- package/src/simple-tree/toFlexSchema.ts +9 -5
- package/src/simple-tree/toMapTree.ts +71 -29
- package/src/simple-tree/{treeApi.ts → treeNodeApi.ts} +91 -48
- package/src/simple-tree/types.ts +160 -1
- package/src/simple-tree/typesUnsafe.ts +2 -2
- package/src/treeFactory.ts +12 -15
- package/src/util/idAllocator.ts +1 -1
- package/src/util/nestedMap.ts +1 -1
- package/src/util/typeboxBrand.ts +3 -3
- package/src/util/utils.ts +4 -4
- package/dist/domains/nodeKey/index.d.ts.map +0 -1
- package/dist/domains/nodeKey/index.js +0 -12
- package/dist/domains/nodeKey/index.js.map +0 -1
- package/dist/domains/nodeKey/nodeKeySchema.d.ts +0 -30
- package/dist/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
- package/dist/domains/nodeKey/nodeKeySchema.js +0 -36
- package/dist/domains/nodeKey/nodeKeySchema.js.map +0 -1
- package/dist/feature-libraries/flex-tree/nodeKeys.d.ts.map +0 -1
- package/dist/feature-libraries/flex-tree/nodeKeys.js +0 -24
- package/dist/feature-libraries/flex-tree/nodeKeys.js.map +0 -1
- package/dist/simple-tree/treeApi.d.ts.map +0 -1
- package/dist/simple-tree/treeApi.js.map +0 -1
- package/lib/domains/nodeKey/index.d.ts.map +0 -1
- package/lib/domains/nodeKey/index.js.map +0 -1
- package/lib/domains/nodeKey/nodeKeySchema.d.ts +0 -30
- package/lib/domains/nodeKey/nodeKeySchema.d.ts.map +0 -1
- package/lib/domains/nodeKey/nodeKeySchema.js +0 -33
- package/lib/domains/nodeKey/nodeKeySchema.js.map +0 -1
- package/lib/feature-libraries/flex-tree/nodeKeys.d.ts.map +0 -1
- package/lib/feature-libraries/flex-tree/nodeKeys.js +0 -20
- package/lib/feature-libraries/flex-tree/nodeKeys.js.map +0 -1
- package/lib/simple-tree/treeApi.d.ts.map +0 -1
- package/lib/simple-tree/treeApi.js.map +0 -1
- package/src/domains/nodeKey/fence.json +0 -5
- package/src/domains/nodeKey/nodeKeySchema.ts +0 -44
package/.eslintrc.cjs
CHANGED
|
@@ -14,7 +14,7 @@ module.exports = {
|
|
|
14
14
|
rules: {
|
|
15
15
|
"@typescript-eslint/no-namespace": "off",
|
|
16
16
|
"@typescript-eslint/no-empty-interface": "off",
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
// This package is build with noUnusedLocals disabled for a specific use case (see note in tsconfig.json),
|
|
19
19
|
// but should reject other cases using this rule:
|
|
20
20
|
"@typescript-eslint/no-unused-vars": [
|
|
@@ -25,8 +25,12 @@ module.exports = {
|
|
|
25
25
|
caughtErrorsIgnorePattern: "^_",
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// TODO: Remove this override once dependency on eslint-config-fluid has been updated to 5.2.0+
|
|
29
30
|
"import/order": "off",
|
|
31
|
+
|
|
32
|
+
// TODO: Remove these overrides once this config has been updated to extend the "strict" base config.
|
|
33
|
+
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
30
34
|
},
|
|
31
35
|
overrides: [
|
|
32
36
|
{
|
|
@@ -39,4 +43,33 @@ module.exports = {
|
|
|
39
43
|
},
|
|
40
44
|
},
|
|
41
45
|
],
|
|
46
|
+
settings: {
|
|
47
|
+
"import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
|
|
48
|
+
"import/parsers": {
|
|
49
|
+
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
|
|
50
|
+
},
|
|
51
|
+
"import/resolver": {
|
|
52
|
+
typescript: {
|
|
53
|
+
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
|
|
54
|
+
conditionNames: [
|
|
55
|
+
"allow-ff-test-exports",
|
|
56
|
+
|
|
57
|
+
// Default condition names below, see https://www.npmjs.com/package/eslint-import-resolver-typescript#conditionnames
|
|
58
|
+
"types",
|
|
59
|
+
"import",
|
|
60
|
+
|
|
61
|
+
// APF: https://angular.io/guide/angular-package-format
|
|
62
|
+
"esm2020",
|
|
63
|
+
"es2020",
|
|
64
|
+
"es2015",
|
|
65
|
+
|
|
66
|
+
"require",
|
|
67
|
+
"node",
|
|
68
|
+
"node-addons",
|
|
69
|
+
"browser",
|
|
70
|
+
"default",
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
42
75
|
};
|
package/.vscode/settings.json
CHANGED
|
@@ -12,5 +12,8 @@
|
|
|
12
12
|
],
|
|
13
13
|
"mochaExplorer.configFile": ".mocharc.cjs",
|
|
14
14
|
"mochaExplorer.timeout": 999999,
|
|
15
|
+
// This extension appears to invoke mocha programmatically, meaning that the enablement of this option in the common
|
|
16
|
+
// mocha test config isn't sufficient; it also needs to be enabled here.
|
|
17
|
+
"mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
|
|
15
18
|
"cSpell.words": ["deprioritized", "endregion", "insertable", "reentrantly", "unhydrated"],
|
|
16
19
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.4.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Deprecated members of IFluidHandle are split off into new IFluidHandleInternal interface [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
|
|
8
|
+
|
|
9
|
+
Split IFluidHandle into two interfaces, `IFluidHandle` and `IFluidHandleInternal`.
|
|
10
|
+
Code depending on the previously deprecated members of IFluidHandle can access them by using `toFluidHandleInternal` from `@fluidframework/runtime-utils/legacy`.
|
|
11
|
+
|
|
12
|
+
External implementation of the `IFluidHandle` interface are not supported: this change makes the typing better convey this using the `ErasedType` pattern.
|
|
13
|
+
Any existing and previously working, and now broken, external implementations of `IFluidHandle` should still work at runtime, but will need some unsafe type casts to compile.
|
|
14
|
+
Such handle implementation may break in the future and thus should be replaced with use of handles produced by the Fluid Framework client packages.
|
|
15
|
+
|
|
16
|
+
- Minor API fixes for "@fluidframework/tree" package. [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
|
|
17
|
+
|
|
18
|
+
Changes constructor for `FieldSchema` from public to private. Users should call `makeFieldSchema` to create instance of `FieldSchema`.
|
|
19
|
+
|
|
3
20
|
## 2.0.0-rc.3.0.0
|
|
4
21
|
|
|
5
22
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [tree](<https://en.wikipedia.org/wiki/Tree_(data_structure)>) data structure for the [Fluid Framework](https://fluidframework.com/).
|
|
4
|
+
|
|
5
|
+
The contents of this package are also reported as part of the [`fluid-framework` package](https://www.npmjs.com/package/fluid-framework) which provides an alternative way to consume the functionality from this package.
|
|
6
|
+
|
|
7
|
+
[SharedTree Philosophy](./docs/SharedTree%20Philosophy.md) covers the goals of the SharedTree project,
|
|
8
|
+
and some of the implications of those goals for developers working on this package.
|
|
4
9
|
|
|
5
10
|
## Status
|
|
6
11
|
|
|
@@ -12,7 +17,13 @@ Notable consideration that early adopters should be wary of:
|
|
|
12
17
|
- SharedTree currently has unbounded memory growth:
|
|
13
18
|
- Removed content is retained forever.
|
|
14
19
|
- Accessing an `EditableField` object (from its parent, e.g., with `getField`) in a loop will leak unbounded memory.
|
|
15
|
-
- All changes are atomized by the `visitDelta` function.
|
|
20
|
+
- All changes are atomized by the `visitDelta` function.
|
|
21
|
+
This means that, when inserting/removing/moving 2 contiguous nodes, the `visitDelta` function will call the `DeltaVisitor` twice (once for each node) instead of once for both nodes.
|
|
22
|
+
Change notification consumers that are downstream from the `DeltaVisitor` will therefore also see those changes as atomized.
|
|
23
|
+
- Some documentation (such as this readme and [the roadmap](docs/roadmap.md)) are out of date.
|
|
24
|
+
The [API documentation](https://fluidframework.com/docs/api/v2/tree) which is derived from the documentation comments in the source code should be more up to date.
|
|
25
|
+
|
|
26
|
+
More details on the development status of various features can be found in the [roadmap](docs/roadmap.md).
|
|
16
27
|
|
|
17
28
|
<!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
|
|
18
29
|
|
|
@@ -89,11 +100,12 @@ This tree serves to get these feature into the hands of users much faster than c
|
|
|
89
100
|
|
|
90
101
|
This package can be developed using any of the [regular workflows for working on Fluid Framework](../../../README.md) and/or its Client release group of packages, but for work only touching the tree package, there is an optional workflow that might be more ergonomic:
|
|
91
102
|
|
|
103
|
+
- Follow the [Setup and Building](../../../README.md#setup-and-building) instructions.
|
|
92
104
|
- Open the [.vscode/Tree.code-workspace](.vscode/Tree.code-workspace) in VS Code.
|
|
93
105
|
This will recommend a test runner extension, which should be installed.
|
|
94
|
-
- Build the
|
|
95
|
-
- After editing the tree project, run `npm run build` in
|
|
96
|
-
- Run tests using the "Testing" side panel in VS Code, or using the inline `Run | Debug` buttons which should show up above tests in the source:
|
|
106
|
+
- Build the the tree package as normal (for run example: `pnpm i && pnpm run build` in the `tree` directory).
|
|
107
|
+
- After editing the tree project, run `npm run build` (still in the `tree`) directory.
|
|
108
|
+
- Run and debug tests using the "Testing" side panel in VS Code, or using the inline `Run | Debug` buttons which should show up above tests in the source:
|
|
97
109
|
both of these are provided by the mocha testing extension thats recommended by the workspace.
|
|
98
110
|
Note that this does not build the tests, so always be sure to build first.
|
|
99
111
|
|
package/api-report/tree.api.md
CHANGED
|
@@ -4,15 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { FluidObject } from '@fluidframework/core-interfaces';
|
|
7
|
+
import { ErasedType } from '@fluidframework/core-interfaces';
|
|
9
8
|
import { IChannel } from '@fluidframework/datastore-definitions';
|
|
10
|
-
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
11
|
-
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
12
|
-
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
13
|
-
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
14
9
|
import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
15
|
-
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
16
10
|
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
17
11
|
import { ISharedObjectKind } from '@fluidframework/shared-object-base';
|
|
18
12
|
import { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
|
|
@@ -140,7 +134,11 @@ export const Any: "Any";
|
|
|
140
134
|
export type Any = typeof Any;
|
|
141
135
|
|
|
142
136
|
// @public
|
|
143
|
-
export type ApplyKind<T, Kind extends FieldKind
|
|
137
|
+
export type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
|
138
|
+
[FieldKind.Required]: T;
|
|
139
|
+
[FieldKind.Optional]: T | undefined;
|
|
140
|
+
[FieldKind.Identifier]: DefaultsAreOptional extends true ? T | undefined : T;
|
|
141
|
+
}[Kind];
|
|
144
142
|
|
|
145
143
|
// @internal
|
|
146
144
|
export type ApplyMultiplicity<TMultiplicity extends Multiplicity, TypedChild> = {
|
|
@@ -308,6 +306,10 @@ export interface CursorWithNode<TNode> extends ITreeCursorSynchronous {
|
|
|
308
306
|
getNode(): TNode;
|
|
309
307
|
}
|
|
310
308
|
|
|
309
|
+
// @public
|
|
310
|
+
export interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
|
|
311
|
+
}
|
|
312
|
+
|
|
311
313
|
// @internal
|
|
312
314
|
export const defaultSchemaPolicy: FullSchemaPolicy;
|
|
313
315
|
|
|
@@ -463,6 +465,7 @@ export type FieldKey = Brand<string, "tree.FieldKey">;
|
|
|
463
465
|
|
|
464
466
|
// @public
|
|
465
467
|
export enum FieldKind {
|
|
468
|
+
Identifier = 2,
|
|
466
469
|
Optional = 0,
|
|
467
470
|
Required = 1
|
|
468
471
|
}
|
|
@@ -483,7 +486,6 @@ export const FieldKinds: {
|
|
|
483
486
|
readonly required: Required_2;
|
|
484
487
|
readonly optional: Optional;
|
|
485
488
|
readonly sequence: Sequence;
|
|
486
|
-
readonly nodeKey: NodeKeyFieldKind;
|
|
487
489
|
readonly identifier: Identifier;
|
|
488
490
|
readonly forbidden: Forbidden;
|
|
489
491
|
};
|
|
@@ -504,15 +506,12 @@ export interface FieldMapObject<TChild> {
|
|
|
504
506
|
|
|
505
507
|
// @public
|
|
506
508
|
export interface FieldProps {
|
|
509
|
+
readonly defaultProvider?: DefaultProvider;
|
|
507
510
|
readonly key?: string;
|
|
508
511
|
}
|
|
509
512
|
|
|
510
513
|
// @public @sealed
|
|
511
514
|
export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
|
|
512
|
-
constructor(
|
|
513
|
-
kind: Kind,
|
|
514
|
-
allowedTypes: Types,
|
|
515
|
-
props?: FieldProps | undefined);
|
|
516
515
|
readonly allowedTypes: Types;
|
|
517
516
|
get allowedTypeSet(): ReadonlySet<TreeNodeSchema>;
|
|
518
517
|
readonly kind: Kind;
|
|
@@ -637,9 +636,9 @@ export class FlexObjectNodeSchema<const out Name extends string = string, const
|
|
|
637
636
|
|
|
638
637
|
// @internal
|
|
639
638
|
export interface FlexTreeContext extends ISubscribable<ForestEvents> {
|
|
640
|
-
readonly
|
|
639
|
+
readonly checkout: ITreeCheckout;
|
|
641
640
|
// (undocumented)
|
|
642
|
-
readonly
|
|
641
|
+
readonly nodeKeyManager: NodeKeyManager;
|
|
643
642
|
get root(): FlexTreeField;
|
|
644
643
|
readonly schema: FlexTreeSchema;
|
|
645
644
|
}
|
|
@@ -830,14 +829,14 @@ export interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes> e
|
|
|
830
829
|
moveToStart(sourceIndex: number): void;
|
|
831
830
|
moveToStart(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;
|
|
832
831
|
removeAt(index: number): void;
|
|
833
|
-
|
|
832
|
+
sequenceEditor(): SequenceFieldEditBuilder;
|
|
834
833
|
}
|
|
835
834
|
|
|
836
835
|
// @internal
|
|
837
836
|
export type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<TSchema["kind"], TSchema["allowedTypes"]>;
|
|
838
837
|
|
|
839
838
|
// @internal
|
|
840
|
-
export type FlexTreeTypedFieldInner<Kind extends FlexFieldKind, Types extends FlexAllowedTypes> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<Types> : Kind extends typeof FieldKinds.required ? FlexTreeRequiredField<Types> : Kind extends typeof FieldKinds.optional ? FlexTreeOptionalField<Types> :
|
|
839
|
+
export type FlexTreeTypedFieldInner<Kind extends FlexFieldKind, Types extends FlexAllowedTypes> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<Types> : Kind extends typeof FieldKinds.required ? FlexTreeRequiredField<Types> : Kind extends typeof FieldKinds.optional ? FlexTreeOptionalField<Types> : FlexTreeField;
|
|
841
840
|
|
|
842
841
|
// @internal
|
|
843
842
|
export type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? FlexTreeLeafNode<TSchema> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexFieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeNode;
|
|
@@ -849,7 +848,7 @@ export type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> = T extends FlexL
|
|
|
849
848
|
export type FlexTreeUnboxField<TSchema extends FlexFieldSchema, Emptiness extends "maybeEmpty" | "notEmpty" = "maybeEmpty"> = FlexTreeUnboxFieldInner<TSchema["kind"], TSchema["allowedTypes"], Emptiness>;
|
|
850
849
|
|
|
851
850
|
// @internal
|
|
852
|
-
export type FlexTreeUnboxFieldInner<Kind extends FlexFieldKind, TTypes extends FlexAllowedTypes, Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<TTypes> : Kind extends typeof FieldKinds.required ? FlexTreeUnboxNodeUnion<TTypes> : Kind extends typeof FieldKinds.optional ? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends "notEmpty" ? never : undefined) :
|
|
851
|
+
export type FlexTreeUnboxFieldInner<Kind extends FlexFieldKind, TTypes extends FlexAllowedTypes, Emptiness extends "maybeEmpty" | "notEmpty"> = Kind extends typeof FieldKinds.sequence ? FlexTreeSequenceField<TTypes> : Kind extends typeof FieldKinds.required ? FlexTreeUnboxNodeUnion<TTypes> : Kind extends typeof FieldKinds.optional ? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends "notEmpty" ? never : undefined) : unknown;
|
|
853
852
|
|
|
854
853
|
// @internal
|
|
855
854
|
export type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexFieldNodeSchema ? FlexTreeFieldNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeUnknownUnboxed;
|
|
@@ -992,7 +991,7 @@ ApplyMultiplicity<TField["kind"]["multiplicity"], AllowedTypesToFlexInsertableTr
|
|
|
992
991
|
// @internal
|
|
993
992
|
export type InsertableFlexNode<TSchema extends FlexTreeNodeSchema> = FlattenKeys<CollectOptions<TSchema extends FlexObjectNodeSchema<string, infer TFields extends FlexObjectNodeFields> ? TypedFields<TFields> : TSchema extends FlexFieldNodeSchema<string, infer TField extends FlexFieldSchema> ? InsertableFlexField<TField> : TSchema extends FlexMapNodeSchema<string, infer TField extends FlexFieldSchema> ? {
|
|
994
993
|
readonly [P in string]: InsertableFlexField<TField>;
|
|
995
|
-
} : EmptyObject, TSchema extends LeafNodeSchema<string, infer TValueSchema> ? TValueSchema : undefined, TSchema["name"]>>;
|
|
994
|
+
} : EmptyObject, TSchema extends LeafNodeSchema<string, infer TValueSchema extends ValueSchema> ? TValueSchema : undefined, TSchema["name"]>>;
|
|
996
995
|
|
|
997
996
|
// @public
|
|
998
997
|
export type InsertableObjectFromSchemaRecord<T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>> = {
|
|
@@ -1005,10 +1004,10 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|
|
1005
1004
|
};
|
|
1006
1005
|
|
|
1007
1006
|
// @public
|
|
1008
|
-
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
|
1007
|
+
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
|
1009
1008
|
|
|
1010
1009
|
// @public
|
|
1011
|
-
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
|
1010
|
+
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
|
1012
1011
|
|
|
1013
1012
|
// @public
|
|
1014
1013
|
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
|
@@ -1026,6 +1025,10 @@ export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = Un
|
|
|
1026
1025
|
implicitlyConstructable: true;
|
|
1027
1026
|
} ? NodeBuilderDataUnsafe<T> : never);
|
|
1028
1027
|
|
|
1028
|
+
// @public
|
|
1029
|
+
export interface InternalTreeNode extends ErasedType<"@fluidframework/tree.InternalTreeNode"> {
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1029
1032
|
// @internal
|
|
1030
1033
|
export interface Invariant<in out T> extends Contravariant<T>, Covariant<T> {
|
|
1031
1034
|
}
|
|
@@ -1317,18 +1320,11 @@ export interface NodeInDocumentConstraint {
|
|
|
1317
1320
|
}
|
|
1318
1321
|
|
|
1319
1322
|
// @internal
|
|
1320
|
-
export
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
// @internal
|
|
1327
|
-
export interface NodeKeys {
|
|
1328
|
-
generate(): LocalNodeKey;
|
|
1329
|
-
localize(key: StableNodeKey): LocalNodeKey;
|
|
1330
|
-
readonly map: ReadonlyMap<LocalNodeKey, FlexTreeObjectNode>;
|
|
1331
|
-
stabilize(key: LocalNodeKey): StableNodeKey;
|
|
1323
|
+
export interface NodeKeyManager {
|
|
1324
|
+
generateLocalNodeKey(): LocalNodeKey;
|
|
1325
|
+
localizeNodeKey(key: StableNodeKey): LocalNodeKey;
|
|
1326
|
+
stabilizeNodeKey(key: LocalNodeKey): StableNodeKey;
|
|
1327
|
+
tryLocalizeNodeKey(key: string): LocalNodeKey | undefined;
|
|
1332
1328
|
}
|
|
1333
1329
|
|
|
1334
1330
|
// @public
|
|
@@ -1485,7 +1481,7 @@ export const reservedObjectNodeFieldPropertyNamePrefixes: readonly ["set", "boxe
|
|
|
1485
1481
|
export type ReservedObjectNodeFieldPropertyNames = (typeof reservedObjectNodeFieldPropertyNames)[number];
|
|
1486
1482
|
|
|
1487
1483
|
// @internal
|
|
1488
|
-
export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "
|
|
1484
|
+
export const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "on", "parentField", "schema", "treeStatus", "tryGetField", "type", "value", "boxedIterator", "iterator", "getBoxed"];
|
|
1489
1485
|
|
|
1490
1486
|
// @public
|
|
1491
1487
|
export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
|
|
@@ -1512,6 +1508,9 @@ export enum RevertibleStatus {
|
|
|
1512
1508
|
// @internal
|
|
1513
1509
|
export type RevisionTag = SessionSpaceCompressedId | "root";
|
|
1514
1510
|
|
|
1511
|
+
// @public
|
|
1512
|
+
export const rollback: unique symbol;
|
|
1513
|
+
|
|
1515
1514
|
// @internal
|
|
1516
1515
|
export interface RootField {
|
|
1517
1516
|
// (undocumented)
|
|
@@ -1527,6 +1526,23 @@ export const rootFieldKey: FieldKey;
|
|
|
1527
1526
|
// @internal
|
|
1528
1527
|
export function runSynchronous(view: ITreeCheckout, transaction: (view: ITreeCheckout) => TransactionResult | void): TransactionResult;
|
|
1529
1528
|
|
|
1529
|
+
// @public
|
|
1530
|
+
export interface RunTransaction {
|
|
1531
|
+
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
|
1532
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
|
1533
|
+
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
|
1534
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
|
1535
|
+
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
|
1536
|
+
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
|
1537
|
+
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: TransactionConstraint[]): TResult;
|
|
1538
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: TransactionConstraint[]): TResult;
|
|
1539
|
+
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: TransactionConstraint[]): TResult | typeof rollback;
|
|
1540
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: TransactionConstraint[]): TResult | typeof rollback;
|
|
1541
|
+
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: TransactionConstraint[]): void;
|
|
1542
|
+
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: TransactionConstraint[]): void;
|
|
1543
|
+
readonly rollback: typeof rollback;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1530
1546
|
// @internal
|
|
1531
1547
|
export class SchemaBuilderBase<TScope extends string, TDefaultKind extends FlexFieldKind, TName extends number | string = string> {
|
|
1532
1548
|
constructor(defaultKind: TDefaultKind, options: SchemaBuilderOptions<TScope>);
|
|
@@ -1584,7 +1600,8 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
|
|
|
1584
1600
|
[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
|
|
1585
1601
|
}, false, T>;
|
|
1586
1602
|
readonly boolean: TreeNodeSchema<"com.fluidframework.leaf.boolean", NodeKind.Leaf, boolean, boolean>;
|
|
1587
|
-
readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<
|
|
1603
|
+
readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<unknown>, IFluidHandle<unknown>>;
|
|
1604
|
+
get identifier(): FieldSchema<FieldKind.Identifier>;
|
|
1588
1605
|
map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchema<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
|
|
1589
1606
|
map<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
|
|
1590
1607
|
mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>, {
|
|
@@ -1597,9 +1614,10 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
|
|
|
1597
1614
|
readonly number: TreeNodeSchema<"com.fluidframework.leaf.number", NodeKind.Leaf, number, number>;
|
|
1598
1615
|
object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, fields: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
|
|
1599
1616
|
objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>>(name: Name, t: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T>;
|
|
1600
|
-
optional<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Optional, T>;
|
|
1601
|
-
optionalRecursive<const T extends Unenforced<
|
|
1602
|
-
required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
|
|
1617
|
+
optional<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Optional, T>;
|
|
1618
|
+
optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Optional, T>;
|
|
1619
|
+
required<const T extends ImplicitAllowedTypes>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchema<FieldKind.Required, T>;
|
|
1620
|
+
requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(t: T, props?: Omit<FieldProps, "defaultProvider">): FieldSchemaUnsafe<FieldKind.Required, T>;
|
|
1603
1621
|
// (undocumented)
|
|
1604
1622
|
readonly scope: TScope;
|
|
1605
1623
|
readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
|
|
@@ -1683,19 +1701,6 @@ export interface SharedTreeContentSnapshot {
|
|
|
1683
1701
|
readonly tree: JsonableTree[];
|
|
1684
1702
|
}
|
|
1685
1703
|
|
|
1686
|
-
// @internal
|
|
1687
|
-
export class SharedTreeFactory implements IChannelFactory<ISharedTree> {
|
|
1688
|
-
constructor(options?: SharedTreeOptions);
|
|
1689
|
-
// (undocumented)
|
|
1690
|
-
readonly attributes: IChannelAttributes;
|
|
1691
|
-
// (undocumented)
|
|
1692
|
-
create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree;
|
|
1693
|
-
// (undocumented)
|
|
1694
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ISharedTree>;
|
|
1695
|
-
// (undocumented)
|
|
1696
|
-
readonly type: string;
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
1704
|
// @internal
|
|
1700
1705
|
export interface SharedTreeFormatOptions {
|
|
1701
1706
|
formatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];
|
|
@@ -1788,10 +1793,7 @@ export interface TreeAdapter {
|
|
|
1788
1793
|
// @public
|
|
1789
1794
|
export interface TreeApi extends TreeNodeApi {
|
|
1790
1795
|
contains(node: TreeNode, other: TreeNode): boolean;
|
|
1791
|
-
runTransaction
|
|
1792
|
-
runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback", preconditions?: TransactionConstraint[]): void;
|
|
1793
|
-
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
|
|
1794
|
-
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback", preconditions?: TransactionConstraint[]): void;
|
|
1796
|
+
readonly runTransaction: RunTransaction;
|
|
1795
1797
|
}
|
|
1796
1798
|
|
|
1797
1799
|
// @public
|
|
@@ -1805,9 +1807,9 @@ export const TreeArrayNode: {
|
|
|
1805
1807
|
|
|
1806
1808
|
// @public
|
|
1807
1809
|
export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
|
1808
|
-
insertAt(index: number, ...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1809
|
-
insertAtEnd(...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1810
|
-
insertAtStart(...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1810
|
+
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1811
|
+
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1812
|
+
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
1811
1813
|
moveRangeToEnd(sourceStart: number, sourceEnd: number): void;
|
|
1812
1814
|
moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;
|
|
1813
1815
|
moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;
|
|
@@ -1861,10 +1863,10 @@ export interface TreeDataContext {
|
|
|
1861
1863
|
}
|
|
1862
1864
|
|
|
1863
1865
|
// @public
|
|
1864
|
-
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
|
1866
|
+
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
|
1865
1867
|
|
|
1866
1868
|
// @public
|
|
1867
|
-
export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
|
1869
|
+
export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
|
1868
1870
|
|
|
1869
1871
|
// @internal
|
|
1870
1872
|
export interface TreeFieldStoredSchema {
|
|
@@ -1906,15 +1908,17 @@ export const enum TreeNavigationResult {
|
|
|
1906
1908
|
// @public
|
|
1907
1909
|
export abstract class TreeNode implements WithType {
|
|
1908
1910
|
abstract get [type](): string;
|
|
1911
|
+
protected constructor();
|
|
1909
1912
|
}
|
|
1910
1913
|
|
|
1911
1914
|
// @public
|
|
1912
1915
|
export interface TreeNodeApi {
|
|
1913
|
-
is<TSchema extends
|
|
1916
|
+
is<TSchema extends ImplicitAllowedTypes>(value: unknown, schema: TSchema): value is TreeNodeFromImplicitAllowedTypes<TSchema>;
|
|
1914
1917
|
key(node: TreeNode): string | number;
|
|
1915
1918
|
on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
|
|
1916
1919
|
parent(node: TreeNode): TreeNode | undefined;
|
|
1917
1920
|
schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
|
|
1921
|
+
shortId(node: TreeNode): number | string | undefined;
|
|
1918
1922
|
readonly status: (node: TreeNode) => TreeStatus;
|
|
1919
1923
|
}
|
|
1920
1924
|
|
|
@@ -1947,7 +1951,7 @@ export abstract class TreeNodeSchemaBase<const out Name extends string = string,
|
|
|
1947
1951
|
// @public
|
|
1948
1952
|
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
|
1949
1953
|
// @sealed
|
|
1950
|
-
new (data: TInsertable): Unhydrated<TNode>;
|
|
1954
|
+
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
|
1951
1955
|
}
|
|
1952
1956
|
|
|
1953
1957
|
// @public
|
package/dist/beta.d.ts
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
|
-
// public APIs
|
|
12
|
+
// @public APIs
|
|
13
13
|
AllowedTypes,
|
|
14
14
|
ApplyKind,
|
|
15
15
|
CommitKind,
|
|
16
16
|
CommitMetadata,
|
|
17
|
+
DefaultProvider,
|
|
17
18
|
Events,
|
|
18
19
|
ExtractItemType,
|
|
19
20
|
FieldKind,
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
|
|
36
37
|
InsertableTypedNode,
|
|
37
38
|
InsertableTypedNodeUnsafe,
|
|
39
|
+
InternalTreeNode,
|
|
38
40
|
IsEvent,
|
|
39
41
|
IterableTreeArrayContent,
|
|
40
42
|
LazyItem,
|
|
@@ -51,6 +53,7 @@ export {
|
|
|
51
53
|
Revertible,
|
|
52
54
|
RevertibleFactory,
|
|
53
55
|
RevertibleStatus,
|
|
56
|
+
RunTransaction,
|
|
54
57
|
SchemaFactory,
|
|
55
58
|
SchemaIncompatible,
|
|
56
59
|
ScopedSchemaName,
|
|
@@ -86,5 +89,6 @@ export {
|
|
|
86
89
|
ValidateRecursiveSchema,
|
|
87
90
|
WithType,
|
|
88
91
|
disposeSymbol,
|
|
92
|
+
rollback,
|
|
89
93
|
type
|
|
90
94
|
} from "./index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAQ,MAAM,kBAAkB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,E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AAC,GAAoB,EAAE,OAAiB,EAAE,EAAE;YACnD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAE,EAAE;YACjD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport { ChangeEncodingContext } from \"../core/index.js\";\nimport { JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @internal\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * @returns Whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @internal\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @internal\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<\n\t\t\t\t\t\tTDecoded,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tTContext\n\t\t\t\t >\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(formatVersion: number) {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats() {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, any> =\n\t{\n\t\tjson: {\n\t\t\tencode: () => 0,\n\t\t\tdecode: () => 0,\n\t\t},\n\t\tbinary: {\n\t\t\tencode: () => IsoBuffer.from(\"\"),\n\t\t\tdecode: () => 0,\n\t\t},\n\t};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext) => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext) => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAA6D;AAI7D,+CAAgE;AA+KhE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAYC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE;QAC9C,IAAI,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YAC9B,IAAA,eAAI,EAAC,6BAA6B,CAAC,CAAC;SACpC;QACD,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;KACvD;IAED,OAAO;QACN,OAAO,CACN,aAAqB;YAErB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACxC,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,mBAAmB;YAClB,OAAO,MAAM,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AAI,EAAE;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACf,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;KACf;IACD,MAAM,EAAE;QACP,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;KACf;CACD,CAAC;AAEH;;;GAGG;AACH,SAAgB,oBAAoB,CAOnC,MAAqB,EACrB,KAAuE,EACvE,SAAyB;IAEzB,IAAI,CAAC,SAAS,EAAE;QACf,OAAO,KAAK,CAAC;KACb;IACD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACN,MAAM,EAAE,CAAC,GAAoB,EAAE,OAAiB,EAAkB,EAAE;YACnE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAmB,EAAE;YAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACnC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;aACvC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport { ChangeEncodingContext } from \"../core/index.js\";\nimport { JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @internal\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * @returns Whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @internal\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @internal\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<\n\t\t\t\t\t\tTDecoded,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\t\t\tTContext\n\t\t\t\t >\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, any> =\n\t{\n\t\tjson: {\n\t\t\tencode: () => 0,\n\t\t\tdecode: () => 0,\n\t\t},\n\t\tbinary: {\n\t\t\tencode: () => IsoBuffer.from(\"\"),\n\t\t\tdecode: () => 0,\n\t\t},\n\t};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { SessionId } from "@fluidframework/id-compressor";
|
|
|
6
6
|
import { ICodecFamily, IJsonCodec } from "../../codec/index.js";
|
|
7
7
|
import { SchemaAndPolicy } from "../../core/index.js";
|
|
8
8
|
import { JsonCompatibleReadOnly } from "../../util/index.js";
|
|
9
|
-
import { ChangeRebaser } from "../rebase/index.js";
|
|
9
|
+
import { ChangeRebaser, RevisionTag } from "../rebase/index.js";
|
|
10
10
|
export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
|
|
11
11
|
buildEditor(changeReceiver: (change: TChange) => void): TEditor;
|
|
12
12
|
readonly rebaser: ChangeRebaser<TChange>;
|
|
@@ -14,6 +14,7 @@ export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
|
|
|
14
14
|
}
|
|
15
15
|
export interface ChangeEncodingContext {
|
|
16
16
|
readonly originatorId: SessionId;
|
|
17
|
+
readonly revision: RevisionTag | undefined;
|
|
17
18
|
readonly schema?: SchemaAndPolicy;
|
|
18
19
|
}
|
|
19
20
|
export type ChangeFamilyCodec<TChange> = IJsonCodec<TChange, JsonCompatibleReadOnly, JsonCompatibleReadOnly, ChangeEncodingContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFamily.d.ts","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"changeFamily.d.ts","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe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