@fluidframework/tree 2.74.0 → 2.80.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 +1 -16
- package/CHANGELOG.md +18 -0
- package/api-report/tree.alpha.api.md +20 -2
- package/dist/alpha.d.ts +4 -0
- package/dist/codec/codec.d.ts +31 -3
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +10 -0
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +2 -2
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +80 -22
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +137 -15
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -2
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +36 -2
- 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 +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +1 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +6 -2
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -12
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.js +3 -3
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -3
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +3 -4
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +1 -2
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +12 -56
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +2 -2
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/mapTree.js +1 -1
- package/dist/core/tree/mapTree.js.map +1 -1
- package/dist/core/tree/sparseTree.d.ts.map +1 -1
- package/dist/core/tree/sparseTree.js +1 -0
- package/dist/core/tree/sparseTree.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js +5 -9
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -13
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +9 -7
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +12 -9
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- 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 +4 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +4 -2
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +11 -7
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +315 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +25 -288
- 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 +225 -195
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +4 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +34 -39
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +28 -70
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +2 -5
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +11 -6
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +17 -13
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +5 -4
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +26 -18
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +40 -35
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +46 -27
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +7 -7
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +2 -2
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/valueUtilities.js +16 -8
- package/dist/feature-libraries/valueUtilities.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- 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/shared-tree/schematizingTreeView.d.ts +2 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +20 -9
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +61 -44
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +35 -29
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +21 -23
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +31 -18
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +3 -1
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +5 -3
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/editManager.js +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +9 -4
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +8 -4
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +1 -0
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +6 -0
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +12 -8
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +25 -8
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +65 -30
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +3 -3
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +13 -9
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +21 -17
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +12 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +18 -9
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -3
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +21 -13
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +14 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +6 -3
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +2 -1
- package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +9 -6
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +9 -5
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/treeFactory.js +7 -3
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/bTreeUtils.js +1 -1
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/breakable.js +7 -9
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/idAllocator.d.ts.map +1 -1
- package/dist/util/idAllocator.js +1 -2
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +16 -15
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +1 -16
- package/lib/alpha.d.ts +4 -0
- package/lib/codec/codec.d.ts +31 -3
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +10 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +2 -2
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +80 -22
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +138 -15
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +36 -2
- 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 +2 -2
- 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/types.d.ts +6 -2
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -10
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.js +3 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +3 -4
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +1 -2
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +13 -57
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/mapTree.js +1 -1
- package/lib/core/tree/mapTree.js.map +1 -1
- package/lib/core/tree/sparseTree.d.ts.map +1 -1
- package/lib/core/tree/sparseTree.js +1 -0
- package/lib/core/tree/sparseTree.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js +5 -9
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +3 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +12 -9
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- 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 +5 -5
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +4 -2
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +3 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +298 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +27 -290
- 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 +118 -88
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +4 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +35 -40
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +30 -68
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +11 -6
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +17 -13
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +5 -4
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +26 -18
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +41 -36
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +46 -27
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +7 -7
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +2 -2
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/valueUtilities.js +16 -8
- package/lib/feature-libraries/valueUtilities.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- 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/shared-tree/schematizingTreeView.d.ts +2 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +20 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +30 -13
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +35 -29
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +21 -23
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +32 -19
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +3 -1
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +5 -3
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/editManager.js +1 -1
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +9 -4
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +8 -4
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +1 -0
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +6 -0
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +12 -8
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +25 -8
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +67 -32
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +3 -3
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +13 -9
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +21 -17
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +12 -8
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +18 -9
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +4 -7
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +21 -13
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +14 -9
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +6 -3
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +2 -1
- package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +9 -6
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +9 -5
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/treeFactory.js +7 -3
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/bTreeUtils.js +1 -1
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/breakable.js +7 -9
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/idAllocator.d.ts.map +1 -1
- package/lib/util/idAllocator.js +1 -2
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +16 -15
- package/lib/util/utils.js.map +1 -1
- package/package.json +32 -32
- package/src/codec/codec.ts +48 -8
- package/src/codec/index.ts +4 -1
- package/src/codec/versioned/codec.ts +340 -22
- package/src/codec/versioned/index.ts +3 -1
- package/src/core/index.ts +2 -2
- package/src/core/rebase/changeRebaser.ts +40 -6
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +6 -18
- package/src/core/rebase/utils.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -3
- package/src/core/tree/anchorSet.ts +3 -4
- package/src/core/tree/detachedFieldIndex.ts +13 -74
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
- package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
- package/src/core/tree/index.ts +1 -1
- package/src/core/tree/mapTree.ts +1 -1
- package/src/core/tree/sparseTree.ts +1 -0
- package/src/core/tree/treeTextFormat.ts +5 -9
- package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +48 -17
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -2
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +6 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +13 -14
- package/src/feature-libraries/index.ts +10 -5
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
- package/src/feature-libraries/mitigatedChangeFamily.ts +11 -6
- package/src/feature-libraries/modular-schema/comparison.ts +12 -9
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +3 -6
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +5 -7
- package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
- package/src/feature-libraries/modular-schema/index.ts +5 -2
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +703 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +39 -523
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +159 -125
- package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +4 -4
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +13 -4
- package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
- package/src/feature-libraries/object-forest/objectForest.ts +4 -4
- package/src/feature-libraries/optional-field/optionalField.ts +34 -46
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
- package/src/feature-libraries/schema-index/codec.ts +30 -90
- package/src/feature-libraries/schema-index/index.ts +2 -4
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
- package/src/feature-libraries/schemaChecker.ts +11 -6
- package/src/feature-libraries/sequence-field/compose.ts +17 -13
- package/src/feature-libraries/sequence-field/invert.ts +5 -4
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +15 -9
- package/src/feature-libraries/sequence-field/rebase.ts +26 -18
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -56
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +16 -8
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +6 -3
- package/src/feature-libraries/sequence-field/utils.ts +46 -27
- package/src/feature-libraries/treeCursorUtils.ts +7 -7
- package/src/feature-libraries/treeTextCursor.ts +2 -2
- package/src/feature-libraries/valueUtilities.ts +16 -8
- package/src/index.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +23 -13
- package/src/shared-tree/sharedTree.ts +30 -14
- package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -9
- package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -2
- package/src/shared-tree/sharedTreeChangeFamily.ts +29 -19
- package/src/shared-tree/sharedTreeEditBuilder.ts +9 -5
- package/src/shared-tree/treeAlpha.ts +60 -51
- package/src/shared-tree/treeCheckout.ts +66 -50
- package/src/shared-tree-core/branch.ts +8 -3
- package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
- package/src/shared-tree-core/editManager.ts +1 -1
- package/src/shared-tree-core/editManagerCodecs.ts +9 -4
- package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
- package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
- package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageCodecs.ts +8 -4
- package/src/shared-tree-core/messageFormat.ts +6 -1
- package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
- package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
- package/src/shared-tree-core/sharedTreeCore.ts +11 -7
- package/src/shared-tree-core/transaction.ts +115 -56
- package/src/shared-tree-core/transactionEnricher.ts +5 -6
- package/src/simple-tree/api/configuration.ts +1 -1
- package/src/simple-tree/api/customTree.ts +14 -10
- package/src/simple-tree/api/discrepancies.ts +23 -17
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +11 -7
- package/src/simple-tree/api/schemaFromSimple.ts +18 -9
- package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
- package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
- package/src/simple-tree/api/storedSchema.ts +10 -7
- package/src/simple-tree/api/transactionTypes.ts +19 -4
- package/src/simple-tree/api/treeNodeApi.ts +21 -13
- package/src/simple-tree/api/verboseTree.ts +14 -9
- package/src/simple-tree/core/treeNodeKernel.ts +6 -3
- package/src/simple-tree/core/unhydratedFlexTree.ts +22 -17
- package/src/simple-tree/getTreeNodeForField.ts +2 -1
- package/src/simple-tree/index.ts +2 -0
- package/src/simple-tree/leafNodeSchema.ts +8 -5
- package/src/simple-tree/node-kinds/array/arrayNode.ts +23 -23
- package/src/simple-tree/node-kinds/object/objectNode.ts +4 -5
- package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
- package/src/simple-tree/toStoredSchema.ts +9 -5
- package/src/treeFactory.ts +10 -5
- package/src/util/bTreeUtils.ts +1 -1
- package/src/util/breakable.ts +9 -9
- package/src/util/idAllocator.ts +1 -2
- package/src/util/nestedMap.ts +1 -3
- package/src/util/utils.ts +14 -13
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
|
@@ -2,68 +2,31 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { fail
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { fail } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
|
|
7
|
+
import { ClientVersionDispatchingCodecBuilder, FluidClientVersion, } from "../../codec/index.js";
|
|
8
8
|
import { SchemaFormatVersion, decodeFieldSchema, encodeFieldSchemaV1, encodeFieldSchemaV2, storedSchemaDecodeDispatcher, } from "../../core/index.js";
|
|
9
|
-
import { brand
|
|
9
|
+
import { brand } from "../../util/index.js";
|
|
10
10
|
import { Format as FormatV1 } from "./formatV1.js";
|
|
11
11
|
import { Format as FormatV2 } from "./formatV2.js";
|
|
12
|
-
/**
|
|
13
|
-
* Convert a MinimumVersionForCollab to a SchemaFormatVersion.
|
|
14
|
-
* @param clientVersion - The MinimumVersionForCollab to convert.
|
|
15
|
-
* @returns The SchemaFormatVersion that corresponds to the provided MinimumVersionForCollab.
|
|
16
|
-
*/
|
|
17
|
-
export function clientVersionToSchemaVersion(clientVersion) {
|
|
18
|
-
return getConfigForMinVersionForCollab(clientVersion, {
|
|
19
|
-
[lowestMinVersionForCollab]: SchemaFormatVersion.v1,
|
|
20
|
-
[FluidClientVersion.v2_43]: SchemaFormatVersion.v2,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export function getCodecTreeForSchemaFormat(clientVersion) {
|
|
24
|
-
return { name: "Schema", version: clientVersionToSchemaVersion(clientVersion) };
|
|
25
|
-
}
|
|
26
12
|
/**
|
|
27
13
|
* Create a schema codec.
|
|
28
14
|
* @param options - Specifies common codec options, including `minVersionForCollab` and which `validator` to use.
|
|
29
15
|
* @param writeVersionOverride - The schema version to write. If not provided, the version will be derived from `minVersionForCollab`.
|
|
16
|
+
* TODO: Currently this parameter is provided when it probably should not be. Users of it should probably allow the automatic selection to occur and this parameter can be removed.
|
|
17
|
+
* Any case where an override is actually required can use `options` to do so.
|
|
30
18
|
* @returns The composed codec.
|
|
31
19
|
*
|
|
32
20
|
* @privateRemarks We should consider using the Shared Tree format version instead as it may be more valuable for application authors than the schema version.
|
|
21
|
+
*
|
|
22
|
+
* TODO: replace use of this with schemaCodecBuilder.build(...).
|
|
33
23
|
*/
|
|
34
24
|
export function makeSchemaCodec(options, writeVersionOverride) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
writeVersion: writeVersionOverride ?? clientVersionToSchemaVersion(options.minVersionForCollab),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Create a family of schema codecs.
|
|
43
|
-
* @param options - Specifies common codec options, including which `validator` to use.
|
|
44
|
-
* @returns The composed codec family.
|
|
45
|
-
*/
|
|
46
|
-
export function makeSchemaCodecs(options) {
|
|
47
|
-
return makeCodecFamily([
|
|
48
|
-
[SchemaFormatVersion.v1, makeSchemaCodecV1(options)],
|
|
49
|
-
[SchemaFormatVersion.v2, makeSchemaCodecV2(options)],
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Encode an in-memory TreeStoredSchema into the specified format version.
|
|
54
|
-
* @param repo - The in-memory schema.
|
|
55
|
-
* @param version - The schema write version.
|
|
56
|
-
* @returns The encoded schema.
|
|
57
|
-
*/
|
|
58
|
-
export function encodeRepo(repo, version) {
|
|
59
|
-
switch (version) {
|
|
60
|
-
case unbrand(SchemaFormatVersion.v1):
|
|
61
|
-
return encodeRepoV1(repo);
|
|
62
|
-
case unbrand(SchemaFormatVersion.v2):
|
|
63
|
-
return encodeRepoV2(repo);
|
|
64
|
-
default:
|
|
65
|
-
unreachableCase(version);
|
|
25
|
+
const overrides = new Map(options.writeVersionOverrides ?? []);
|
|
26
|
+
if (writeVersionOverride !== undefined) {
|
|
27
|
+
overrides.set(schemaCodecBuilder.name, writeVersionOverride);
|
|
66
28
|
}
|
|
29
|
+
return schemaCodecBuilder.build({ ...options, writeVersionOverrides: overrides });
|
|
67
30
|
}
|
|
68
31
|
function encodeRepoV1(repo) {
|
|
69
32
|
const nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV1());
|
|
@@ -128,24 +91,23 @@ function decodeV2(f) {
|
|
|
128
91
|
}
|
|
129
92
|
/**
|
|
130
93
|
* Creates a codec which performs synchronous monolithic encoding of schema content.
|
|
131
|
-
* @param options - Specifies common codec options, including which `validator` to use.
|
|
132
|
-
* @returns The codec.
|
|
133
|
-
*/
|
|
134
|
-
function makeSchemaCodecV1(options) {
|
|
135
|
-
return makeVersionedValidatedCodec(options, new Set([SchemaFormatVersion.v1]), FormatV1, {
|
|
136
|
-
encode: (data) => encodeRepoV1(data),
|
|
137
|
-
decode: (data) => decodeV1(data),
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Creates a codec which performs synchronous monolithic encoding of schema content.
|
|
142
|
-
* @param options - Specifies common codec options, including which `validator` to use.
|
|
143
|
-
* @returns The codec.
|
|
144
94
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
95
|
+
export const schemaCodecBuilder = ClientVersionDispatchingCodecBuilder.build("Schema", {
|
|
96
|
+
[lowestMinVersionForCollab]: {
|
|
97
|
+
formatVersion: SchemaFormatVersion.v1,
|
|
98
|
+
codec: {
|
|
99
|
+
encode: (data) => encodeRepoV1(data),
|
|
100
|
+
decode: (data) => decodeV1(data),
|
|
101
|
+
schema: FormatV1,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
[FluidClientVersion.v2_43]: {
|
|
105
|
+
formatVersion: SchemaFormatVersion.v2,
|
|
106
|
+
codec: {
|
|
107
|
+
encode: (data) => encodeRepoV2(data),
|
|
108
|
+
decode: (data) => decodeV2(data),
|
|
109
|
+
schema: FormatV2,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
151
113
|
//# sourceMappingURL=codec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EACN,+BAA+B,EAC/B,yBAAyB,GACzB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAGN,kBAAkB,EAIlB,eAAe,EACf,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,mBAAmB,EAInB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAuB,MA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U;KACV,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,OAAsB;IAChD,OAAO,2BAA2B,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE;QACxF,MAAM,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;QACtD,MAAM,EAAE,CAAC,IAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC1C,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,OAAsB;IAChD,OAAO,2BAA2B,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE;QACxF,MAAM,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;QACtD,MAAM,EAAE,CAAC,IAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC1C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport {\n\tSchemaFormatVersion,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tdecodeFieldSchema,\n\tencodeFieldSchemaV1,\n\tencodeFieldSchemaV2,\n\tstoredSchemaDecodeDispatcher,\n} from \"../../core/index.js\";\nimport { brand, unbrand, type JsonCompatible } from \"../../util/index.js\";\n\nimport { Format as FormatV1 } from \"./formatV1.js\";\nimport { Format as FormatV2 } from \"./formatV2.js\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\n/**\n * Convert a MinimumVersionForCollab to a SchemaFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The SchemaFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToSchemaVersion(\n\tclientVersion: MinimumVersionForCollab,\n): SchemaFormatVersion {\n\treturn getConfigForMinVersionForCollab(clientVersion, {\n\t\t[lowestMinVersionForCollab]: SchemaFormatVersion.v1,\n\t\t[FluidClientVersion.v2_43]: SchemaFormatVersion.v2,\n\t});\n}\n\nexport function getCodecTreeForSchemaFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"Schema\", version: clientVersionToSchemaVersion(clientVersion) };\n}\n\n/**\n * Create a schema codec.\n * @param options - Specifies common codec options, including `minVersionForCollab` and which `validator` to use.\n * @param writeVersionOverride - The schema version to write. If not provided, the version will be derived from `minVersionForCollab`.\n * @returns The composed codec.\n *\n * @privateRemarks We should consider using the Shared Tree format version instead as it may be more valuable for application authors than the schema version.\n */\nexport function makeSchemaCodec(\n\toptions: CodecWriteOptions,\n\twriteVersionOverride?: SchemaFormatVersion,\n): IJsonCodec<TreeStoredSchema> {\n\tconst family = makeSchemaCodecs(options);\n\treturn makeVersionDispatchingCodec(family, {\n\t\t...options,\n\t\twriteVersion:\n\t\t\twriteVersionOverride ?? clientVersionToSchemaVersion(options.minVersionForCollab),\n\t});\n}\n\n/**\n * Create a family of schema codecs.\n * @param options - Specifies common codec options, including which `validator` to use.\n * @returns The composed codec family.\n */\nexport function makeSchemaCodecs(options: ICodecOptions): ICodecFamily<TreeStoredSchema> {\n\treturn makeCodecFamily([\n\t\t[SchemaFormatVersion.v1, makeSchemaCodecV1(options)],\n\t\t[SchemaFormatVersion.v2, makeSchemaCodecV2(options)],\n\t]);\n}\n\n/**\n * Encode an in-memory TreeStoredSchema into the specified format version.\n * @param repo - The in-memory schema.\n * @param version - The schema write version.\n * @returns The encoded schema.\n */\nexport function encodeRepo(\n\trepo: TreeStoredSchema,\n\tversion: SchemaFormatVersion,\n): JsonCompatible {\n\tswitch (version) {\n\t\tcase unbrand(SchemaFormatVersion.v1):\n\t\t\treturn encodeRepoV1(repo) as JsonCompatible;\n\t\tcase unbrand(SchemaFormatVersion.v2):\n\t\t\treturn encodeRepoV2(repo) as JsonCompatible;\n\t\tdefault:\n\t\t\tunreachableCase(version);\n\t}\n}\n\nfunction encodeRepoV1(repo: TreeStoredSchema): FormatV1 {\n\tconst nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV1());\n\tconst rootFieldSchema = encodeFieldSchemaV1(repo.rootFieldSchema);\n\treturn {\n\t\tversion: SchemaFormatVersion.v1,\n\t\tnodes: nodeSchema,\n\t\troot: rootFieldSchema,\n\t};\n}\n\nfunction encodeRepoV2(repo: TreeStoredSchema): FormatV2 {\n\tconst nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV2());\n\tconst rootFieldSchema = encodeFieldSchemaV2(repo.rootFieldSchema);\n\treturn {\n\t\tversion: SchemaFormatVersion.v2,\n\t\tnodes: nodeSchema,\n\t\troot: rootFieldSchema,\n\t};\n}\n\n/**\n * Shared logic for encoding node schemas.\n * @param repo - The stored schema to encode.\n * @param encodeValue - A function which encodes a single node schema.\n * @returns The encoded node schema.\n */\nfunction encodeNodeSchema<TFormat>(\n\trepo: TreeStoredSchema,\n\tencodeValue: (schema: TreeNodeStoredSchema) => TFormat,\n): Record<string, TFormat> {\n\tconst nodeSchema: Record<string, TFormat> = Object.create(null);\n\tfor (const name of [...repo.nodeSchema.keys()].sort()) {\n\t\tconst schema = repo.nodeSchema.get(name) ?? fail(0xb28 /* missing schema */);\n\t\tObject.defineProperty(nodeSchema, name, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: encodeValue(schema),\n\t\t});\n\t}\n\n\treturn nodeSchema;\n}\n\nfunction decodeV1(f: FormatV1): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [key, schema] of Object.entries(f.nodes)) {\n\t\tconst storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema);\n\n\t\t// No metadata in v1, so pass undefined\n\t\tnodeSchema.set(brand(key), storedSchemaDecoder(undefined));\n\t}\n\treturn {\n\t\trootFieldSchema: decodeFieldSchema(f.root),\n\t\tnodeSchema,\n\t};\n}\n\nfunction decodeV2(f: FormatV2): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [key, schema] of Object.entries(f.nodes)) {\n\t\tconst storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema.kind);\n\n\t\t// Pass in the node metadata\n\t\tnodeSchema.set(brand(key), storedSchemaDecoder(schema.metadata));\n\t}\n\treturn {\n\t\trootFieldSchema: decodeFieldSchema(f.root),\n\t\tnodeSchema,\n\t};\n}\n\n/**\n * Creates a codec which performs synchronous monolithic encoding of schema content.\n * @param options - Specifies common codec options, including which `validator` to use.\n * @returns The codec.\n */\nfunction makeSchemaCodecV1(options: ICodecOptions): IJsonCodec<TreeStoredSchema, FormatV1> {\n\treturn makeVersionedValidatedCodec(options, new Set([SchemaFormatVersion.v1]), FormatV1, {\n\t\tencode: (data: TreeStoredSchema) => encodeRepoV1(data),\n\t\tdecode: (data: FormatV1) => decodeV1(data),\n\t});\n}\n\n/**\n * Creates a codec which performs synchronous monolithic encoding of schema content.\n * @param options - Specifies common codec options, including which `validator` to use.\n * @returns The codec.\n */\nfunction makeSchemaCodecV2(options: ICodecOptions): IJsonCodec<TreeStoredSchema, FormatV2> {\n\treturn makeVersionedValidatedCodec(options, new Set([SchemaFormatVersion.v2]), FormatV2, {\n\t\tencode: (data: TreeStoredSchema) => encodeRepoV2(data),\n\t\tdecode: (data: FormatV2) => decodeV2(data),\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EACN,oCAAoC,EAEpC,kBAAkB,GAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,mBAAmB,EAInB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC9B,OAA0B,EAC1B,oBAA0C;IAE1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;IAC/D,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACxC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,kBAAkB,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,SAAS,YAAY,CAAC,IAAsB;IAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,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Ac,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,QAAQ;SAChB;KACD;IACD,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;QAC3B,aAAa,EAAE,mBAAmB,CAAC,EAAE;QACrC,KAAK,EAAE;YACN,MAAM,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;YACtD,MAAM,EAAE,CAAC,IAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,QAAQ;SAChB;KACD;CACD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n} from \"../../codec/index.js\";\nimport {\n\tSchemaFormatVersion,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tdecodeFieldSchema,\n\tencodeFieldSchemaV1,\n\tencodeFieldSchemaV2,\n\tstoredSchemaDecodeDispatcher,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\nimport { Format as FormatV1 } from \"./formatV1.js\";\nimport { Format as FormatV2 } from \"./formatV2.js\";\n\n/**\n * Create a schema codec.\n * @param options - Specifies common codec options, including `minVersionForCollab` and which `validator` to use.\n * @param writeVersionOverride - The schema version to write. If not provided, the version will be derived from `minVersionForCollab`.\n * TODO: Currently this parameter is provided when it probably should not be. Users of it should probably allow the automatic selection to occur and this parameter can be removed.\n * Any case where an override is actually required can use `options` to do so.\n * @returns The composed codec.\n *\n * @privateRemarks We should consider using the Shared Tree format version instead as it may be more valuable for application authors than the schema version.\n *\n * TODO: replace use of this with schemaCodecBuilder.build(...).\n */\nexport function makeSchemaCodec(\n\toptions: CodecWriteOptions,\n\twriteVersionOverride?: SchemaFormatVersion,\n): IJsonCodec<TreeStoredSchema> {\n\tconst overrides = new Map(options.writeVersionOverrides ?? []);\n\tif (writeVersionOverride !== undefined) {\n\t\toverrides.set(schemaCodecBuilder.name, writeVersionOverride);\n\t}\n\treturn schemaCodecBuilder.build({ ...options, writeVersionOverrides: overrides });\n}\n\nfunction encodeRepoV1(repo: TreeStoredSchema): FormatV1 {\n\tconst nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV1());\n\tconst rootFieldSchema = encodeFieldSchemaV1(repo.rootFieldSchema);\n\treturn {\n\t\tversion: SchemaFormatVersion.v1,\n\t\tnodes: nodeSchema,\n\t\troot: rootFieldSchema,\n\t};\n}\n\nfunction encodeRepoV2(repo: TreeStoredSchema): FormatV2 {\n\tconst nodeSchema = encodeNodeSchema(repo, (schema) => schema.encodeV2());\n\tconst rootFieldSchema = encodeFieldSchemaV2(repo.rootFieldSchema);\n\treturn {\n\t\tversion: SchemaFormatVersion.v2,\n\t\tnodes: nodeSchema,\n\t\troot: rootFieldSchema,\n\t};\n}\n\n/**\n * Shared logic for encoding node schemas.\n * @param repo - The stored schema to encode.\n * @param encodeValue - A function which encodes a single node schema.\n * @returns The encoded node schema.\n */\nfunction encodeNodeSchema<TFormat>(\n\trepo: TreeStoredSchema,\n\tencodeValue: (schema: TreeNodeStoredSchema) => TFormat,\n): Record<string, TFormat> {\n\tconst nodeSchema: Record<string, TFormat> = Object.create(null);\n\tfor (const name of [...repo.nodeSchema.keys()].sort()) {\n\t\tconst schema = repo.nodeSchema.get(name) ?? fail(0xb28 /* missing schema */);\n\t\tObject.defineProperty(nodeSchema, name, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: encodeValue(schema),\n\t\t});\n\t}\n\n\treturn nodeSchema;\n}\n\nfunction decodeV1(f: FormatV1): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [key, schema] of Object.entries(f.nodes)) {\n\t\tconst storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema);\n\n\t\t// No metadata in v1, so pass undefined\n\t\tnodeSchema.set(brand(key), storedSchemaDecoder(undefined));\n\t}\n\treturn {\n\t\trootFieldSchema: decodeFieldSchema(f.root),\n\t\tnodeSchema,\n\t};\n}\n\nfunction decodeV2(f: FormatV2): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [key, schema] of Object.entries(f.nodes)) {\n\t\tconst storedSchemaDecoder = storedSchemaDecodeDispatcher.dispatch(schema.kind);\n\n\t\t// Pass in the node metadata\n\t\tnodeSchema.set(brand(key), storedSchemaDecoder(schema.metadata));\n\t}\n\treturn {\n\t\trootFieldSchema: decodeFieldSchema(f.root),\n\t\tnodeSchema,\n\t};\n}\n\n/**\n * Creates a codec which performs synchronous monolithic encoding of schema content.\n */\nexport const schemaCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\"Schema\", {\n\t[lowestMinVersionForCollab]: {\n\t\tformatVersion: SchemaFormatVersion.v1,\n\t\tcodec: {\n\t\t\tencode: (data: TreeStoredSchema) => encodeRepoV1(data),\n\t\t\tdecode: (data: FormatV1) => decodeV1(data),\n\t\t\tschema: FormatV1,\n\t\t},\n\t},\n\t[FluidClientVersion.v2_43]: {\n\t\tformatVersion: SchemaFormatVersion.v2,\n\t\tcodec: {\n\t\t\tencode: (data: TreeStoredSchema) => encodeRepoV2(data),\n\t\t\tdecode: (data: FormatV2) => decodeV2(data),\n\t\t\tschema: FormatV2,\n\t\t},\n\t},\n});\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { SchemaSummarizer
|
|
6
|
-
export { makeSchemaCodec,
|
|
5
|
+
export { SchemaSummarizer } from "./schemaSummarizer.js";
|
|
6
|
+
export { makeSchemaCodec, schemaCodecBuilder, } from "./codec.js";
|
|
7
7
|
export { Format as FormatV1 } from "./formatV1.js";
|
|
8
8
|
export { Format as FormatV2 } from "./formatV2.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACN,eAAe,EACf,kBAAkB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { SchemaSummarizer
|
|
6
|
-
export { makeSchemaCodec,
|
|
5
|
+
export { SchemaSummarizer } from "./schemaSummarizer.js";
|
|
6
|
+
export { makeSchemaCodec, schemaCodecBuilder, } from "./codec.js";
|
|
7
7
|
export { Format as FormatV1 } from "./formatV1.js";
|
|
8
8
|
export { Format as FormatV2 } from "./formatV2.js";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACN,eAAe,EACf,kBAAkB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { SchemaSummarizer } from \"./schemaSummarizer.js\";\nexport {\n\tmakeSchemaCodec,\n\tschemaCodecBuilder,\n} from \"./codec.js\";\nexport { Format as FormatV1 } from \"./formatV1.js\";\nexport { Format as FormatV2 } from \"./formatV2.js\";\n"]}
|
|
@@ -6,9 +6,8 @@ import type { IChannelStorageService } from "@fluidframework/datastore-definitio
|
|
|
6
6
|
import type { IExperimentalIncrementalSummaryContext, ITelemetryContext, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
import type { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
|
|
8
8
|
import type { IJsonCodec } from "../../codec/index.js";
|
|
9
|
-
import { type MutableTreeStoredSchema, type
|
|
9
|
+
import { type MutableTreeStoredSchema, type TreeStoredSchema } from "../../core/index.js";
|
|
10
10
|
import { VersionedSummarizer, type Summarizable, type SummaryElementParser, type SummaryElementStringifier } from "../../shared-tree-core/index.js";
|
|
11
|
-
import type { JsonCompatible } from "../../util/index.js";
|
|
12
11
|
import type { CollabWindow } from "../incrementalSummarizationUtils.js";
|
|
13
12
|
export declare const schemaStringKey = "SchemaString";
|
|
14
13
|
/**
|
|
@@ -46,11 +45,4 @@ export declare class SchemaSummarizer extends VersionedSummarizer<SchemaSummaryF
|
|
|
46
45
|
}): void;
|
|
47
46
|
protected loadInternal(services: IChannelStorageService, parse: SummaryElementParser): Promise<void>;
|
|
48
47
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Dumps schema into a deterministic JSON compatible semi-human readable format.
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.
|
|
54
|
-
*/
|
|
55
|
-
export declare function encodeTreeSchema(schema: TreeStoredSchema, writeVersion: SchemaFormatVersion): JsonCompatible;
|
|
56
48
|
//# sourceMappingURL=schemaSummarizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EACX,sCAAsC,EACtC,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,
|
|
1
|
+
{"version":3,"file":"schemaSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EACX,sCAAsC,EACtC,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C;;GAEG;AACH,0BAAkB,0BAA0B;IAC3C;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,EAAE,IAAI;IACN;;OAEG;IACH,OAAO,IAAK;CACZ;AAiBD;;GAEG;AACH,qBAAa,gBACZ,SAAQ,mBAAmB,CAAC,0BAA0B,CACtD,YAAW,YAAY;IAKtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALvB,OAAO,CAAC,yBAAyB,CAAqB;gBAGpC,MAAM,EAAE,uBAAuB,EAChD,YAAY,EAAE,YAAY,EACT,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,EACpD,mBAAmB,EAAE,uBAAuB;IAe7C,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;QAClC,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;QACnE,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;cAmBQ,YAAY,CAC3B,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAgBhB"}
|
|
@@ -7,7 +7,6 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
import { SummaryType } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { schemaDataIsEmpty, } from "../../core/index.js";
|
|
9
9
|
import { VersionedSummarizer, } from "../../shared-tree-core/index.js";
|
|
10
|
-
import { encodeRepo } from "./codec.js";
|
|
11
10
|
export const schemaStringKey = "SchemaString";
|
|
12
11
|
/**
|
|
13
12
|
* The versions for the schema summary format.
|
|
@@ -78,13 +77,4 @@ export class SchemaSummarizer extends VersionedSummarizer {
|
|
|
78
77
|
this.schemaIndexLastChangedSeq = 0;
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Dumps schema into a deterministic JSON compatible semi-human readable format.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.
|
|
86
|
-
*/
|
|
87
|
-
export function encodeTreeSchema(schema, writeVersion) {
|
|
88
|
-
return encodeRepo(schema, writeVersion);
|
|
89
|
-
}
|
|
90
80
|
//# sourceMappingURL=schemaSummarizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AASjE,OAAO,
|
|
1
|
+
{"version":3,"file":"schemaSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/schema-index/schemaSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AASjE,OAAO,EAGN,iBAAiB,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AA2B,IAAI,IAAI,CAAC,yBAAyB,EACtF,CAAC;YACF,OAAO,CAAC,SAAS,CAChB,eAAe,EACf,WAAW,CAAC,IAAI,EAChB,GAAG,yBAAyB,CAAC,WAAW,IAAI,eAAe,EAAE,CAC7D,CAAC;QACH,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAES,KAAK,CAAC,YAAY,CAC3B,QAAgC,EAChC,KAA2B;QAE3B,MAAM,YAAY,GAAoB,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/E,kEAAkE;QAClE,0EAA0E;QAC1E,iDAAiD;QACjD,MAAM,CACL,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAC9B,KAAK,CAAC,0EAA0E,CAChF,CAAC;QAEF,MAAM,YAAY,GAAG,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3D,+DAA+D;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../../codec/index.js\";\nimport {\n\ttype MutableTreeStoredSchema,\n\ttype TreeStoredSchema,\n\tschemaDataIsEmpty,\n} from \"../../core/index.js\";\nimport {\n\tVersionedSummarizer,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport type { CollabWindow } from \"../incrementalSummarizationUtils.js\";\n\nexport const schemaStringKey = \"SchemaString\";\n\n/**\n * The versions for the schema summary format.\n */\nexport const enum SchemaSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<SchemaSummaryFormatVersion>([\n\tSchemaSummaryFormatVersion.v1,\n\tSchemaSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToSchemaSummaryFormatVersion(\n\tversion: MinimumVersionForCollab,\n): SchemaSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn SchemaSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading a schema repository.\n */\nexport class SchemaSummarizer\n\textends VersionedSummarizer<SchemaSummaryFormatVersion>\n\timplements Summarizable\n{\n\tprivate schemaIndexLastChangedSeq: number | undefined;\n\n\tpublic constructor(\n\t\tprivate readonly schema: MutableTreeStoredSchema,\n\t\tcollabWindow: CollabWindow,\n\t\tprivate readonly codec: IJsonCodec<TreeStoredSchema>,\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t) {\n\t\tsuper(\n\t\t\t\"Schema\",\n\t\t\tminVersionToSchemaSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t\tthis.schema.events.on(\"afterSchemaChange\", () => {\n\t\t\t// Invalidate the cache, as we need to regenerate the blob if the schema changes\n\t\t\t// We are assuming that schema changes from remote ops are valid, as we are in a summarization context.\n\t\t\tthis.schemaIndexLastChangedSeq = collabWindow.getCurrentSeq();\n\t\t});\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { builder, incrementalSummaryContext, stringify, fullTree = false } = props;\n\t\tif (\n\t\t\t!fullTree &&\n\t\t\tincrementalSummaryContext !== undefined &&\n\t\t\tthis.schemaIndexLastChangedSeq !== undefined &&\n\t\t\tincrementalSummaryContext.latestSummarySequenceNumber >= this.schemaIndexLastChangedSeq\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tschemaStringKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`${incrementalSummaryContext.summaryPath}/${schemaStringKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tconst dataString = stringify(this.codec.encode(this.schema));\n\t\t\tbuilder.addBlob(schemaStringKey, dataString);\n\t\t}\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(schemaStringKey);\n\t\t// After the awaits, validate that the schema is in a clean state.\n\t\t// This detects any schema that could have been accidentally added through\n\t\t// invalid means and are about to be overwritten.\n\t\tassert(\n\t\t\tschemaDataIsEmpty(this.schema),\n\t\t\t0x3da /* there should not already be stored schema when loading stored schema */,\n\t\t);\n\n\t\tconst schemaString = bufferToString(schemaBuffer, \"utf-8\");\n\t\t// Currently no Fluid handles are used, so just use JSON.parse.\n\t\tconst decoded = this.codec.decode(JSON.parse(schemaString));\n\t\tthis.schema.apply(decoded);\n\t\tthis.schemaIndexLastChangedSeq = 0;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,qBAAqB,EAI1B,YAAY,EACZ,KAAK,eAAe,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG1F,oBAAY,qBAAqB;IAChC,2BAA2B,IAAA;IAC3B,0BAA0B,IAAA;IAC1B,gCAAgC,IAAA;IAChC,2BAA2B,IAAA;IAC3B,wBAAwB,IAAA;IACxB,qBAAqB,IAAA;IACrB,yBAAyB,IAAA;IACzB,2BAA2B,IAAA;IAC3B,2BAA2B,IAAA;IAC3B,kBAAkB,IAAA;CAClB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,qBAAqB,GAAG,KAAK,CAIzE;AAED,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EACpD,IAAI,EAAE,sBAAsB,EAC5B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,CAAC,GAC1C,CAAC,GAAG,SAAS,CA6Df;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACrD,UAAU,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,EAC3D,MAAM,EAAE,qBAAqB,EAC7B,eAAe,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BAAqB,EAC7B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,CAAC,GAC1C,CAAC,GAAG,SAAS,CA6Bf;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,YAAY,GACxB,qBAAqB,GAAG,SAAS,CA4BnC"}
|
|
@@ -66,7 +66,7 @@ export function isNodeInSchema(node, schemaAndPolicy, onError) {
|
|
|
66
66
|
// Since this is testing compatibility with a stored schema (not view schema), "allowUnknownOptionalFields" does not exist at this layer.
|
|
67
67
|
// Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.
|
|
68
68
|
// Other schema evolution features like "staged" allowed types will likely cause similar issues elsewhere in this checker.
|
|
69
|
-
if (uncheckedFieldsFromNode.size
|
|
69
|
+
if (uncheckedFieldsFromNode.size > 0) {
|
|
70
70
|
return onError(SchemaValidationError.ObjectNode_FieldNotInSchema);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -125,7 +125,7 @@ export function isFieldInSchema(childNodes, schema, schemaAndPolicy, onError) {
|
|
|
125
125
|
*/
|
|
126
126
|
export function compliesWithMultiplicity(numberOfItems, multiplicity) {
|
|
127
127
|
switch (multiplicity) {
|
|
128
|
-
case Multiplicity.Single:
|
|
128
|
+
case Multiplicity.Single: {
|
|
129
129
|
if (numberOfItems < 1) {
|
|
130
130
|
return SchemaValidationError.Field_MissingRequiredChild;
|
|
131
131
|
}
|
|
@@ -135,18 +135,23 @@ export function compliesWithMultiplicity(numberOfItems, multiplicity) {
|
|
|
135
135
|
else {
|
|
136
136
|
return undefined;
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
}
|
|
139
|
+
case Multiplicity.Optional: {
|
|
139
140
|
return numberOfItems > 1
|
|
140
141
|
? SchemaValidationError.Field_MultipleChildrenNotAllowed
|
|
141
142
|
: undefined;
|
|
142
|
-
|
|
143
|
+
}
|
|
144
|
+
case Multiplicity.Sequence: {
|
|
143
145
|
return undefined;
|
|
144
|
-
|
|
146
|
+
}
|
|
147
|
+
case Multiplicity.Forbidden: {
|
|
145
148
|
return numberOfItems === 0
|
|
146
149
|
? undefined
|
|
147
150
|
: SchemaValidationError.Field_ChildInForbiddenField;
|
|
148
|
-
|
|
151
|
+
}
|
|
152
|
+
default: {
|
|
149
153
|
unreachableCase(multiplicity);
|
|
154
|
+
}
|
|
150
155
|
}
|
|
151
156
|
}
|
|
152
157
|
//# sourceMappingURL=schemaChecker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.js","sourceRoot":"","sources":["../../src/feature-libraries/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,CAAN,IAAY,qBAWX;AAXD,WAAY,qBAAqB;IAChC,+GAA2B,CAAA;IAC3B,6GAA0B,CAAA;IAC1B,yHAAgC,CAAA;IAChC,+GAA2B,CAAA;IAC3B,yGAAwB,CAAA;IACxB,mGAAqB,CAAA;IACrB,2GAAyB,CAAA;IACzB,+GAA2B,CAAA;IAC3B,+GAA2B,CAAA;IAC3B,6FAAkB,CAAA;AACnB,CAAC,EAXW,qBAAqB,KAArB,qBAAqB,QAWhC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAiC;IACjE,MAAM,IAAI,UAAU,CACnB,oCAAoC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CACvE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,QAAQ;YACzB,OAAO,SAAS,CAAC;QAClB,KAAK,YAAY,CAAC,SAAS;YAC1B,OAAO,aAAa,KAAK,CAAC;gBACzB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,qBAAqB,CAAC,2BAA2B,CAAC;QACtD;YACC,eAAe,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype TreeFieldStoredSchema,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tMultiplicity,\n\ttype SchemaAndPolicy,\n} from \"../core/index.js\";\nimport { allowsValue } from \"./valueUtilities.js\";\nimport type { MapTreeFieldViewGeneric, MinimalMapTreeNodeView } from \"./mapTreeCursor.js\";\nimport { iterableHasSome, mapIterable } from \"../util/index.js\";\n\nexport enum SchemaValidationError {\n\tField_KindNotInSchemaPolicy,\n\tField_MissingRequiredChild,\n\tField_MultipleChildrenNotAllowed,\n\tField_ChildInForbiddenField,\n\tField_NodeTypeNotAllowed,\n\tLeafNode_InvalidValue,\n\tLeafNode_FieldsNotAllowed,\n\tObjectNode_FieldNotInSchema,\n\tNonLeafNode_ValueNotAllowed,\n\tNode_MissingSchema,\n}\n\n/**\n * Throws a UsageError indicating a tree is out of schema.\n */\nexport function throwOutOfSchema(maybeError: SchemaValidationError): never {\n\tthrow new UsageError(\n\t\t`Tree does not conform to schema: ${SchemaValidationError[maybeError]}`,\n\t);\n}\n\ntype NotUndefined = number | string | boolean | bigint | symbol | object;\n\n/**\n * Deeply checks that the provided node complies with the schema based on its identifier.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the node or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isNodeInSchema<T extends NotUndefined>(\n\tnode: MinimalMapTreeNodeView,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate the schema declared by the node exists\n\tconst schema = schemaAndPolicy.schema.nodeSchema.get(node.type);\n\tif (schema === undefined) {\n\t\treturn onError(SchemaValidationError.Node_MissingSchema);\n\t}\n\n\t// Validate the node is well formed according to its schema\n\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tif (iterableHasSome(node.fields)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_FieldsNotAllowed);\n\t\t}\n\t\tif (!allowsValue(schema.leafValue, node.value)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_InvalidValue);\n\t\t}\n\t} else {\n\t\tif (node.value !== undefined) {\n\t\t\treturn onError(SchemaValidationError.NonLeafNode_ValueNotAllowed);\n\t\t}\n\n\t\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst uncheckedFieldsFromNode = new Set(mapIterable(node.fields, ([key, field]) => key));\n\t\t\tfor (const [fieldKey, fieldSchema] of schema.objectNodeFields) {\n\t\t\t\tconst nodeField = node.fields.get(fieldKey) ?? [];\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tnodeField,\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t\tuncheckedFieldsFromNode.delete(fieldKey);\n\t\t\t}\n\t\t\t// The node has fields that we did not check as part of looking at every field defined in the node's schema.\n\t\t\t// Since this is testing compatibility with a stored schema (not view schema), \"allowUnknownOptionalFields\" does not exist at this layer.\n\t\t\t// Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.\n\t\t\t// Other schema evolution features like \"staged\" allowed types will likely cause similar issues elsewhere in this checker.\n\t\t\tif (uncheckedFieldsFromNode.size !== 0) {\n\t\t\t\treturn onError(SchemaValidationError.ObjectNode_FieldNotInSchema);\n\t\t\t}\n\t\t} else if (schema instanceof MapNodeStoredSchema) {\n\t\t\tfor (const [_key, field] of node.fields) {\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tfield,\n\t\t\t\t\tschema.mapFields,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfail(0xb0e /* Unknown TreeNodeStoredSchema type */);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Deeply checks that the nodes comply with the field schema and included schema.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the field or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isFieldInSchema<T extends NotUndefined>(\n\tchildNodes: MapTreeFieldViewGeneric<MinimalMapTreeNodeView>,\n\tschema: TreeFieldStoredSchema,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate that the field kind is handled by the schema policy\n\tconst kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);\n\tif (kind === undefined) {\n\t\treturn onError(SchemaValidationError.Field_KindNotInSchemaPolicy);\n\t}\n\n\t// Validate that the field doesn't contain more nodes than its type supports\n\t{\n\t\tconst multiplicityCheck = compliesWithMultiplicity(childNodes.length, kind.multiplicity);\n\t\tif (multiplicityCheck !== undefined) {\n\t\t\treturn onError(multiplicityCheck);\n\t\t}\n\t}\n\n\tfor (const node of childNodes) {\n\t\t// Validate the type declared by the node is allowed in this field\n\t\tif (schema.types !== undefined && !schema.types.has(node.type)) {\n\t\t\treturn onError(SchemaValidationError.Field_NodeTypeNotAllowed);\n\t\t}\n\n\t\t// Validate the node complies with the type it declares to be.\n\t\tconst nodeInSchemaResult = isNodeInSchema(node, schemaAndPolicy, onError);\n\t\tif (nodeInSchemaResult !== undefined) {\n\t\t\treturn nodeInSchemaResult;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validates that a given number of items complies with the specified {@link Multiplicity | multiplicity}.\n * @param numberOfItems - Number of items.\n * @param multiplicity - Kind of multiplicity to validate against.\n * @returns `true` if the specified number of items complies with the specified multiplicity; otherwise, `false`.\n */\nexport function compliesWithMultiplicity(\n\tnumberOfItems: number,\n\tmultiplicity: Multiplicity,\n): SchemaValidationError | undefined {\n\tswitch (multiplicity) {\n\t\tcase Multiplicity.Single:\n\t\t\tif (numberOfItems < 1) {\n\t\t\t\treturn SchemaValidationError.Field_MissingRequiredChild;\n\t\t\t} else if (numberOfItems > 1) {\n\t\t\t\treturn SchemaValidationError.Field_MultipleChildrenNotAllowed;\n\t\t\t} else {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\tcase Multiplicity.Optional:\n\t\t\treturn numberOfItems > 1\n\t\t\t\t? SchemaValidationError.Field_MultipleChildrenNotAllowed\n\t\t\t\t: undefined;\n\t\tcase Multiplicity.Sequence:\n\t\t\treturn undefined;\n\t\tcase Multiplicity.Forbidden:\n\t\t\treturn numberOfItems === 0\n\t\t\t\t? undefined\n\t\t\t\t: SchemaValidationError.Field_ChildInForbiddenField;\n\t\tdefault:\n\t\t\tunreachableCase(multiplicity);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schemaChecker.js","sourceRoot":"","sources":["../../src/feature-libraries/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW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ED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACvC,aAAqB,EACrB,YAA0B;IAE1B,QAAQ,YAAY,EAAE,CAAC;QACtB,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;YAC1B,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBACvB,OAAO,qBAAqB,CAAC,0BAA0B,CAAC;YACzD,CAAC;iBAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,qBAAqB,CAAC,gCAAgC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YAClB,CAAC;QACF,CAAC;QACD,KAAK,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,OAAO,aAAa,GAAG,CAAC;gBACvB,CAAC,CAAC,qBAAqB,CAAC,gCAAgC;gBACxD,CAAC,CAAC,SAAS,CAAC;QACd,CAAC;QACD,KAAK,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,KAAK,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,OAAO,aAAa,KAAK,CAAC;gBACzB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,qBAAqB,CAAC,2BAA2B,CAAC;QACtD,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype TreeFieldStoredSchema,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tMultiplicity,\n\ttype SchemaAndPolicy,\n} from \"../core/index.js\";\nimport { allowsValue } from \"./valueUtilities.js\";\nimport type { MapTreeFieldViewGeneric, MinimalMapTreeNodeView } from \"./mapTreeCursor.js\";\nimport { iterableHasSome, mapIterable } from \"../util/index.js\";\n\nexport enum SchemaValidationError {\n\tField_KindNotInSchemaPolicy,\n\tField_MissingRequiredChild,\n\tField_MultipleChildrenNotAllowed,\n\tField_ChildInForbiddenField,\n\tField_NodeTypeNotAllowed,\n\tLeafNode_InvalidValue,\n\tLeafNode_FieldsNotAllowed,\n\tObjectNode_FieldNotInSchema,\n\tNonLeafNode_ValueNotAllowed,\n\tNode_MissingSchema,\n}\n\n/**\n * Throws a UsageError indicating a tree is out of schema.\n */\nexport function throwOutOfSchema(maybeError: SchemaValidationError): never {\n\tthrow new UsageError(\n\t\t`Tree does not conform to schema: ${SchemaValidationError[maybeError]}`,\n\t);\n}\n\ntype NotUndefined = number | string | boolean | bigint | symbol | object;\n\n/**\n * Deeply checks that the provided node complies with the schema based on its identifier.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the node or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isNodeInSchema<T extends NotUndefined>(\n\tnode: MinimalMapTreeNodeView,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate the schema declared by the node exists\n\tconst schema = schemaAndPolicy.schema.nodeSchema.get(node.type);\n\tif (schema === undefined) {\n\t\treturn onError(SchemaValidationError.Node_MissingSchema);\n\t}\n\n\t// Validate the node is well formed according to its schema\n\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tif (iterableHasSome(node.fields)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_FieldsNotAllowed);\n\t\t}\n\t\tif (!allowsValue(schema.leafValue, node.value)) {\n\t\t\treturn onError(SchemaValidationError.LeafNode_InvalidValue);\n\t\t}\n\t} else {\n\t\tif (node.value !== undefined) {\n\t\t\treturn onError(SchemaValidationError.NonLeafNode_ValueNotAllowed);\n\t\t}\n\n\t\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst uncheckedFieldsFromNode = new Set(mapIterable(node.fields, ([key, field]) => key));\n\t\t\tfor (const [fieldKey, fieldSchema] of schema.objectNodeFields) {\n\t\t\t\tconst nodeField = node.fields.get(fieldKey) ?? [];\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tnodeField,\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t\tuncheckedFieldsFromNode.delete(fieldKey);\n\t\t\t}\n\t\t\t// The node has fields that we did not check as part of looking at every field defined in the node's schema.\n\t\t\t// Since this is testing compatibility with a stored schema (not view schema), \"allowUnknownOptionalFields\" does not exist at this layer.\n\t\t\t// Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.\n\t\t\t// Other schema evolution features like \"staged\" allowed types will likely cause similar issues elsewhere in this checker.\n\t\t\tif (uncheckedFieldsFromNode.size > 0) {\n\t\t\t\treturn onError(SchemaValidationError.ObjectNode_FieldNotInSchema);\n\t\t\t}\n\t\t} else if (schema instanceof MapNodeStoredSchema) {\n\t\t\tfor (const [_key, field] of node.fields) {\n\t\t\t\tconst fieldInSchemaResult = isFieldInSchema(\n\t\t\t\t\tfield,\n\t\t\t\t\tschema.mapFields,\n\t\t\t\t\tschemaAndPolicy,\n\t\t\t\t\tonError,\n\t\t\t\t);\n\t\t\t\tif (fieldInSchemaResult !== undefined) {\n\t\t\t\t\treturn fieldInSchemaResult;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfail(0xb0e /* Unknown TreeNodeStoredSchema type */);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Deeply checks that the nodes comply with the field schema and included schema.\n *\n * @param onError - Called with the first error (if any).\n *\n * @returns the return value from `onError` if the field or anything inside of it is out of schema, otherwise `undefined`.\n */\nexport function isFieldInSchema<T extends NotUndefined>(\n\tchildNodes: MapTreeFieldViewGeneric<MinimalMapTreeNodeView>,\n\tschema: TreeFieldStoredSchema,\n\tschemaAndPolicy: SchemaAndPolicy,\n\tonError: (error: SchemaValidationError) => T,\n): T | undefined {\n\t// Validate that the field kind is handled by the schema policy\n\tconst kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);\n\tif (kind === undefined) {\n\t\treturn onError(SchemaValidationError.Field_KindNotInSchemaPolicy);\n\t}\n\n\t// Validate that the field doesn't contain more nodes than its type supports\n\t{\n\t\tconst multiplicityCheck = compliesWithMultiplicity(childNodes.length, kind.multiplicity);\n\t\tif (multiplicityCheck !== undefined) {\n\t\t\treturn onError(multiplicityCheck);\n\t\t}\n\t}\n\n\tfor (const node of childNodes) {\n\t\t// Validate the type declared by the node is allowed in this field\n\t\tif (schema.types !== undefined && !schema.types.has(node.type)) {\n\t\t\treturn onError(SchemaValidationError.Field_NodeTypeNotAllowed);\n\t\t}\n\n\t\t// Validate the node complies with the type it declares to be.\n\t\tconst nodeInSchemaResult = isNodeInSchema(node, schemaAndPolicy, onError);\n\t\tif (nodeInSchemaResult !== undefined) {\n\t\t\treturn nodeInSchemaResult;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validates that a given number of items complies with the specified {@link Multiplicity | multiplicity}.\n * @param numberOfItems - Number of items.\n * @param multiplicity - Kind of multiplicity to validate against.\n * @returns `true` if the specified number of items complies with the specified multiplicity; otherwise, `false`.\n */\nexport function compliesWithMultiplicity(\n\tnumberOfItems: number,\n\tmultiplicity: Multiplicity,\n): SchemaValidationError | undefined {\n\tswitch (multiplicity) {\n\t\tcase Multiplicity.Single: {\n\t\t\tif (numberOfItems < 1) {\n\t\t\t\treturn SchemaValidationError.Field_MissingRequiredChild;\n\t\t\t} else if (numberOfItems > 1) {\n\t\t\t\treturn SchemaValidationError.Field_MultipleChildrenNotAllowed;\n\t\t\t} else {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t\tcase Multiplicity.Optional: {\n\t\t\treturn numberOfItems > 1\n\t\t\t\t? SchemaValidationError.Field_MultipleChildrenNotAllowed\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase Multiplicity.Sequence: {\n\t\t\treturn undefined;\n\t\t}\n\t\tcase Multiplicity.Forbidden: {\n\t\t\treturn numberOfItems === 0\n\t\t\t\t? undefined\n\t\t\t\t: SchemaValidationError.Field_ChildInForbiddenField;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(multiplicity);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/sequence-field/compose.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,sBAAsB,EAG3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAEvB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAEN,KAAK,eAAe,EAQpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGN,KAAK,SAAS,EAEd,KAAK,IAAI,EAMT,MAAM,YAAY,CAAC;AA6BpB;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACtB,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,SAAS,EAClB,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,iBAAiB,EAC1B,gBAAgB,EAAE,sBAAsB,GACtC,SAAS,CAQX;AAuZD,qBAAa,YAAY;IASvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IATlC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QA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E,SAAS,EACpB,QAAQ,EAAE,SAAS,EACF,WAAW,EAAE,eAAe,EAC5B,gBAAgB,EAAE,sBAAsB;IAQnD,OAAO,IAAI,OAAO;IAIlB,GAAG,IAAI,YAAY;IAyD1B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,aAAa;CAUrB;AAED,UAAU,YAAY;IACrB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;CACf"}
|
|
@@ -254,7 +254,7 @@ function composeChildChanges(baseChange, newChange, composeChild) {
|
|
|
254
254
|
return composeChild(baseChange, newChange);
|
|
255
255
|
}
|
|
256
256
|
function composeMark(mark, moveEffects, composeChild) {
|
|
257
|
-
const nodeChanges = mark.changes
|
|
257
|
+
const nodeChanges = mark.changes === undefined ? undefined : composeChild(mark.changes);
|
|
258
258
|
const updatedMark = withUpdatedEndpoint(mark, mark.count, moveEffects);
|
|
259
259
|
return withNodeChange(updatedMark, nodeChanges);
|
|
260
260
|
}
|
|
@@ -296,14 +296,18 @@ export class ComposeQueue {
|
|
|
296
296
|
assert(newCellId !== undefined, 0x89d /* Both marks should have cell IDs */);
|
|
297
297
|
const comparison = compareCellPositionsUsingTombstones(baseCellId, newCellId, this.baseMarksCellSources, this.newMarksCellSources, this.revisionMetadata);
|
|
298
298
|
switch (comparison) {
|
|
299
|
-
case CellOrder.SameCell:
|
|
299
|
+
case CellOrder.SameCell: {
|
|
300
300
|
return this.dequeueBoth();
|
|
301
|
-
|
|
301
|
+
}
|
|
302
|
+
case CellOrder.OldThenNew: {
|
|
302
303
|
return this.dequeueBase();
|
|
303
|
-
|
|
304
|
+
}
|
|
305
|
+
case CellOrder.NewThenOld: {
|
|
304
306
|
return this.dequeueNew();
|
|
305
|
-
|
|
307
|
+
}
|
|
308
|
+
default: {
|
|
306
309
|
unreachableCase(comparison);
|
|
310
|
+
}
|
|
307
311
|
}
|
|
308
312
|
}
|
|
309
313
|
else if (areOutputCellsEmpty(baseMark)) {
|
|
@@ -380,12 +384,12 @@ function setModifyAfter(moveEffects, { revision, localId: id }, modifyAfter) {
|
|
|
380
384
|
const target = CrossFieldTarget.Source;
|
|
381
385
|
const count = 1;
|
|
382
386
|
const effect = getMoveEffect(moveEffects, target, revision, id, count, false);
|
|
383
|
-
const newEffect = effect.value
|
|
387
|
+
const newEffect = effect.value === undefined ? { modifyAfter } : { ...effect.value, modifyAfter };
|
|
384
388
|
setMoveEffect(moveEffects, target, revision, id, count, newEffect);
|
|
385
389
|
}
|
|
386
390
|
function setEndpoint(moveEffects, target, id, count, endpoint) {
|
|
387
391
|
const effect = getMoveEffect(moveEffects, target, id.revision, id.localId, count, false);
|
|
388
|
-
const newEffect = effect.value
|
|
392
|
+
const newEffect = effect.value === undefined ? { endpoint } : { ...effect.value, endpoint };
|
|
389
393
|
setMoveEffect(moveEffects, target, id.revision, id.localId, effect.length, newEffect);
|
|
390
394
|
const remainingCount = count - effect.length;
|
|
391
395
|
if (remainingCount > 0) {
|
|
@@ -394,9 +398,9 @@ function setEndpoint(moveEffects, target, id, count, endpoint) {
|
|
|
394
398
|
}
|
|
395
399
|
function setTruncatedEndpoint(moveEffects, target, id, count, truncatedEndpoint) {
|
|
396
400
|
const effect = getMoveEffect(moveEffects, target, id.revision, id.localId, count);
|
|
397
|
-
const newEffect = effect.value
|
|
398
|
-
? {
|
|
399
|
-
: { truncatedEndpoint };
|
|
401
|
+
const newEffect = effect.value === undefined
|
|
402
|
+
? { truncatedEndpoint }
|
|
403
|
+
: { ...effect.value, truncatedEndpoint };
|
|
400
404
|
setMoveEffect(moveEffects, target, id.revision, id.localId, effect.length, newEffect);
|
|
401
405
|
const remainingCount = count - effect.length;
|
|
402
406
|
if (remainingCount > 0) {
|
|
@@ -405,9 +409,9 @@ function setTruncatedEndpoint(moveEffects, target, id, count, truncatedEndpoint)
|
|
|
405
409
|
}
|
|
406
410
|
function setTruncatedEndpointForInner(moveEffects, target, id, count, truncatedEndpointForInner) {
|
|
407
411
|
const effect = getMoveEffect(moveEffects, target, id.revision, id.localId, count);
|
|
408
|
-
const newEffect = effect.value
|
|
409
|
-
? {
|
|
410
|
-
: { truncatedEndpointForInner };
|
|
412
|
+
const newEffect = effect.value === undefined
|
|
413
|
+
? { truncatedEndpointForInner }
|
|
414
|
+
: { ...effect.value, truncatedEndpointForInner };
|
|
411
415
|
setMoveEffect(moveEffects, target, id.revision, id.localId, effect.length, newEffect);
|
|
412
416
|
const remainingCount = count - effect.length;
|
|
413
417
|
if (remainingCount > 0) {
|