@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
|
@@ -9,11 +9,11 @@ export declare const validVersions: Set<number>;
|
|
|
9
9
|
* Top level length is implied from length of data array.
|
|
10
10
|
* All content are of this shape.
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const EncodedNestedArrayShape: import("@sinclair/typebox").TNumber;
|
|
13
13
|
/**
|
|
14
14
|
* Inline array.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const EncodedInlineArrayShape: import("@sinclair/typebox").TObject<{
|
|
17
17
|
length: import("@sinclair/typebox").TNumber;
|
|
18
18
|
/**
|
|
19
19
|
* All entries are this shape.
|
|
@@ -80,11 +80,11 @@ export declare enum SpecialField {
|
|
|
80
80
|
* In the future other value shape formats may be added, likely as objects.
|
|
81
81
|
*
|
|
82
82
|
* @remarks
|
|
83
|
-
* See {@link
|
|
83
|
+
* See {@link EncodedNodeShape} for usage.
|
|
84
84
|
*/
|
|
85
85
|
export declare const EncodedValueShape: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TAny>, import("@sinclair/typebox").TEnum<typeof SpecialField>]>;
|
|
86
86
|
export type EncodedValueShape = undefined | Static<typeof EncodedValueShape>;
|
|
87
|
-
export declare const
|
|
87
|
+
export declare const EncodedNodeShape: import("@sinclair/typebox").TObject<{
|
|
88
88
|
/**
|
|
89
89
|
* If not provided, inlined in data.
|
|
90
90
|
*/
|
|
@@ -103,17 +103,23 @@ export declare const EncodedTreeShape: import("@sinclair/typebox").TObject<{
|
|
|
103
103
|
extraFields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
104
104
|
}>;
|
|
105
105
|
/**
|
|
106
|
-
* Discriminated union of
|
|
106
|
+
* Discriminated union that represents the shapes of chunks in the encoded data.
|
|
107
|
+
* "Chunk" here refers to a chunk of tree data, rooted at a range of nodes, that is encoded as a
|
|
108
|
+
* single unit in a specific format represented by one of the shapes in this union.
|
|
109
|
+
*
|
|
110
|
+
* The concept of "chunk" is same for the tree data in memory and in the encoded wire format.
|
|
111
|
+
* The physical representation of the chunk may differ, but the logical structure remains the same.
|
|
112
|
+
* This is similar to other such concepts in the system.
|
|
107
113
|
*
|
|
108
114
|
* See {@link DiscriminatedUnionDispatcher} for more information on this pattern.
|
|
109
115
|
*/
|
|
110
116
|
export declare const EncodedChunkShape: import("@sinclair/typebox").TObject<{
|
|
111
117
|
/**
|
|
112
|
-
* {@link
|
|
118
|
+
* {@link EncodedNestedArrayShape} union member.
|
|
113
119
|
*/
|
|
114
120
|
a: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
115
121
|
/**
|
|
116
|
-
* {@link
|
|
122
|
+
* {@link EncodedInlineArrayShape} union member.
|
|
117
123
|
*/
|
|
118
124
|
b: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
119
125
|
length: import("@sinclair/typebox").TNumber;
|
|
@@ -123,7 +129,7 @@ export declare const EncodedChunkShape: import("@sinclair/typebox").TObject<{
|
|
|
123
129
|
shape: import("@sinclair/typebox").TNumber;
|
|
124
130
|
}>>;
|
|
125
131
|
/**
|
|
126
|
-
* {@link
|
|
132
|
+
* {@link EncodedNodeShape} union member.
|
|
127
133
|
*/
|
|
128
134
|
c: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
129
135
|
/**
|
|
@@ -149,9 +155,9 @@ export declare const EncodedChunkShape: import("@sinclair/typebox").TObject<{
|
|
|
149
155
|
d: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<0>>;
|
|
150
156
|
}>;
|
|
151
157
|
export type EncodedChunkShape = Static<typeof EncodedChunkShape>;
|
|
152
|
-
export type
|
|
153
|
-
export type
|
|
154
|
-
export type
|
|
158
|
+
export type EncodedNestedArrayShape = Static<typeof EncodedNestedArrayShape>;
|
|
159
|
+
export type EncodedInlineArrayShape = Static<typeof EncodedInlineArrayShape>;
|
|
160
|
+
export type EncodedNodeShape = Static<typeof EncodedNodeShape>;
|
|
155
161
|
export type EncodedAnyShape = Static<typeof EncodedAnyShape>;
|
|
156
162
|
export declare const EncodedFieldBatch: import("@sinclair/typebox").TObject<{
|
|
157
163
|
data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TAny>>;
|
|
@@ -159,11 +165,11 @@ export declare const EncodedFieldBatch: import("@sinclair/typebox").TObject<{
|
|
|
159
165
|
identifiers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
160
166
|
shapes: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
161
167
|
/**
|
|
162
|
-
* {@link
|
|
168
|
+
* {@link EncodedNestedArrayShape} union member.
|
|
163
169
|
*/
|
|
164
170
|
a: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
165
171
|
/**
|
|
166
|
-
* {@link
|
|
172
|
+
* {@link EncodedInlineArrayShape} union member.
|
|
167
173
|
*/
|
|
168
174
|
b: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
169
175
|
length: import("@sinclair/typebox").TNumber;
|
|
@@ -173,7 +179,7 @@ export declare const EncodedFieldBatch: import("@sinclair/typebox").TObject<{
|
|
|
173
179
|
shape: import("@sinclair/typebox").TNumber;
|
|
174
180
|
}>>;
|
|
175
181
|
/**
|
|
176
|
-
* {@link
|
|
182
|
+
* {@link EncodedNodeShape} union member.
|
|
177
183
|
*/
|
|
178
184
|
c: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
179
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAWtD,eAAO,MAAM,OAAO,IAAI,CAAC;AAIzB,eAAO,MAAM,aAAa,aAAqB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAWtD,eAAO,MAAM,OAAO,IAAI,CAAC;AAIzB,eAAO,MAAM,aAAa,aAAqB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAAa,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;IAGlC;;OAEG;;EAIJ,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,yCAAkB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2LAS5B,CAAC;AAEH,MAAM,MAAM,iBAAiB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;;EAagF,CAAC;AACtF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.EncodedFieldBatch = exports.EncodedChunkShape = exports.
|
|
7
|
+
exports.EncodedFieldBatch = exports.EncodedChunkShape = exports.EncodedNodeShape = exports.EncodedValueShape = exports.SpecialField = exports.EncodedCounter = exports.EncodedFieldShape = exports.EncodedAnyShape = exports.EncodedInlineArrayShape = exports.EncodedNestedArrayShape = exports.validVersions = exports.version = void 0;
|
|
8
8
|
const typebox_1 = require("@sinclair/typebox");
|
|
9
9
|
const index_js_1 = require("../../../codec/index.js");
|
|
10
10
|
const formatGeneric_js_1 = require("./formatGeneric.js");
|
|
@@ -16,11 +16,11 @@ exports.validVersions = new Set([exports.version]);
|
|
|
16
16
|
* Top level length is implied from length of data array.
|
|
17
17
|
* All content are of this shape.
|
|
18
18
|
*/
|
|
19
|
-
exports.
|
|
19
|
+
exports.EncodedNestedArrayShape = formatGeneric_js_1.ShapeIndex;
|
|
20
20
|
/**
|
|
21
21
|
* Inline array.
|
|
22
22
|
*/
|
|
23
|
-
exports.
|
|
23
|
+
exports.EncodedInlineArrayShape = typebox_1.Type.Object({
|
|
24
24
|
length: formatGeneric_js_1.Count,
|
|
25
25
|
/**
|
|
26
26
|
* All entries are this shape.
|
|
@@ -102,7 +102,7 @@ var SpecialField;
|
|
|
102
102
|
* In the future other value shape formats may be added, likely as objects.
|
|
103
103
|
*
|
|
104
104
|
* @remarks
|
|
105
|
-
* See {@link
|
|
105
|
+
* See {@link EncodedNodeShape} for usage.
|
|
106
106
|
*/
|
|
107
107
|
exports.EncodedValueShape = typebox_1.Type.Union([
|
|
108
108
|
typebox_1.Type.Boolean(),
|
|
@@ -111,7 +111,7 @@ exports.EncodedValueShape = typebox_1.Type.Union([
|
|
|
111
111
|
// TODO: support delta encoding and/or special node identifier handling
|
|
112
112
|
// EncodedCounter,
|
|
113
113
|
]);
|
|
114
|
-
exports.
|
|
114
|
+
exports.EncodedNodeShape = typebox_1.Type.Object({
|
|
115
115
|
/**
|
|
116
116
|
* If not provided, inlined in data.
|
|
117
117
|
*/
|
|
@@ -130,23 +130,29 @@ exports.EncodedTreeShape = typebox_1.Type.Object({
|
|
|
130
130
|
extraFields: typebox_1.Type.Optional(formatGeneric_js_1.ShapeIndex),
|
|
131
131
|
}, { additionalProperties: false });
|
|
132
132
|
/**
|
|
133
|
-
* Discriminated union of
|
|
133
|
+
* Discriminated union that represents the shapes of chunks in the encoded data.
|
|
134
|
+
* "Chunk" here refers to a chunk of tree data, rooted at a range of nodes, that is encoded as a
|
|
135
|
+
* single unit in a specific format represented by one of the shapes in this union.
|
|
136
|
+
*
|
|
137
|
+
* The concept of "chunk" is same for the tree data in memory and in the encoded wire format.
|
|
138
|
+
* The physical representation of the chunk may differ, but the logical structure remains the same.
|
|
139
|
+
* This is similar to other such concepts in the system.
|
|
134
140
|
*
|
|
135
141
|
* See {@link DiscriminatedUnionDispatcher} for more information on this pattern.
|
|
136
142
|
*/
|
|
137
143
|
exports.EncodedChunkShape = typebox_1.Type.Object({
|
|
138
144
|
/**
|
|
139
|
-
* {@link
|
|
145
|
+
* {@link EncodedNestedArrayShape} union member.
|
|
140
146
|
*/
|
|
141
|
-
a: typebox_1.Type.Optional(exports.
|
|
147
|
+
a: typebox_1.Type.Optional(exports.EncodedNestedArrayShape),
|
|
142
148
|
/**
|
|
143
|
-
* {@link
|
|
149
|
+
* {@link EncodedInlineArrayShape} union member.
|
|
144
150
|
*/
|
|
145
|
-
b: typebox_1.Type.Optional(exports.
|
|
151
|
+
b: typebox_1.Type.Optional(exports.EncodedInlineArrayShape),
|
|
146
152
|
/**
|
|
147
|
-
* {@link
|
|
153
|
+
* {@link EncodedNodeShape} union member.
|
|
148
154
|
*/
|
|
149
|
-
c: typebox_1.Type.Optional(exports.
|
|
155
|
+
c: typebox_1.Type.Optional(exports.EncodedNodeShape),
|
|
150
156
|
/**
|
|
151
157
|
* {@link EncodedAnyShape} union member.
|
|
152
158
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,sDAAuD;AAEvD,yDAK4B;AAEf,QAAA,OAAO,GAAG,CAAC,CAAC;AAEzB,0DAA0D;AAC1D,mEAAmE;AACtD,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,eAAO,CAAC,CAAC,CAAC;AAEhD;;;GAGG;AACU,QAAA,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/format.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,sDAAuD;AAEvD,yDAK4B;AAEf,QAAA,OAAO,GAAG,CAAC,CAAC;AAEzB,0DAA0D;AAC1D,mEAAmE;AACtD,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,eAAO,CAAC,CAAC,CAAC;AAEhD;;;GAGG;AACU,QAAA,uBAAuB,GAAG,6BAAU,CAAC;AAElD;;GAEG;AACU,QAAA,uBAAuB,GAAG,cAAI,CAAC,MAAM,CACjD;IACC,MAAM,EAAE,wBAAK;IACb;;OAEG;IACH,KAAK,EAAE,6BAAU;CACjB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAEF;;;;GAIG;AACU,QAAA,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C;;;GAGG;AACU,QAAA,iBAAiB,GAAG,cAAI,CAAC,KAAK,CAAC;IAC3C;;OAEG;IACH,oCAAiB;IACjB;;OAEG;IACH,6BAAU;CACV,CAAC,CAAC;AAIH,IA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EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,KAAK,CAAC,yBAAiB,CAAC,CAAC;IACpD;;;OAGG;IACH,WAAW,EAAE,cAAI,CAAC,QAAQ,CAAC,6BAAU,CAAC;CACtC,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,iBAAiB,GAAG,cAAI,CAAC,MAAM,CAC3C;IACC;;OAEG;IACH,CAAC,EAAE,cAAI,CAAC,QAAQ,CAAC,+BAAuB,CAAC;IACzC;;OAEG;IACH,CAAC,EAAE,cAAI,CAAC,QAAQ,CAAC,+BAAuB,CAAC;IACzC;;OAEG;IACH,CAAC,EAAE,cAAI,CAAC,QAAQ,CAAC,wBAAgB,CAAC;IAClC;;OAEG;IACH,CAAC,EAAE,cAAI,CAAC,QAAQ,CAAC,uBAAe,CAAC;CACjC,EACD,uBAAY,CACZ,CAAC;AASW,QAAA,iBAAiB,GAAG,IAAA,2CAAwB,EAAC,eAAO,EAAE,yBAAiB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { unionOptions } from \"../../../codec/index.js\";\n\nimport {\n\tCount,\n\tEncodedFieldBatchGeneric,\n\tIdentifierOrIndex,\n\tShapeIndex,\n} from \"./formatGeneric.js\";\n\nexport const version = 1;\n\n// Compatible versions used for format/version validation.\n// TODO: A proper version update policy will need to be documented.\nexport const validVersions = new Set([version]);\n\n/**\n * Top level length is implied from length of data array.\n * All content are of this shape.\n */\nexport const EncodedNestedArrayShape = ShapeIndex;\n\n/**\n * Inline array.\n */\nexport const EncodedInlineArrayShape = Type.Object(\n\t{\n\t\tlength: Count,\n\t\t/**\n\t\t * All entries are this shape.\n\t\t */\n\t\tshape: ShapeIndex,\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Encoded as `shape, ...[data for shape]`.\n *\n * Used for polymorphism.\n */\nexport const EncodedAnyShape = Type.Literal(0);\n\n/**\n * Content of the encoded field is specified by the Shape referenced by the ShapeIndex.\n * This is a tuple for conciseness.\n */\nexport const EncodedFieldShape = Type.Tuple([\n\t/**\n\t * Field key for this field.\n\t */\n\tIdentifierOrIndex,\n\t/**\n\t * Shape of data in this field.\n\t */\n\tShapeIndex,\n]);\n\nexport type EncodedFieldShape = Static<typeof EncodedFieldShape>;\n\nenum CounterRelativeTo {\n\t// Relative to previous node of same type in depth first pre-order traversal.\n\tPreviousNodeOfType_DepthFirstPreOrder,\n\t// TODO: add alternative relative mode relative to previous note at a path to allow delta encoded sequences (like points where x and y are delta encoded relative to previous points).\n}\n\nenum CounterMode {\n\tNumber,\n\t// TODO: document wrap modes and bit skipping. Note UUID subVersion here (ex: UUIDv4)\n\tUUID,\n}\n\n/**\n * Delta encoded value relative to a previous node's value.\n */\nexport const EncodedCounter = Type.Object(\n\t{\n\t\trelativeTo: Type.Enum(CounterRelativeTo),\n\t\t// If not provided, delta inline in data.\n\t\tdelta: Type.Optional(Type.Number()),\n\t\tmode: Type.Enum(CounterMode),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Used in {@link EncodedValueShape} for special field kind handling.\n */\nexport enum SpecialField {\n\t/**\n\t * Special case for Identifier field kind.\n\t */\n\tIdentifier = 0,\n}\n\n/**\n * Shape of a value on a node.\n *\n * Due to limitations of TypeBox and differences between JavaScript objects, TypeScript types and JSON,\n * the case where no information about the value is captured in the shape is a bit confusing.\n * In TypeBox this is allowed by the user of this type putting it in an optional property.\n * In TypeScript it is modeled using `undefined`.\n * In JavaScript the property may be missing or explicitly `undefined`.\n * In JSON this will serialize as the property being omitted.\n * In this case, the value will be encoded as either:\n * - `false` (when there is no value) OR\n * - `true, value` when there is a value.\n *\n * For a more compact encoding, there are 4 options for the shape:\n * - `true`: there is a value, and it will simply be encoded by putting it in the output buffer (so `value`).\n * - `false`: there is never a value, and it takes up no space in the output buffer.\n * - `[value]`: there is a value, and its always the same.\n * - `SpecialField.Identifier`: special case for node identifier handling.\n * Takes up no space in the output buffer: the value comes from the shape arrays's content.\n * It is wrapped in an array to differentiate value shape types.\n *\n * In the future other value shape formats may be added, likely as objects.\n *\n * @remarks\n * See {@link EncodedNodeShape} for usage.\n */\nexport const EncodedValueShape = Type.Union([\n\tType.Boolean(),\n\tType.Array(Type.Any(), { minItems: 1, maxItems: 1 }),\n\tType.Enum(SpecialField),\n\t// TODO: support delta encoding and/or special node identifier handling\n\t// EncodedCounter,\n]);\nexport type EncodedValueShape = undefined | Static<typeof EncodedValueShape>;\n\nexport const EncodedNodeShape = Type.Object(\n\t{\n\t\t/**\n\t\t * If not provided, inlined in data.\n\t\t */\n\t\ttype: Type.Optional(IdentifierOrIndex),\n\t\tvalue: Type.Optional(EncodedValueShape),\n\t\t/**\n\t\t * Fields with fixed (per key) shapes.\n\t\t * They are encoded in the order they are specified here.\n\t\t * To ensure the order is preserved, this is an array instead of an object with keys.\n\t\t */\n\t\tfields: Type.Optional(Type.Array(EncodedFieldShape)),\n\t\t/**\n\t\t * If undefined, no data. Otherwise, nested array of `[key, ...data]*`\n\t\t * Covers any fields beyond those in `fields`.\n\t\t */\n\t\textraFields: Type.Optional(ShapeIndex),\n\t},\n\t{ additionalProperties: false },\n);\n\n/**\n * Discriminated union that represents the shapes of chunks in the encoded data.\n * \"Chunk\" here refers to a chunk of tree data, rooted at a range of nodes, that is encoded as a\n * single unit in a specific format represented by one of the shapes in this union.\n *\n * The concept of \"chunk\" is same for the tree data in memory and in the encoded wire format.\n * The physical representation of the chunk may differ, but the logical structure remains the same.\n * This is similar to other such concepts in the system.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const EncodedChunkShape = Type.Object(\n\t{\n\t\t/**\n\t\t * {@link EncodedNestedArrayShape} union member.\n\t\t */\n\t\ta: Type.Optional(EncodedNestedArrayShape),\n\t\t/**\n\t\t * {@link EncodedInlineArrayShape} union member.\n\t\t */\n\t\tb: Type.Optional(EncodedInlineArrayShape),\n\t\t/**\n\t\t * {@link EncodedNodeShape} union member.\n\t\t */\n\t\tc: Type.Optional(EncodedNodeShape),\n\t\t/**\n\t\t * {@link EncodedAnyShape} union member.\n\t\t */\n\t\td: Type.Optional(EncodedAnyShape),\n\t},\n\tunionOptions,\n);\n\nexport type EncodedChunkShape = Static<typeof EncodedChunkShape>;\n\nexport type EncodedNestedArrayShape = Static<typeof EncodedNestedArrayShape>;\nexport type EncodedInlineArrayShape = Static<typeof EncodedInlineArrayShape>;\nexport type EncodedNodeShape = Static<typeof EncodedNodeShape>;\nexport type EncodedAnyShape = Static<typeof EncodedAnyShape>;\n\nexport const EncodedFieldBatch = EncodedFieldBatchGeneric(version, EncodedChunkShape);\nexport type EncodedFieldBatch = Static<typeof EncodedFieldBatch>;\n"]}
|
|
@@ -5,30 +5,36 @@
|
|
|
5
5
|
import { type ITreeCursorSynchronous, type TreeNodeSchemaIdentifier } from "../../../core/index.js";
|
|
6
6
|
import type { Counter, DeduplicationTable } from "./chunkCodecUtilities.js";
|
|
7
7
|
import { type BufferFormat, Shape } from "./chunkEncodingGeneric.js";
|
|
8
|
-
import { type
|
|
8
|
+
import { type EncoderContext, type FieldEncoder, type KeyedFieldEncoder, type NodeEncoder } from "./compressedEncode.js";
|
|
9
9
|
import type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from "./format.js";
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Encodes a node with the {@link EncodedNodeShape} shape.
|
|
12
|
+
* @remarks
|
|
13
|
+
* The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,
|
|
14
|
+
* which is an easy way to keep all the related code together without extra objects.
|
|
15
|
+
*/
|
|
16
|
+
export declare class NodeShapeBasedEncoder extends Shape<EncodedChunkShape> implements NodeEncoder {
|
|
11
17
|
readonly type: undefined | TreeNodeSchemaIdentifier;
|
|
12
18
|
readonly value: EncodedValueShape;
|
|
13
19
|
/**
|
|
14
20
|
* Encoders for a specific set of fields, by key, in the order they will be encoded.
|
|
15
21
|
* These are fields for which specialized encoding is provided as an optimization.
|
|
16
|
-
* Using these for a given field instead of falling back to {@link
|
|
22
|
+
* Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:
|
|
17
23
|
* this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
|
|
18
24
|
* Instead, this information is here, and thus is encoded only once as part of the node shape.
|
|
19
25
|
* These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
|
|
20
26
|
*
|
|
21
|
-
* Any fields not included here will be encoded using {@link
|
|
22
|
-
* If {@link
|
|
27
|
+
* Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.
|
|
28
|
+
* If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
|
|
23
29
|
*/
|
|
24
30
|
readonly specializedFieldEncoders: readonly KeyedFieldEncoder[];
|
|
25
31
|
/**
|
|
26
|
-
* Encoder for all other fields that are not in {@link
|
|
32
|
+
* Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must
|
|
27
33
|
* be encoded after the specialized fields.
|
|
28
34
|
*/
|
|
29
35
|
readonly otherFieldsEncoder: undefined | FieldEncoder;
|
|
30
36
|
/**
|
|
31
|
-
* Set of keys for fields that are encoded using {@link
|
|
37
|
+
* Set of keys for fields that are encoded using {@link NodeShapeBasedEncoder.specializedFieldEncoders}.
|
|
32
38
|
* TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.
|
|
33
39
|
*/
|
|
34
40
|
private readonly specializedFieldKeys;
|
|
@@ -36,25 +42,25 @@ export declare class NodeShape extends Shape<EncodedChunkShape> implements NodeE
|
|
|
36
42
|
/**
|
|
37
43
|
* Encoders for a specific set of fields, by key, in the order they will be encoded.
|
|
38
44
|
* These are fields for which specialized encoding is provided as an optimization.
|
|
39
|
-
* Using these for a given field instead of falling back to {@link
|
|
45
|
+
* Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:
|
|
40
46
|
* this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
|
|
41
47
|
* Instead, this information is here, and thus is encoded only once as part of the node shape.
|
|
42
48
|
* These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
|
|
43
49
|
*
|
|
44
|
-
* Any fields not included here will be encoded using {@link
|
|
45
|
-
* If {@link
|
|
50
|
+
* Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.
|
|
51
|
+
* If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
|
|
46
52
|
*/
|
|
47
53
|
specializedFieldEncoders: readonly KeyedFieldEncoder[],
|
|
48
54
|
/**
|
|
49
|
-
* Encoder for all other fields that are not in {@link
|
|
55
|
+
* Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must
|
|
50
56
|
* be encoded after the specialized fields.
|
|
51
57
|
*/
|
|
52
58
|
otherFieldsEncoder: undefined | FieldEncoder);
|
|
53
59
|
private getValueToEncode;
|
|
54
|
-
encodeNode(cursor: ITreeCursorSynchronous,
|
|
60
|
+
encodeNode(cursor: ITreeCursorSynchronous, context: EncoderContext, outputBuffer: BufferFormat<EncodedChunkShape>): void;
|
|
55
61
|
encodeShape(identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedChunkShape;
|
|
56
62
|
countReferencedShapesAndIdentifiers(identifiers: Counter<string>, shapeDiscovered: (shape: Shape<EncodedChunkShape>) => void): void;
|
|
57
|
-
get shape():
|
|
63
|
+
get shape(): Shape<EncodedChunkShape>;
|
|
58
64
|
}
|
|
59
65
|
export declare function encodeFieldShapes(fieldEncoders: readonly KeyedFieldEncoder[], identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedFieldShape[] | undefined;
|
|
60
|
-
//# sourceMappingURL=
|
|
66
|
+
//# sourceMappingURL=nodeEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEncoder.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeEncoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAG7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,KAAK,YAAY,EAAmB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3F;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,KAAK,CAAC,iBAAiB,CAAE,YAAW,WAAW;aAQxE,IAAI,EAAE,SAAS,GAAG,wBAAwB;aAC1C,KAAK,EAAE,iBAAiB;IACxC;;;;;;;;;;OAUG;aACa,wBAAwB,EAAE,SAAS,iBAAiB,EAAE;IACtE;;;OAGG;aACa,kBAAkB,EAAE,SAAS,GAAG,YAAY;IAzB7D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAgB;gBAGpC,IAAI,EAAE,SAAS,GAAG,wBAAwB,EAC1C,KAAK,EAAE,iBAAiB;IACxC;;;;;;;;;;OAUG;IACa,wBAAwB,EAAE,SAAS,iBAAiB,EAAE;IACtE;;;OAGG;IACa,kBAAkB,EAAE,SAAS,GAAG,YAAY;IAM7D,OAAO,CAAC,gBAAgB;IAajB,UAAU,CAChB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,YAAY,CAAC,iBAAiB,CAAC,GAC3C,IAAI;IAgCA,WAAW,CACjB,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB;IAWb,mCAAmC,CACzC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAC5B,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,GACxD,IAAI;IAeP,IAAW,KAAK,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAE3C;CACD;AAED,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB,EAAE,GAAG,SAAS,CAUjC"}
|
|
@@ -4,29 +4,35 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.encodeFieldShapes = exports.
|
|
7
|
+
exports.encodeFieldShapes = exports.NodeShapeBasedEncoder = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/id-compressor/internal");
|
|
10
10
|
const index_js_1 = require("../../../core/index.js");
|
|
11
11
|
const index_js_2 = require("../../../util/index.js");
|
|
12
12
|
const chunkEncodingGeneric_js_1 = require("./chunkEncodingGeneric.js");
|
|
13
13
|
const compressedEncode_js_1 = require("./compressedEncode.js");
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Encodes a node with the {@link EncodedNodeShape} shape.
|
|
16
|
+
* @remarks
|
|
17
|
+
* The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,
|
|
18
|
+
* which is an easy way to keep all the related code together without extra objects.
|
|
19
|
+
*/
|
|
20
|
+
class NodeShapeBasedEncoder extends chunkEncodingGeneric_js_1.Shape {
|
|
15
21
|
constructor(type, value,
|
|
16
22
|
/**
|
|
17
23
|
* Encoders for a specific set of fields, by key, in the order they will be encoded.
|
|
18
24
|
* These are fields for which specialized encoding is provided as an optimization.
|
|
19
|
-
* Using these for a given field instead of falling back to {@link
|
|
25
|
+
* Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:
|
|
20
26
|
* this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
|
|
21
27
|
* Instead, this information is here, and thus is encoded only once as part of the node shape.
|
|
22
28
|
* These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
|
|
23
29
|
*
|
|
24
|
-
* Any fields not included here will be encoded using {@link
|
|
25
|
-
* If {@link
|
|
30
|
+
* Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.
|
|
31
|
+
* If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
|
|
26
32
|
*/
|
|
27
33
|
specializedFieldEncoders,
|
|
28
34
|
/**
|
|
29
|
-
* Encoder for all other fields that are not in {@link
|
|
35
|
+
* Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must
|
|
30
36
|
* be encoded after the specialized fields.
|
|
31
37
|
*/
|
|
32
38
|
otherFieldsEncoder) {
|
|
@@ -37,29 +43,29 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
|
|
|
37
43
|
this.otherFieldsEncoder = otherFieldsEncoder;
|
|
38
44
|
this.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));
|
|
39
45
|
}
|
|
40
|
-
getValueToEncode(cursor,
|
|
46
|
+
getValueToEncode(cursor, context) {
|
|
41
47
|
if (this.value === 0) {
|
|
42
48
|
(0, internal_1.assert)(typeof cursor.value === "string", 0x9aa /* identifier must be type string */);
|
|
43
49
|
if ((0, internal_2.isStableId)(cursor.value)) {
|
|
44
|
-
const sessionSpaceCompressedId =
|
|
50
|
+
const sessionSpaceCompressedId = context.idCompressor.tryRecompress(cursor.value);
|
|
45
51
|
if (sessionSpaceCompressedId !== undefined) {
|
|
46
|
-
return
|
|
52
|
+
return context.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
return cursor.value;
|
|
51
57
|
}
|
|
52
|
-
encodeNode(cursor,
|
|
58
|
+
encodeNode(cursor, context, outputBuffer) {
|
|
53
59
|
if (this.type === undefined) {
|
|
54
60
|
outputBuffer.push(new chunkEncodingGeneric_js_1.IdentifierToken(cursor.type));
|
|
55
61
|
}
|
|
56
62
|
else {
|
|
57
63
|
(0, internal_1.assert)(cursor.type === this.type, 0x741 /* type must match shape */);
|
|
58
64
|
}
|
|
59
|
-
(0, compressedEncode_js_1.encodeValue)(this.getValueToEncode(cursor,
|
|
65
|
+
(0, compressedEncode_js_1.encodeValue)(this.getValueToEncode(cursor, context), this.value, outputBuffer);
|
|
60
66
|
for (const fieldEncoder of this.specializedFieldEncoders) {
|
|
61
67
|
cursor.enterField((0, index_js_2.brand)(fieldEncoder.key));
|
|
62
|
-
fieldEncoder.encoder.encodeField(cursor,
|
|
68
|
+
fieldEncoder.encoder.encodeField(cursor, context, outputBuffer);
|
|
63
69
|
cursor.exitField();
|
|
64
70
|
}
|
|
65
71
|
const otherFieldsBuffer = [];
|
|
@@ -68,7 +74,7 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
|
|
|
68
74
|
if (!this.specializedFieldKeys.has(key)) {
|
|
69
75
|
(0, internal_1.assert)(this.otherFieldsEncoder !== undefined, 0x742 /* had extra local fields when shape does not support them */);
|
|
70
76
|
otherFieldsBuffer.push(new chunkEncodingGeneric_js_1.IdentifierToken(key));
|
|
71
|
-
this.otherFieldsEncoder.encodeField(cursor,
|
|
77
|
+
this.otherFieldsEncoder.encodeField(cursor, context, otherFieldsBuffer);
|
|
72
78
|
}
|
|
73
79
|
});
|
|
74
80
|
if (this.otherFieldsEncoder !== undefined) {
|
|
@@ -101,7 +107,7 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
|
|
|
101
107
|
return this;
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
|
-
exports.
|
|
110
|
+
exports.NodeShapeBasedEncoder = NodeShapeBasedEncoder;
|
|
105
111
|
function encodeFieldShapes(fieldEncoders, identifiers, shapes) {
|
|
106
112
|
if (fieldEncoders.length === 0) {
|
|
107
113
|
return undefined;
|
|
@@ -120,10 +126,10 @@ function encodeIdentifier(identifier, identifiers) {
|
|
|
120
126
|
function encodeOptionalIdentifier(identifier, identifiers) {
|
|
121
127
|
return identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);
|
|
122
128
|
}
|
|
123
|
-
function encodeOptionalFieldShape(
|
|
124
|
-
return
|
|
129
|
+
function encodeOptionalFieldShape(encoder, shapes) {
|
|
130
|
+
return encoder === undefined ? undefined : dedupShape(encoder.shape, shapes);
|
|
125
131
|
}
|
|
126
132
|
function dedupShape(shape, shapes) {
|
|
127
133
|
return shapes.valueToIndex.get(shape) ?? (0, internal_1.fail)(0xb51 /* missing shape */);
|
|
128
134
|
}
|
|
129
|
-
//# sourceMappingURL=
|
|
135
|
+
//# sourceMappingURL=nodeEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEncoder.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeEncoder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,qEAAoE;AAEpE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAG/B;;;;;GAKG;AACH,MAAa,qBAAsB,SAAQ,+BAAwB;IAOlE,YACiB,IAA0C,EAC1C,KAAwB;IACxC;;;;;;;;;;O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AmB,CAAC;KACtF,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAS,gBAAgB,CACxB,UAAkB,EAClB,WAAuC;IAEvC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,OAAiC,EACjC,MAAoD;IAEpD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderContext,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\n\n/**\n * Encodes a node with the {@link EncodedNodeShape} shape.\n * @remarks\n * The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,\n * which is an easy way to keep all the related code together without extra objects.\n */\nexport class NodeShapeBasedEncoder extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShapeBasedEncoder.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.\n\t\t * If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, context: EncoderContext): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = context.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn context.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcontext: EncoderContext,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, context), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, context, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, context, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapeDiscovered(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapeDiscovered(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): Shape<EncodedChunkShape> {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tencoder: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn encoder === undefined ? undefined : dedupShape(encoder.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
6
6
|
import { type StoredSchemaCollection, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier } from "../../../core/index.js";
|
|
7
7
|
import type { FullSchemaPolicy } from "../../modular-schema/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { EncoderContext, type FieldEncoder, type FieldEncodeBuilder, type NodeEncodeBuilder } from "./compressedEncode.js";
|
|
9
9
|
import type { FieldBatch } from "./fieldBatch.js";
|
|
10
10
|
import { type EncodedFieldBatch } from "./format.js";
|
|
11
|
-
import {
|
|
11
|
+
import { NodeShapeBasedEncoder } from "./nodeEncoder.js";
|
|
12
12
|
/**
|
|
13
13
|
* Encode data from `fieldBatch` in into an `EncodedChunk`.
|
|
14
14
|
*
|
|
@@ -16,14 +16,14 @@ import { NodeShape } from "./nodeShape.js";
|
|
|
16
16
|
* TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.
|
|
17
17
|
*/
|
|
18
18
|
export declare function schemaCompressedEncode(schema: StoredSchemaCollection, policy: FullSchemaPolicy, fieldBatch: FieldBatch, idCompressor: IIdCompressor): EncodedFieldBatch;
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function buildContext(storedSchema: StoredSchemaCollection, policy: FullSchemaPolicy, idCompressor: IIdCompressor): EncoderContext;
|
|
20
20
|
/**
|
|
21
|
-
* Selects
|
|
21
|
+
* Selects an encoder to use to encode fields.
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function getFieldEncoder(nodeBuilder: NodeEncodeBuilder, field: TreeFieldStoredSchema, context: EncoderContext, storedSchema: StoredSchemaCollection): FieldEncoder;
|
|
24
24
|
/**
|
|
25
|
-
* Selects
|
|
25
|
+
* Selects an encoder to use to encode nodes.
|
|
26
26
|
*/
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function getNodeEncoder(fieldBuilder: FieldEncodeBuilder, storedSchema: StoredSchemaCollection, schemaName: TreeNodeSchemaIdentifier): NodeShapeBasedEncoder;
|
|
28
28
|
export declare function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined;
|
|
29
29
|
//# sourceMappingURL=schemaBasedEncode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaBasedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAIN,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAI7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"schemaBasedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAIN,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAI7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACN,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,aAAa,GACzB,iBAAiB,CAEnB;AAED,wBAAgB,YAAY,CAC3B,YAAY,EAAE,sBAAsB,EACpC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,aAAa,GACzB,cAAc,CAUhB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,WAAW,EAAE,iBAAiB,EAC9B,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,sBAAsB,GAClC,YAAY,CA8Bd;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,YAAY,EAAE,kBAAkB,EAChC,YAAY,EAAE,sBAAsB,EACpC,UAAU,EAAE,wBAAwB,GAClC,qBAAqB,CAoCvB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAU5E"}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.oneFromSet = exports.
|
|
7
|
+
exports.oneFromSet = exports.getNodeEncoder = exports.getFieldEncoder = exports.buildContext = exports.schemaCompressedEncode = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const index_js_1 = require("../../../core/index.js");
|
|
10
10
|
const compressedEncode_js_1 = require("./compressedEncode.js");
|
|
11
11
|
const format_js_1 = require("./format.js");
|
|
12
|
-
const
|
|
12
|
+
const nodeEncoder_js_1 = require("./nodeEncoder.js");
|
|
13
13
|
/**
|
|
14
14
|
* Encode data from `fieldBatch` in into an `EncodedChunk`.
|
|
15
15
|
*
|
|
@@ -17,21 +17,21 @@ const nodeShape_js_1 = require("./nodeShape.js");
|
|
|
17
17
|
* TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.
|
|
18
18
|
*/
|
|
19
19
|
function schemaCompressedEncode(schema, policy, fieldBatch, idCompressor) {
|
|
20
|
-
return (0, compressedEncode_js_1.compressedEncode)(fieldBatch,
|
|
20
|
+
return (0, compressedEncode_js_1.compressedEncode)(fieldBatch, buildContext(schema, policy, idCompressor));
|
|
21
21
|
}
|
|
22
22
|
exports.schemaCompressedEncode = schemaCompressedEncode;
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
return
|
|
23
|
+
function buildContext(storedSchema, policy, idCompressor) {
|
|
24
|
+
const context = new compressedEncode_js_1.EncoderContext((fieldBuilder, schemaName) => getNodeEncoder(fieldBuilder, storedSchema, schemaName), (nodeBuilder, fieldSchema) => getFieldEncoder(nodeBuilder, fieldSchema, context, storedSchema), policy.fieldKinds, idCompressor);
|
|
25
|
+
return context;
|
|
26
26
|
}
|
|
27
|
-
exports.
|
|
27
|
+
exports.buildContext = buildContext;
|
|
28
28
|
/**
|
|
29
|
-
* Selects
|
|
29
|
+
* Selects an encoder to use to encode fields.
|
|
30
30
|
*/
|
|
31
|
-
function
|
|
32
|
-
const kind =
|
|
31
|
+
function getFieldEncoder(nodeBuilder, field, context, storedSchema) {
|
|
32
|
+
const kind = context.fieldShapes.get(field.kind) ?? (0, internal_1.fail)(0xb52 /* missing FieldKind */);
|
|
33
33
|
const type = oneFromSet(field.types);
|
|
34
|
-
const nodeEncoder = type !== undefined ?
|
|
34
|
+
const nodeEncoder = type !== undefined ? nodeBuilder.nodeEncoderFromSchema(type) : compressedEncode_js_1.anyNodeEncoder;
|
|
35
35
|
if (kind.multiplicity === index_js_1.Multiplicity.Single) {
|
|
36
36
|
if (field.kind === index_js_1.identifierFieldKindIdentifier) {
|
|
37
37
|
(0, internal_1.assert)(type !== undefined, 0x999 /* field type must be defined in identifier field */);
|
|
@@ -39,43 +39,43 @@ function fieldShaper(treeHandler, field, cache, storedSchema) {
|
|
|
39
39
|
(0, internal_1.assert)(nodeSchema !== undefined, 0x99a /* nodeSchema must be defined */);
|
|
40
40
|
(0, internal_1.assert)(nodeSchema instanceof index_js_1.LeafNodeStoredSchema, 0x99b /* nodeSchema must be LeafNodeStoredSchema */);
|
|
41
41
|
(0, internal_1.assert)(nodeSchema.leafValue === index_js_1.ValueSchema.String, 0x99c /* identifier field can only be type string */);
|
|
42
|
-
const identifierNodeEncoder = new
|
|
42
|
+
const identifierNodeEncoder = new nodeEncoder_js_1.NodeShapeBasedEncoder(type, format_js_1.SpecialField.Identifier, [], undefined);
|
|
43
43
|
return (0, compressedEncode_js_1.asFieldEncoder)(identifierNodeEncoder);
|
|
44
44
|
}
|
|
45
45
|
return (0, compressedEncode_js_1.asFieldEncoder)(nodeEncoder);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
return
|
|
48
|
+
return context.nestedArrayEncoder(nodeEncoder);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
exports.
|
|
51
|
+
exports.getFieldEncoder = getFieldEncoder;
|
|
52
52
|
/**
|
|
53
|
-
* Selects
|
|
53
|
+
* Selects an encoder to use to encode nodes.
|
|
54
54
|
*/
|
|
55
|
-
function
|
|
56
|
-
const schema =
|
|
55
|
+
function getNodeEncoder(fieldBuilder, storedSchema, schemaName) {
|
|
56
|
+
const schema = storedSchema.nodeSchema.get(schemaName) ?? (0, internal_1.fail)(0xb53 /* missing node schema */);
|
|
57
57
|
if (schema instanceof index_js_1.ObjectNodeStoredSchema) {
|
|
58
58
|
// TODO:Performance:
|
|
59
59
|
// consider moving some optional and sequence fields to extra fields if they are commonly empty
|
|
60
60
|
// to reduce encoded size.
|
|
61
61
|
const objectNodeFields = [];
|
|
62
62
|
for (const [key, field] of schema.objectNodeFields ?? []) {
|
|
63
|
-
objectNodeFields.push({ key, encoder:
|
|
63
|
+
objectNodeFields.push({ key, encoder: fieldBuilder.fieldEncoderFromSchema(field) });
|
|
64
64
|
}
|
|
65
|
-
const shape = new
|
|
65
|
+
const shape = new nodeEncoder_js_1.NodeShapeBasedEncoder(schemaName, false, objectNodeFields, undefined);
|
|
66
66
|
return shape;
|
|
67
67
|
}
|
|
68
68
|
if (schema instanceof index_js_1.LeafNodeStoredSchema) {
|
|
69
|
-
const shape = new
|
|
69
|
+
const shape = new nodeEncoder_js_1.NodeShapeBasedEncoder(schemaName, valueShapeFromSchema(schema.leafValue), [], undefined);
|
|
70
70
|
return shape;
|
|
71
71
|
}
|
|
72
72
|
if (schema instanceof index_js_1.MapNodeStoredSchema) {
|
|
73
|
-
const shape = new
|
|
73
|
+
const shape = new nodeEncoder_js_1.NodeShapeBasedEncoder(schemaName, false, [], fieldBuilder.fieldEncoderFromSchema(schema.mapFields));
|
|
74
74
|
return shape;
|
|
75
75
|
}
|
|
76
76
|
(0, internal_1.fail)(0xb54 /* unsupported node kind */);
|
|
77
77
|
}
|
|
78
|
-
exports.
|
|
78
|
+
exports.getNodeEncoder = getNodeEncoder;
|
|
79
79
|
function oneFromSet(set) {
|
|
80
80
|
if (set === undefined) {
|
|
81
81
|
return undefined;
|