@fluidframework/tree 2.51.0 → 2.52.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/.vscode/settings.json +0 -1
- package/CHANGELOG.md +43 -0
- package/api-report/tree.alpha.api.md +3 -2
- package/dist/codec/codec.d.ts +2 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +4 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +3 -1
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +2 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +1 -23
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +2 -2
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +2 -3
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
- package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
- package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
- package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
- package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
- package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
- package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
- package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js +2 -2
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +2 -4
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +15 -16
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +2 -3
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- 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/independentView.d.ts +8 -0
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +23 -11
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -1
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +7 -10
- 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 +1 -29
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +20 -6
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +9 -4
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +32 -0
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +1 -1
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +2 -2
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js +6 -6
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +8 -2
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +8 -7
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +35 -22
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +25 -4
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +42 -16
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +98 -0
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
- package/dist/simple-tree/api/discrepancies.js +255 -0
- package/dist/simple-tree/api/discrepancies.js.map +1 -0
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +18 -117
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +7 -4
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +5 -1
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +2 -2
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +10 -4
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +2 -2
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +15 -15
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +20 -4
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +45 -13
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/context.d.ts +13 -2
- package/dist/simple-tree/core/context.d.ts.map +1 -1
- package/dist/simple-tree/core/context.js +22 -9
- package/dist/simple-tree/core/context.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -2
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +3 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +8 -1
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +3 -0
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +2 -0
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts +2 -0
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +3 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +1 -0
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +1 -0
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +7 -8
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js +1 -2
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js +1 -2
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +4 -18
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +9 -3
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +3 -0
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +3 -0
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
- package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/walkFieldSchema.js +1 -0
- package/dist/simple-tree/walkFieldSchema.js.map +1 -1
- package/lib/codec/codec.d.ts +2 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +4 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +3 -1
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +1 -0
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +1 -23
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +2 -2
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +2 -3
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
- package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
- package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
- package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
- package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
- package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
- package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
- package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +14 -14
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +3 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +8 -0
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +21 -10
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -1
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +8 -11
- 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 +2 -30
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +20 -6
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +10 -5
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +33 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +1 -1
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +2 -2
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js +6 -6
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +8 -2
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +8 -7
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +38 -25
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +25 -4
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +43 -17
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +98 -0
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
- package/lib/simple-tree/{discrepancies.js → api/discrepancies.js} +80 -206
- package/lib/simple-tree/api/discrepancies.js.map +1 -0
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -118
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +7 -4
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +6 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +2 -2
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +8 -2
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +2 -2
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +9 -9
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +20 -4
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +42 -12
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/context.d.ts +13 -2
- package/lib/simple-tree/core/context.d.ts.map +1 -1
- package/lib/simple-tree/core/context.js +22 -9
- package/lib/simple-tree/core/context.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -2
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +8 -1
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +3 -0
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +2 -0
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts +2 -0
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +3 -1
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +1 -0
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +1 -0
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -16
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +11 -5
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +3 -0
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +3 -0
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
- package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/walkFieldSchema.js +1 -0
- package/lib/simple-tree/walkFieldSchema.js.map +1 -1
- package/package.json +23 -23
- package/src/codec/codec.ts +4 -3
- package/src/core/index.ts +2 -0
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +4 -0
- package/src/core/schema-stored/schema.ts +2 -26
- package/src/core/tree/detachedFieldIndex.ts +4 -6
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
- package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
- package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
- package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
- package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
- package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
- package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
- package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
- package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
- package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
- package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +10 -0
- package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
- package/src/feature-libraries/default-schema/index.ts +1 -1
- package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
- package/src/feature-libraries/index.ts +1 -3
- package/src/feature-libraries/modular-schema/comparison.ts +14 -29
- package/src/feature-libraries/object-forest/objectForest.ts +10 -6
- package/src/index.ts +5 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +45 -19
- package/src/shared-tree/schematizeTree.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +16 -13
- package/src/shared-tree/sharedTree.ts +2 -42
- package/src/shared-tree/treeAlpha.ts +30 -18
- package/src/shared-tree/treeCheckout.ts +54 -10
- package/src/shared-tree-core/branch.ts +1 -6
- package/src/simple-tree/api/conciseTree.ts +9 -7
- package/src/simple-tree/api/configuration.ts +8 -2
- package/src/simple-tree/api/create.ts +49 -36
- package/src/simple-tree/api/customTree.ts +59 -20
- package/src/simple-tree/{discrepancies.ts → api/discrepancies.ts} +128 -303
- package/src/simple-tree/api/schemaCompatibilityTester.ts +27 -151
- package/src/simple-tree/api/schemaFactory.ts +7 -4
- package/src/simple-tree/api/storedSchema.ts +6 -9
- package/src/simple-tree/api/treeBeta.ts +17 -4
- package/src/simple-tree/api/verboseTree.ts +17 -8
- package/src/simple-tree/core/allowedTypes.ts +54 -21
- package/src/simple-tree/core/context.ts +24 -22
- package/src/simple-tree/core/index.ts +2 -1
- package/src/simple-tree/core/treeNodeKernel.ts +1 -1
- package/src/simple-tree/core/treeNodeValid.ts +9 -2
- package/src/simple-tree/core/walkSchema.ts +3 -0
- package/src/simple-tree/createContext.ts +6 -1
- package/src/simple-tree/fieldSchema.ts +1 -0
- package/src/simple-tree/index.ts +5 -10
- package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -19
- package/src/simple-tree/node-kinds/index.ts +0 -1
- package/src/simple-tree/node-kinds/object/index.ts +0 -1
- package/src/simple-tree/node-kinds/object/objectNode.ts +9 -27
- package/src/simple-tree/prepareForInsertion.ts +17 -9
- package/src/simple-tree/toStoredSchema.ts +3 -0
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
- package/src/simple-tree/walkFieldSchema.ts +1 -0
- package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
- package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
- package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
- package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
- package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
- package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
- package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
- package/dist/feature-libraries/initializeForest.d.ts +0 -18
- package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
- package/dist/feature-libraries/initializeForest.js +0 -35
- package/dist/feature-libraries/initializeForest.js.map +0 -1
- package/dist/simple-tree/discrepancies.d.ts +0 -167
- package/dist/simple-tree/discrepancies.d.ts.map +0 -1
- package/dist/simple-tree/discrepancies.js +0 -382
- package/dist/simple-tree/discrepancies.js.map +0 -1
- package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
- package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
- package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
- package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
- package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
- package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
- package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
- package/lib/feature-libraries/initializeForest.d.ts +0 -18
- package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
- package/lib/feature-libraries/initializeForest.js +0 -31
- package/lib/feature-libraries/initializeForest.js.map +0 -1
- package/lib/simple-tree/discrepancies.d.ts +0 -167
- package/lib/simple-tree/discrepancies.d.ts.map +0 -1
- package/lib/simple-tree/discrepancies.js.map +0 -1
- package/src/feature-libraries/initializeForest.ts +0 -55
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatCommon.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAIpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,QAAQ,qCAAiC,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mDAG7B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,8HAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,eAAO,MAAM,UAAU,kKAAwB,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD;;GAEG;AAGH,eAAO,MAAM,uBAAuB,yCAA0C,MAAM,+XAMjF,CAAC;AACJ,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC;AAEzF,eAAO,MAAM,MAAM,0EACR,QAAQ,gBACJ,kBAAkB;;;;EAW/B,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Format = exports.EncodedRootsForRevision = exports.RootRanges = exports.RootRange = exports.
|
|
7
|
+
exports.Format = exports.EncodedRootsForRevision = exports.RootRanges = exports.RootRange = exports.ForestRootIdSchema = exports.DetachId = void 0;
|
|
8
8
|
const typebox_1 = require("@sinclair/typebox");
|
|
9
9
|
const index_js_1 = require("../../util/index.js");
|
|
10
|
-
const index_js_2 = require("../rebase/index.js");
|
|
11
|
-
exports.version = 1.0;
|
|
12
10
|
/**
|
|
13
11
|
* The ID of a detached node. Is not globally unique on.
|
|
14
12
|
* A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.
|
|
@@ -18,7 +16,10 @@ exports.DetachId = typebox_1.Type.Number({ multipleOf: 1 });
|
|
|
18
16
|
* The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.
|
|
19
17
|
* Is not consistent across clients.
|
|
20
18
|
*/
|
|
21
|
-
|
|
19
|
+
exports.ForestRootIdSchema = (0, index_js_1.brandedNumberType)({
|
|
20
|
+
minimum: -1,
|
|
21
|
+
multipleOf: 1,
|
|
22
|
+
});
|
|
22
23
|
/**
|
|
23
24
|
* A mapping from a range of the detached node IDs the corresponding range root IDs.
|
|
24
25
|
* The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).
|
|
@@ -28,21 +29,25 @@ exports.RootRange = typebox_1.Type.Tuple([
|
|
|
28
29
|
// ID for the first detached node
|
|
29
30
|
exports.DetachId,
|
|
30
31
|
// ID for the first root node
|
|
31
|
-
ForestRootIdSchema,
|
|
32
|
+
exports.ForestRootIdSchema,
|
|
32
33
|
]);
|
|
33
34
|
exports.RootRanges = typebox_1.Type.Array(exports.RootRange);
|
|
34
35
|
/**
|
|
35
36
|
* For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
// Return type is intentionally derived.
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
40
|
+
const EncodedRootsForRevision = (tRevisionTag) => typebox_1.Type.Union([
|
|
38
41
|
// Used to represent a revision in which more than one node were detached
|
|
39
|
-
typebox_1.Type.Tuple([
|
|
42
|
+
typebox_1.Type.Tuple([tRevisionTag, exports.RootRanges]),
|
|
40
43
|
// Used to represent a revision in which a single node was detached
|
|
41
|
-
typebox_1.Type.Tuple([
|
|
44
|
+
typebox_1.Type.Tuple([tRevisionTag, exports.DetachId, exports.ForestRootIdSchema]),
|
|
42
45
|
]);
|
|
43
|
-
exports.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
exports.EncodedRootsForRevision = EncodedRootsForRevision;
|
|
47
|
+
const Format = (tVersion, tRevisionTag) => typebox_1.Type.Object({
|
|
48
|
+
version: typebox_1.Type.Literal(tVersion),
|
|
49
|
+
data: typebox_1.Type.Array((0, exports.EncodedRootsForRevision)(tRevisionTag)),
|
|
50
|
+
maxId: exports.ForestRootIdSchema,
|
|
47
51
|
}, { additionalProperties: false });
|
|
48
|
-
|
|
52
|
+
exports.Format = Format;
|
|
53
|
+
//# sourceMappingURL=detachedFieldIndexFormatCommon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatCommon.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAoE;AAEpE,kDAAwD;AAIxD;;;GAGG;AACU,QAAA,QAAQ,GAAG,cAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;AAEvD;;;GAGG;AACU,QAAA,kBAAkB,GAAG,IAAA,4BAAiB,EAAe;IACjE,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,CAAC;CACb,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,SAAS,GAAG,cAAI,CAAC,KAAK,CAAC;IACnC,iCAAiC;IACjC,gBAAQ;IACR,6BAA6B;IAC7B,0BAAkB;CAClB,CAAC,CAAC;AAGU,QAAA,UAAU,GAAG,cAAI,CAAC,KAAK,CAAC,iBAAS,CAAC,CAAC;AAGhD;;GAEG;AACH,wCAAwC;AACxC,4EAA4E;AACrE,MAAM,uBAAuB,GAAG,CAAyB,YAAoB,EAAE,EAAE,CACvF,cAAI,CAAC,KAAK,CAAC;IACV,yEAAyE;IACzE,cAAI,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,kBAAU,CAAC,CAAC;IACtC,mEAAmE;IACnE,cAAI,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,gBAAQ,EAAE,0BAAkB,CAAC,CAAC;CACxD,CAAC,CAAC;AANS,QAAA,uBAAuB,2BAMhC;AAGG,MAAM,MAAM,GAAG,CACrB,QAAkB,EAClB,YAAgC,EAG/B,EAAE,CACH,cAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,IAAA,+BAAuB,EAAC,YAAY,CAAC,CAAC;IACvD,KAAK,EAAE,0BAAkB;CACzB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAbU,QAAA,MAAM,UAahB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, type TSchema, Type } from \"@sinclair/typebox\";\n\nimport { brandedNumberType } from \"../../util/index.js\";\n\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\n\n/**\n * The ID of a detached node. Is not globally unique on.\n * A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.\n */\nexport const DetachId = Type.Number({ multipleOf: 1 });\n\n/**\n * The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.\n * Is not consistent across clients.\n */\nexport const ForestRootIdSchema = brandedNumberType<ForestRootId>({\n\tminimum: -1,\n\tmultipleOf: 1,\n});\n\n/**\n * A mapping from a range of the detached node IDs the corresponding range root IDs.\n * The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).\n * Note: the length of the range (currently always 1) can be looked up in the forest.\n */\nexport const RootRange = Type.Tuple([\n\t// ID for the first detached node\n\tDetachId,\n\t// ID for the first root node\n\tForestRootIdSchema,\n]);\nexport type RootRange = Static<typeof RootRange>;\n\nexport const RootRanges = Type.Array(RootRange);\nexport type RootRanges = Static<typeof RootRanges>;\n\n/**\n * For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.\n */\n// Return type is intentionally derived.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport const EncodedRootsForRevision = <Schema extends TSchema>(tRevisionTag: Schema) =>\n\tType.Union([\n\t\t// Used to represent a revision in which more than one node were detached\n\t\tType.Tuple([tRevisionTag, RootRanges]),\n\t\t// Used to represent a revision in which a single node was detached\n\t\tType.Tuple([tRevisionTag, DetachId, ForestRootIdSchema]),\n\t]);\nexport type EncodedRootsForRevision = Static<ReturnType<typeof EncodedRootsForRevision>>;\n\nexport const Format = <TVersion extends number, TRevisionTagSchema extends TSchema>(\n\ttVersion: TVersion,\n\ttRevisionTag: TRevisionTagSchema,\n\t// Return type is intentionally derived.\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Literal(tVersion),\n\t\t\tdata: Type.Array(EncodedRootsForRevision(tRevisionTag)),\n\t\t\tmaxId: ForestRootIdSchema,\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n\nexport type Format = Static<ReturnType<typeof Format>>;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { Static } from "@sinclair/typebox";
|
|
6
|
+
export declare const version1 = 1;
|
|
7
|
+
export declare const FormatV1: import("@sinclair/typebox").TObject<{
|
|
8
|
+
version: import("@sinclair/typebox").TLiteral<1>;
|
|
9
|
+
data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>]>>;
|
|
10
|
+
maxId: import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>;
|
|
11
|
+
}>;
|
|
12
|
+
export type FormatV1 = Static<typeof FormatV1>;
|
|
13
|
+
//# sourceMappingURL=detachedFieldIndexFormatV1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatV1.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,eAAO,MAAM,QAAQ,IAAM,CAAC;AAE5B,eAAO,MAAM,QAAQ;;;;EAAsC,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FormatV1 = exports.version1 = void 0;
|
|
8
|
+
const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
|
|
9
|
+
const index_js_1 = require("../rebase/index.js");
|
|
10
|
+
exports.version1 = 1.0;
|
|
11
|
+
exports.FormatV1 = (0, detachedFieldIndexFormatCommon_js_1.Format)(exports.version1, index_js_1.RevisionTagSchema);
|
|
12
|
+
//# sourceMappingURL=detachedFieldIndexFormatV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatV1.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2FAA6D;AAC7D,iDAAuD;AAE1C,QAAA,QAAQ,GAAG,GAAG,CAAC;AAEf,QAAA,QAAQ,GAAG,IAAA,0CAAM,EAAC,gBAAQ,EAAE,4BAAiB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static } from \"@sinclair/typebox\";\n\nimport { Format } from \"./detachedFieldIndexFormatCommon.js\";\nimport { RevisionTagSchema } from \"../rebase/index.js\";\n\nexport const version1 = 1.0;\n\nexport const FormatV1 = Format(version1, RevisionTagSchema);\n\nexport type FormatV1 = Static<typeof FormatV1>;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type Static } from "@sinclair/typebox";
|
|
6
|
+
export declare const version2 = 2;
|
|
7
|
+
export declare const StableOrFinalRevisionTag: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>;
|
|
8
|
+
export declare const FormatV2: import("@sinclair/typebox").TObject<{
|
|
9
|
+
version: import("@sinclair/typebox").TLiteral<2>;
|
|
10
|
+
data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<import("../../util/brand.js").Brand<import("@fluidframework/id-compressor").OpSpaceCompressedId, "EncodedRevisionTag">>]>, import("@sinclair/typebox").TString]>, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>]>>;
|
|
11
|
+
maxId: import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>;
|
|
12
|
+
}>;
|
|
13
|
+
export type FormatV2 = Static<typeof FormatV2>;
|
|
14
|
+
//# sourceMappingURL=detachedFieldIndexFormatV2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatV2.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,QAAQ,IAAM,CAAC;AAE5B,eAAO,MAAM,wBAAwB,4TAAkD,CAAC;AAExF,eAAO,MAAM,QAAQ;;;;EAA6C,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FormatV2 = exports.StableOrFinalRevisionTag = exports.version2 = void 0;
|
|
8
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
9
|
+
const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
|
|
10
|
+
const index_js_1 = require("../rebase/index.js");
|
|
11
|
+
exports.version2 = 2.0;
|
|
12
|
+
exports.StableOrFinalRevisionTag = typebox_1.Type.Union([index_js_1.RevisionTagSchema, index_js_1.StableIdSchema]);
|
|
13
|
+
exports.FormatV2 = (0, detachedFieldIndexFormatCommon_js_1.Format)(exports.version2, exports.StableOrFinalRevisionTag);
|
|
14
|
+
//# sourceMappingURL=detachedFieldIndexFormatV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexFormatV2.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexFormatV2.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,2FAA6D;AAC7D,iDAAuE;AAE1D,QAAA,QAAQ,GAAG,GAAG,CAAC;AAEf,QAAA,wBAAwB,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,4BAAiB,EAAE,yBAAc,CAAC,CAAC,CAAC;AAE3E,QAAA,QAAQ,GAAG,IAAA,0CAAM,EAAC,gBAAQ,EAAE,gCAAwB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Type, type Static } from \"@sinclair/typebox\";\n\nimport { Format } from \"./detachedFieldIndexFormatCommon.js\";\nimport { RevisionTagSchema, StableIdSchema } from \"../rebase/index.js\";\n\nexport const version2 = 2.0;\n\nexport const StableOrFinalRevisionTag = Type.Union([RevisionTagSchema, StableIdSchema]);\n\nexport const FormatV2 = Format(version2, StableOrFinalRevisionTag);\n\nexport type FormatV2 = Static<typeof FormatV2>;\n"]}
|
|
@@ -6,7 +6,7 @@ import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
|
|
|
6
6
|
import type { Value, TreeChunk } from "../../../core/index.js";
|
|
7
7
|
import { type ChunkDecoder, type StreamCursor } from "./chunkCodecUtilities.js";
|
|
8
8
|
import { DecoderContext } from "./chunkDecodingGeneric.js";
|
|
9
|
-
import { type EncodedChunkShape, type EncodedFieldBatch, type
|
|
9
|
+
import { type EncodedChunkShape, type EncodedFieldBatch, type EncodedInlineArrayShape, type EncodedNestedArrayShape, type EncodedNodeShape, type EncodedValueShape } from "./format.js";
|
|
10
10
|
export interface IdDecodingContext {
|
|
11
11
|
idCompressor: IIdCompressor;
|
|
12
12
|
/**
|
|
@@ -38,19 +38,19 @@ export declare function deaggregateChunks(chunk: TreeChunk): TreeChunk[];
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function aggregateChunks(input: TreeChunk[]): TreeChunk;
|
|
40
40
|
/**
|
|
41
|
-
* Decoder for {@link
|
|
41
|
+
* Decoder for {@link EncodedNestedArrayShape}s.
|
|
42
42
|
*/
|
|
43
43
|
export declare class NestedArrayDecoder implements ChunkDecoder {
|
|
44
44
|
private readonly shape;
|
|
45
|
-
constructor(shape:
|
|
45
|
+
constructor(shape: EncodedNestedArrayShape);
|
|
46
46
|
decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Decoder for {@link
|
|
49
|
+
* Decoder for {@link EncodedInlineArrayShape}s.
|
|
50
50
|
*/
|
|
51
51
|
export declare class InlineArrayDecoder implements ChunkDecoder {
|
|
52
52
|
private readonly shape;
|
|
53
|
-
constructor(shape:
|
|
53
|
+
constructor(shape: EncodedInlineArrayShape);
|
|
54
54
|
decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -58,14 +58,14 @@ export declare class InlineArrayDecoder implements ChunkDecoder {
|
|
|
58
58
|
*/
|
|
59
59
|
export declare const anyDecoder: ChunkDecoder;
|
|
60
60
|
/**
|
|
61
|
-
* Decoder for {@link
|
|
61
|
+
* Decoder for {@link EncodedNodeShape}s.
|
|
62
62
|
*/
|
|
63
|
-
export declare class
|
|
63
|
+
export declare class NodeDecoder implements ChunkDecoder {
|
|
64
64
|
private readonly shape;
|
|
65
|
-
private readonly
|
|
65
|
+
private readonly context;
|
|
66
66
|
private readonly type?;
|
|
67
67
|
private readonly fieldDecoders;
|
|
68
|
-
constructor(shape:
|
|
68
|
+
constructor(shape: EncodedNodeShape, context: DecoderContext<EncodedChunkShape>);
|
|
69
69
|
decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
|
|
70
70
|
}
|
|
71
71
|
//# sourceMappingURL=chunkDecoding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAGX,KAAK,EACL,SAAS,EACT,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAGX,KAAK,EACL,SAAS,EACT,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,aAAa,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,QAAQ,CAAC,aAAa,CAA+B;gBAE3C,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC;IAWrD,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CAmCjF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.NodeDecoder = exports.anyDecoder = exports.InlineArrayDecoder = exports.NestedArrayDecoder = exports.aggregateChunks = exports.deaggregateChunks = exports.readValue = exports.decode = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const index_js_1 = require("../../../codec/index.js");
|
|
10
10
|
const index_js_2 = require("../../../util/index.js");
|
|
@@ -22,14 +22,14 @@ function decode(chunk, idDecodingContext) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.decode = decode;
|
|
24
24
|
const decoderLibrary = new index_js_1.DiscriminatedUnionDispatcher({
|
|
25
|
-
a(shape,
|
|
25
|
+
a(shape, context) {
|
|
26
26
|
return new NestedArrayDecoder(shape);
|
|
27
27
|
},
|
|
28
|
-
b(shape,
|
|
28
|
+
b(shape, context) {
|
|
29
29
|
return new InlineArrayDecoder(shape);
|
|
30
30
|
},
|
|
31
|
-
c(shape,
|
|
32
|
-
return new
|
|
31
|
+
c(shape, context) {
|
|
32
|
+
return new NodeDecoder(shape, context);
|
|
33
33
|
},
|
|
34
34
|
d(shape) {
|
|
35
35
|
return exports.anyDecoder;
|
|
@@ -117,7 +117,7 @@ function aggregateChunks(input) {
|
|
|
117
117
|
}
|
|
118
118
|
exports.aggregateChunks = aggregateChunks;
|
|
119
119
|
/**
|
|
120
|
-
* Decoder for {@link
|
|
120
|
+
* Decoder for {@link EncodedNestedArrayShape}s.
|
|
121
121
|
*/
|
|
122
122
|
class NestedArrayDecoder {
|
|
123
123
|
constructor(shape) {
|
|
@@ -147,7 +147,7 @@ class NestedArrayDecoder {
|
|
|
147
147
|
}
|
|
148
148
|
exports.NestedArrayDecoder = NestedArrayDecoder;
|
|
149
149
|
/**
|
|
150
|
-
* Decoder for {@link
|
|
150
|
+
* Decoder for {@link EncodedInlineArrayShape}s.
|
|
151
151
|
*/
|
|
152
152
|
class InlineArrayDecoder {
|
|
153
153
|
constructor(shape) {
|
|
@@ -175,34 +175,34 @@ exports.anyDecoder = {
|
|
|
175
175
|
},
|
|
176
176
|
};
|
|
177
177
|
/**
|
|
178
|
-
* Get a decoder for fields of a provided (via `shape` and `
|
|
178
|
+
* Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.
|
|
179
179
|
*/
|
|
180
|
-
function fieldDecoder(
|
|
181
|
-
(0, index_js_2.assertValidIndex)(shape,
|
|
180
|
+
function fieldDecoder(context, key, shape) {
|
|
181
|
+
(0, index_js_2.assertValidIndex)(shape, context.shapes);
|
|
182
182
|
return (decoders, stream) => {
|
|
183
183
|
const decoder = decoders[shape] ?? (0, internal_1.oob)();
|
|
184
184
|
return [key, decoder.decode(decoders, stream)];
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
|
-
* Decoder for {@link
|
|
188
|
+
* Decoder for {@link EncodedNodeShape}s.
|
|
189
189
|
*/
|
|
190
|
-
class
|
|
191
|
-
constructor(shape,
|
|
190
|
+
class NodeDecoder {
|
|
191
|
+
constructor(shape, context) {
|
|
192
192
|
this.shape = shape;
|
|
193
|
-
this.
|
|
194
|
-
this.type = shape.type === undefined ? undefined :
|
|
193
|
+
this.context = context;
|
|
194
|
+
this.type = shape.type === undefined ? undefined : context.identifier(shape.type);
|
|
195
195
|
const fieldDecoders = [];
|
|
196
196
|
for (const [fieldKey, fieldShape] of shape.fields ?? []) {
|
|
197
|
-
const key =
|
|
198
|
-
fieldDecoders.push(fieldDecoder(
|
|
197
|
+
const key = context.identifier(fieldKey);
|
|
198
|
+
fieldDecoders.push(fieldDecoder(context, key, fieldShape));
|
|
199
199
|
}
|
|
200
200
|
this.fieldDecoders = fieldDecoders;
|
|
201
201
|
}
|
|
202
202
|
decode(decoders, stream) {
|
|
203
|
-
const type = this.type ?? (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(stream, this.
|
|
203
|
+
const type = this.type ?? (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(stream, this.context);
|
|
204
204
|
// TODO: Consider typechecking against stored schema in here somewhere.
|
|
205
|
-
const value = readValue(stream, this.shape.value, this.
|
|
205
|
+
const value = readValue(stream, this.shape.value, this.context.idDecodingContext);
|
|
206
206
|
const fields = new Map();
|
|
207
207
|
// Helper to add fields, but with unneeded array chunks removed.
|
|
208
208
|
function addField(key, data) {
|
|
@@ -221,12 +221,12 @@ class TreeDecoder {
|
|
|
221
221
|
const decoder = decoders[this.shape.extraFields] ?? (0, internal_1.oob)();
|
|
222
222
|
const inner = (0, chunkCodecUtilities_js_1.readStreamStream)(stream);
|
|
223
223
|
while (inner.offset !== inner.data.length) {
|
|
224
|
-
const key = (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(inner, this.
|
|
224
|
+
const key = (0, chunkDecodingGeneric_js_1.readStreamIdentifier)(inner, this.context);
|
|
225
225
|
addField(key, decoder.decode(decoders, inner));
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
return new basicChunk_js_1.BasicChunk(type, fields, value);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
exports.
|
|
231
|
+
exports.NodeDecoder = NodeDecoder;
|
|
232
232
|
//# sourceMappingURL=chunkDecoding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAA0D;AAC1D,oDAA8C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W,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAA,yCAAgB,EAAC,MAAM,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9D,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArray,\n\ttype EncodedNestedArray,\n\ttype EncodedTreeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[cache: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArray, cache): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArray, cache): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedTreeShape, cache): ChunkDecoder {\n\t\treturn new TreeDecoder(shape, cache);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArray}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArray}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArray) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `cache`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcache: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, cache.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedTreeShape}s.\n */\nexport class TreeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedTreeShape,\n\t\tprivate readonly cache: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : cache.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = cache.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(cache, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.cache);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.cache.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.cache);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAA0D;AAC1D,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CASqB;AASrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E;IAE3E,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,w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AC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const field of this.fieldDecoders) {\n\t\t\tconst [key, content] = field(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
|
|
@@ -11,7 +11,9 @@ import type { EncodedFieldBatchGeneric, IdentifierOrIndex } from "./formatGeneri
|
|
|
11
11
|
/**
|
|
12
12
|
* General purpose shape based tree decoder which gets its support for specific shapes from the caller.
|
|
13
13
|
*/
|
|
14
|
-
export declare function decode<TEncodedShape extends object,
|
|
14
|
+
export declare function decode<TEncodedShape extends object, TContext>(decoderLibrary: DiscriminatedUnionDispatcher<TEncodedShape, [
|
|
15
|
+
context: TContext
|
|
16
|
+
], ChunkDecoder>, context: TContext, batch: EncodedFieldBatchGeneric<TEncodedShape>, rootDecoder: ChunkDecoder): TreeChunk[];
|
|
15
17
|
/**
|
|
16
18
|
* Shared data for use in constructing decoders.
|
|
17
19
|
*/
|
|
@@ -28,5 +30,5 @@ export declare class DecoderContext<TEncodedShape = unknown> {
|
|
|
28
30
|
/**
|
|
29
31
|
* Read one identifier from the stream, advancing the stream offset.
|
|
30
32
|
*/
|
|
31
|
-
export declare function readStreamIdentifier<T extends string & BrandedType<string, string>>(stream: StreamCursor,
|
|
33
|
+
export declare function readStreamIdentifier<T extends string & BrandedType<string, string>>(stream: StreamCursor, context: DecoderContext): T;
|
|
32
34
|
//# sourceMappingURL=chunkDecodingGeneric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"chunkDecodingGeneric.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,SAAS,MAAM,EAAE,QAAQ,EAC5D,cAAc,EAAE,4BAA4B,CAC3C,aAAa,EACb;IAAC,OAAO,EAAE,QAAQ;CAAC,EACnB,YAAY,CACZ,EACD,OAAO,EAAE,QAAQ,EACjB,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,EAC9C,WAAW,EAAE,YAAY,GACvB,SAAS,EAAE,CAcb;AAED;;GAEG;AACH,qBAAa,cAAc,CAAC,aAAa,GAAG,OAAO;aAKjC,WAAW,EAAE,SAAS,MAAM,EAAE;aAC9B,MAAM,EAAE,SAAS,aAAa,EAAE;aAChC,iBAAiB,EAAE,iBAAiB;IANrD;;OAEG;gBAEc,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,iBAAiB,EAAE,iBAAiB;IAG9C,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,OAAO,EAAE,iBAAiB,GACxB,CAAC;CAMJ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClF,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,cAAc,GACrB,CAAC,CAOH"}
|
|
@@ -10,8 +10,8 @@ const chunkCodecUtilities_js_1 = require("./chunkCodecUtilities.js");
|
|
|
10
10
|
/**
|
|
11
11
|
* General purpose shape based tree decoder which gets its support for specific shapes from the caller.
|
|
12
12
|
*/
|
|
13
|
-
function decode(decoderLibrary,
|
|
14
|
-
const decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape,
|
|
13
|
+
function decode(decoderLibrary, context, batch, rootDecoder) {
|
|
14
|
+
const decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, context));
|
|
15
15
|
const chunks = [];
|
|
16
16
|
for (const field of batch.data) {
|
|
17
17
|
const stream = { data: field, offset: 0 };
|
|
@@ -45,10 +45,10 @@ exports.DecoderContext = DecoderContext;
|
|
|
45
45
|
/**
|
|
46
46
|
* Read one identifier from the stream, advancing the stream offset.
|
|
47
47
|
*/
|
|
48
|
-
function readStreamIdentifier(stream,
|
|
48
|
+
function readStreamIdentifier(stream, context) {
|
|
49
49
|
const content = (0, chunkCodecUtilities_js_1.readStream)(stream);
|
|
50
50
|
(0, internal_1.assert)(typeof content === "number" || typeof content === "string", 0x73b /* content to be a number or string */);
|
|
51
|
-
return
|
|
51
|
+
return context.identifier(content);
|
|
52
52
|
}
|
|
53
53
|
exports.readStreamIdentifier = readStreamIdentifier;
|
|
54
54
|
//# sourceMappingURL=chunkDecodingGeneric.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,qEAKkC;AAIlC;;GAEG;AACH,SAAgB,MAAM,CACrB,
|
|
1
|
+
{"version":3,"file":"chunkDecodingGeneric.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,qEAKkC;AAIlC;;GAEG;AACH,SAAgB,MAAM,CACrB,cAIC,EACD,OAAiB,EACjB,KAA8C,EAC9C,WAAyB;IAEzB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACtF,MAAM,MAAM,GAAgB,EAAE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ft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type { TreeChunk } from \"../../../core/index.js\";\nimport type { BrandedType } from \"../../../util/index.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n} from \"./chunkCodecUtilities.js\";\nimport type { IdDecodingContext } from \"./chunkDecoding.js\";\nimport type { EncodedFieldBatchGeneric, IdentifierOrIndex } from \"./formatGeneric.js\";\n\n/**\n * General purpose shape based tree decoder which gets its support for specific shapes from the caller.\n */\nexport function decode<TEncodedShape extends object, TContext>(\n\tdecoderLibrary: DiscriminatedUnionDispatcher<\n\t\tTEncodedShape,\n\t\t[context: TContext],\n\t\tChunkDecoder\n\t>,\n\tcontext: TContext,\n\tbatch: EncodedFieldBatchGeneric<TEncodedShape>,\n\trootDecoder: ChunkDecoder,\n): TreeChunk[] {\n\tconst decoders = batch.shapes.map((shape) => decoderLibrary.dispatch(shape, context));\n\tconst chunks: TreeChunk[] = [];\n\tfor (const field of batch.data) {\n\t\tconst stream = { data: field, offset: 0 };\n\t\tconst result = rootDecoder.decode(decoders, stream);\n\t\tassert(\n\t\t\tstream.offset === stream.data.length,\n\t\t\t0x73a /* expected decode to consume full stream */,\n\t\t);\n\t\tchunks.push(result);\n\t}\n\n\treturn chunks;\n}\n\n/**\n * Shared data for use in constructing decoders.\n */\nexport class DecoderContext<TEncodedShape = unknown> {\n\t/**\n\t * @param identifiers - identifier substitution table (use to replace numeric identifier indexes with the actual identifiers from this table).\n\t */\n\tpublic constructor(\n\t\tpublic readonly identifiers: readonly string[],\n\t\tpublic readonly shapes: readonly TEncodedShape[],\n\t\tpublic readonly idDecodingContext: IdDecodingContext,\n\t) {}\n\n\tpublic identifier<T extends string & BrandedType<string, string>>(\n\t\tencoded: IdentifierOrIndex,\n\t): T {\n\t\tif (typeof encoded === \"string\") {\n\t\t\treturn encoded as T;\n\t\t}\n\t\treturn getChecked(this.identifiers, encoded) as T;\n\t}\n}\n\n/**\n * Read one identifier from the stream, advancing the stream offset.\n */\nexport function readStreamIdentifier<T extends string & BrandedType<string, string>>(\n\tstream: StreamCursor,\n\tcontext: DecoderContext,\n): T {\n\tconst content = readStream(stream);\n\tassert(\n\t\ttypeof content === \"number\" || typeof content === \"string\",\n\t\t0x73b /* content to be a number or string */,\n\t);\n\treturn context.identifier(content);\n}\n"]}
|