@fluidframework/tree 2.101.0 → 2.102.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/CHANGELOG.md +4 -0
- package/api-report/tree.alpha.api.md +19 -0
- package/dist/codec/codec.d.ts +22 -53
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +7 -44
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +56 -28
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +29 -12
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -2
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/tree/deltaUtil.d.ts +2 -2
- package/dist/core/tree/deltaUtil.js +2 -2
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -2
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +62 -4
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +18 -4
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +106 -3
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +9 -3
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +44 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js +5 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js +7 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +1 -2
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +5 -4
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +2 -2
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +2 -2
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +1 -1
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/isAuditableFromOutcome.d.ts +20 -0
- package/dist/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
- package/dist/shared-tree/isAuditableFromOutcome.js +36 -0
- package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -0
- package/dist/shared-tree/treeCheckout.d.ts +2 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +37 -8
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +2 -2
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +3 -3
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +2 -2
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +25 -11
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/text/codePointUtils.d.ts +48 -0
- package/dist/text/codePointUtils.d.ts.map +1 -0
- package/dist/text/codePointUtils.js +80 -0
- package/dist/text/codePointUtils.js.map +1 -0
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +4 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomain.d.ts +93 -1
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +65 -8
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +24 -6
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +29 -1
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +9 -7
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +7 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +18 -4
- package/dist/util/breakable.js.map +1 -1
- package/lib/codec/codec.d.ts +22 -53
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +7 -44
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +56 -28
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +27 -10
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/tree/deltaUtil.d.ts +2 -2
- package/lib/core/tree/deltaUtil.js +2 -2
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +5 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +2 -2
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +61 -4
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +20 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +102 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +8 -2
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js +41 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js +2 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js +6 -0
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +2 -3
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +5 -4
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +3 -3
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +2 -2
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +2 -2
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/isAuditableFromOutcome.d.ts +20 -0
- package/lib/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
- package/lib/shared-tree/isAuditableFromOutcome.js +32 -0
- package/lib/shared-tree/isAuditableFromOutcome.js.map +1 -0
- package/lib/shared-tree/treeCheckout.d.ts +2 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +37 -8
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +3 -3
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +3 -3
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +3 -3
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +25 -11
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/text/codePointUtils.d.ts +48 -0
- package/lib/text/codePointUtils.d.ts.map +1 -0
- package/lib/text/codePointUtils.js +75 -0
- package/lib/text/codePointUtils.js.map +1 -0
- package/lib/text/index.d.ts +1 -0
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +1 -0
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomain.d.ts +93 -1
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +56 -0
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +24 -6
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +30 -2
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +2 -0
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +7 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +18 -4
- package/lib/util/breakable.js.map +1 -1
- package/package.json +24 -24
- package/src/codec/codec.ts +82 -73
- package/src/codec/index.ts +2 -1
- package/src/codec/versioned/codec.ts +173 -73
- package/src/codec/versioned/index.ts +2 -1
- package/src/core/tree/deltaUtil.ts +2 -2
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -2
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -3
- package/src/core/tree/detachedFieldIndexCodecs.ts +2 -2
- package/src/feature-libraries/chunked-forest/chunkTree.ts +85 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +27 -7
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +143 -7
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +30 -28
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +7 -7
- package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +11 -7
- package/src/feature-libraries/chunked-forest/codec/format/formatVText.ts +83 -0
- package/src/feature-libraries/chunked-forest/codec/format/index.ts +6 -1
- package/src/feature-libraries/chunked-forest/codec/format/versions.ts +25 -4
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +14 -18
- package/src/feature-libraries/forest-summary/codec.ts +9 -4
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +1 -1
- package/src/feature-libraries/schema-index/codec.ts +2 -5
- package/src/index.ts +6 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/isAuditableFromOutcome.ts +34 -0
- package/src/shared-tree/treeCheckout.ts +52 -9
- package/src/shared-tree-core/editManagerCodecs.ts +4 -6
- package/src/shared-tree-core/messageCodecs.ts +4 -4
- package/src/simple-tree/core/treeNodeKernel.ts +27 -13
- package/src/text/codePointUtils.ts +81 -0
- package/src/text/index.ts +1 -0
- package/src/text/textDomain.ts +155 -2
- package/src/text/textDomainFormatted.ts +73 -2
- package/src/treeFactory.ts +5 -0
- package/src/util/breakable.ts +27 -6
|
@@ -48,14 +48,15 @@ function makeVersionedCodec<
|
|
|
48
48
|
TDecoded,
|
|
49
49
|
TEncoded extends Versioned = VersionedJson,
|
|
50
50
|
TValidate = TEncoded,
|
|
51
|
-
|
|
51
|
+
TEncodeContext = void,
|
|
52
|
+
TDecodeContext = TEncodeContext,
|
|
52
53
|
>(
|
|
53
54
|
supportedVersions: Set<FormatVersion>,
|
|
54
55
|
{ jsonValidator: validator }: ICodecOptions,
|
|
55
|
-
inner: IJsonCodec<TDecoded, TEncoded, TValidate,
|
|
56
|
-
): IJsonCodec<TDecoded, TEncoded, TValidate,
|
|
56
|
+
inner: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,
|
|
57
|
+
): IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext> {
|
|
57
58
|
const codec = {
|
|
58
|
-
encode: (data: TDecoded, context:
|
|
59
|
+
encode: (data: TDecoded, context: TEncodeContext): TEncoded => {
|
|
59
60
|
const encoded = inner.encode(data, context);
|
|
60
61
|
assert(
|
|
61
62
|
supportedVersions.has(encoded.version),
|
|
@@ -63,7 +64,7 @@ function makeVersionedCodec<
|
|
|
63
64
|
);
|
|
64
65
|
return encoded;
|
|
65
66
|
},
|
|
66
|
-
decode: (data: TValidate, context:
|
|
67
|
+
decode: (data: TValidate, context: TDecodeContext): TDecoded => {
|
|
67
68
|
const versioned = data as Versioned; // Validated by withSchemaValidation
|
|
68
69
|
if (!supportedVersions.has(versioned.version)) {
|
|
69
70
|
throw new UsageError(
|
|
@@ -96,14 +97,15 @@ function makeVersionedValidatedCodec<
|
|
|
96
97
|
TDecoded,
|
|
97
98
|
TEncoded extends Versioned = VersionedJson,
|
|
98
99
|
TValidate = TEncoded,
|
|
99
|
-
|
|
100
|
+
TEncodeContext = void,
|
|
101
|
+
TDecodeContext = TEncodeContext,
|
|
100
102
|
>(
|
|
101
103
|
options: ICodecOptions,
|
|
102
104
|
supportedVersions: Set<FormatVersion>,
|
|
103
105
|
schema: EncodedSchema,
|
|
104
|
-
codec: IJsonCodec<TDecoded, TEncoded, TValidate,
|
|
105
|
-
): IJsonCodec<TDecoded, TEncoded, TValidate,
|
|
106
|
-
Pick<CodecAndSchema<TDecoded,
|
|
106
|
+
codec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,
|
|
107
|
+
): IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext> &
|
|
108
|
+
Pick<CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>, "schema"> {
|
|
107
109
|
return {
|
|
108
110
|
...makeVersionedCodec(
|
|
109
111
|
supportedVersions,
|
|
@@ -119,12 +121,11 @@ function makeVersionedValidatedCodec<
|
|
|
119
121
|
*/
|
|
120
122
|
export function makeDiscontinuedCodecAndSchema<
|
|
121
123
|
TDecoded,
|
|
122
|
-
TContext,
|
|
123
124
|
TFormatVersion extends FormatVersion = FormatVersion,
|
|
124
125
|
>(
|
|
125
126
|
discontinuedVersion: TFormatVersion,
|
|
126
127
|
discontinuedSince: SemanticVersion,
|
|
127
|
-
): CodecVersion<TDecoded,
|
|
128
|
+
): CodecVersion<TDecoded, unknown, TFormatVersion, ICodecOptions, unknown> {
|
|
128
129
|
return {
|
|
129
130
|
minVersionForCollab: undefined,
|
|
130
131
|
formatVersion: discontinuedVersion,
|
|
@@ -150,9 +151,19 @@ export function makeDiscontinuedCodecAndSchema<
|
|
|
150
151
|
* The codec should not perform its own schema validation.
|
|
151
152
|
* The schema validation gets added when normalizing to {@link NormalizedCodecVersion}.
|
|
152
153
|
*/
|
|
153
|
-
export type CodecAndSchema<
|
|
154
|
+
export type CodecAndSchema<
|
|
155
|
+
TDecoded,
|
|
156
|
+
TEncodeContext = void,
|
|
157
|
+
TDecodeContext = TEncodeContext,
|
|
158
|
+
> = {
|
|
154
159
|
readonly schema: TSchema;
|
|
155
|
-
} & IJsonCodec<
|
|
160
|
+
} & IJsonCodec<
|
|
161
|
+
TDecoded,
|
|
162
|
+
VersionedJson,
|
|
163
|
+
JsonCompatibleReadOnly,
|
|
164
|
+
TEncodeContext,
|
|
165
|
+
TDecodeContext
|
|
166
|
+
>;
|
|
156
167
|
|
|
157
168
|
/**
|
|
158
169
|
* A codec alongside its format version and schema.
|
|
@@ -183,12 +194,13 @@ export interface CodecVersionBase<
|
|
|
183
194
|
*/
|
|
184
195
|
export interface CodecVersion<
|
|
185
196
|
TDecoded,
|
|
186
|
-
|
|
197
|
+
TEncodeContext,
|
|
187
198
|
TFormatVersion extends FormatVersion,
|
|
188
199
|
TBuildOptions extends ICodecOptions = ICodecOptions,
|
|
200
|
+
TDecodeContext = TEncodeContext,
|
|
189
201
|
> extends CodecVersionBase<
|
|
190
|
-
| CodecAndSchema<TDecoded,
|
|
191
|
-
| ((options: TBuildOptions) => CodecAndSchema<TDecoded,
|
|
202
|
+
| CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>
|
|
203
|
+
| ((options: TBuildOptions) => CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>),
|
|
192
204
|
TFormatVersion
|
|
193
205
|
> {}
|
|
194
206
|
|
|
@@ -200,21 +212,29 @@ export interface CodecVersion<
|
|
|
200
212
|
*/
|
|
201
213
|
export interface NormalizedCodecVersion<
|
|
202
214
|
TDecoded,
|
|
203
|
-
|
|
215
|
+
TEncodeContext,
|
|
204
216
|
TFormatVersion extends FormatVersion,
|
|
205
217
|
TBuildOptions extends ICodecOptions,
|
|
218
|
+
TDecodeContext = TEncodeContext,
|
|
206
219
|
> extends CodecVersionBase<
|
|
207
|
-
(options: TBuildOptions) => CodecAndSchema<TDecoded,
|
|
220
|
+
(options: TBuildOptions) => CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>,
|
|
208
221
|
TFormatVersion
|
|
209
222
|
> {}
|
|
210
223
|
|
|
211
224
|
/**
|
|
212
225
|
* {@link NormalizedCodecVersion} after applying the build options.
|
|
213
226
|
* @remarks
|
|
214
|
-
* Produced by {@link
|
|
227
|
+
* Produced by {@link VersionDispatchingCodecBuilder.applyOptions}.
|
|
215
228
|
*/
|
|
216
|
-
interface EvaluatedCodecVersion<
|
|
217
|
-
|
|
229
|
+
interface EvaluatedCodecVersion<
|
|
230
|
+
TDecoded,
|
|
231
|
+
TEncodeContext,
|
|
232
|
+
TFormatVersion extends FormatVersion,
|
|
233
|
+
TDecodeContext = TEncodeContext,
|
|
234
|
+
> extends CodecVersionBase<
|
|
235
|
+
CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>,
|
|
236
|
+
TFormatVersion
|
|
237
|
+
> {}
|
|
218
238
|
|
|
219
239
|
/**
|
|
220
240
|
* Normalize the codec to a single format.
|
|
@@ -223,17 +243,34 @@ interface EvaluatedCodecVersion<TDecoded, TContext, TFormatVersion extends Forma
|
|
|
223
243
|
*/
|
|
224
244
|
function normalizeCodecVersion<
|
|
225
245
|
TDecoded,
|
|
226
|
-
|
|
246
|
+
TEncodeContext,
|
|
227
247
|
TFormatVersion extends FormatVersion,
|
|
228
248
|
TBuildOptions extends ICodecOptions,
|
|
249
|
+
TDecodeContext = TEncodeContext,
|
|
229
250
|
>(
|
|
230
|
-
codecVersion: CodecVersion<
|
|
231
|
-
|
|
232
|
-
|
|
251
|
+
codecVersion: CodecVersion<
|
|
252
|
+
TDecoded,
|
|
253
|
+
TEncodeContext,
|
|
254
|
+
TFormatVersion,
|
|
255
|
+
TBuildOptions,
|
|
256
|
+
TDecodeContext
|
|
257
|
+
>,
|
|
258
|
+
): NormalizedCodecVersion<
|
|
259
|
+
TDecoded,
|
|
260
|
+
TEncodeContext,
|
|
261
|
+
TFormatVersion,
|
|
262
|
+
TBuildOptions,
|
|
263
|
+
TDecodeContext
|
|
264
|
+
> {
|
|
265
|
+
const codecBuilder: (
|
|
266
|
+
options: TBuildOptions,
|
|
267
|
+
) => CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext> =
|
|
233
268
|
typeof codecVersion.codec === "function"
|
|
234
269
|
? codecVersion.codec
|
|
235
|
-
: () => codecVersion.codec as CodecAndSchema<TDecoded,
|
|
236
|
-
const codec = (
|
|
270
|
+
: () => codecVersion.codec as CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext>;
|
|
271
|
+
const codec = (
|
|
272
|
+
options: TBuildOptions,
|
|
273
|
+
): CodecAndSchema<TDecoded, TEncodeContext, TDecodeContext> => {
|
|
237
274
|
const built = codecBuilder(options);
|
|
238
275
|
return makeVersionedValidatedCodec(
|
|
239
276
|
options,
|
|
@@ -251,27 +288,59 @@ function normalizeCodecVersion<
|
|
|
251
288
|
}
|
|
252
289
|
|
|
253
290
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
291
|
+
* A codec that can read multiple format versions and write a single selected version.
|
|
292
|
+
* @remarks
|
|
293
|
+
* Produced by {@link VersionDispatchingCodecBuilder.build}.
|
|
294
|
+
*
|
|
295
|
+
* @typeParam TDecoded - The in memory (not encoded) format.
|
|
296
|
+
* @typeParam TEncodeContext - Context type passed to encode operations.
|
|
297
|
+
* @typeParam TFormatVersion - The type of format version identifiers used by this codec.
|
|
298
|
+
* @typeParam TDecodeContext - Context type passed to decode operations. Defaults to `TEncodeContext`.
|
|
299
|
+
*/
|
|
300
|
+
export interface VersionDispatchingCodec<
|
|
301
|
+
TDecoded,
|
|
302
|
+
TEncodeContext,
|
|
303
|
+
TFormatVersion extends FormatVersion,
|
|
304
|
+
TDecodeContext = TEncodeContext,
|
|
305
|
+
> extends IJsonCodec<
|
|
306
|
+
TDecoded,
|
|
307
|
+
JsonCompatibleReadOnly,
|
|
308
|
+
JsonCompatibleReadOnly,
|
|
309
|
+
TEncodeContext,
|
|
310
|
+
TDecodeContext
|
|
311
|
+
> {
|
|
312
|
+
/**
|
|
313
|
+
* The format version which this codec writes.
|
|
314
|
+
* @remarks
|
|
315
|
+
* Selected by {@link VersionDispatchingCodecBuilder.build} based on the provided options.
|
|
316
|
+
*/
|
|
317
|
+
readonly writeVersion: TFormatVersion;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Creates a {@link VersionDispatchingCodec} using a {@link CodecVersion} to select the {@link VersionDispatchingCodec.writeVersion}.
|
|
256
322
|
* @privateRemarks
|
|
257
|
-
* This is a two stage builder so the first stage can encapsulate all codec specific details and
|
|
323
|
+
* This is a two stage builder so the first stage (the static build) can encapsulate all codec specific details and
|
|
324
|
+
* the second (the instance build) can bring in configuration.
|
|
258
325
|
*/
|
|
259
|
-
export class
|
|
326
|
+
export class VersionDispatchingCodecBuilder<
|
|
260
327
|
TBuildOptions extends ICodecOptions = ICodecOptions,
|
|
261
328
|
TDecoded = unknown,
|
|
262
|
-
|
|
329
|
+
TEncodeContext = unknown,
|
|
263
330
|
TFormatVersion extends FormatVersion = FormatVersion,
|
|
264
331
|
TName extends CodecName = string,
|
|
332
|
+
TDecodeContext = TEncodeContext,
|
|
265
333
|
> {
|
|
266
334
|
public readonly registry: readonly NormalizedCodecVersion<
|
|
267
335
|
TDecoded,
|
|
268
|
-
|
|
336
|
+
TEncodeContext,
|
|
269
337
|
TFormatVersion,
|
|
270
|
-
TBuildOptions
|
|
338
|
+
TBuildOptions,
|
|
339
|
+
TDecodeContext
|
|
271
340
|
>[];
|
|
272
341
|
|
|
273
342
|
/**
|
|
274
|
-
* Use {@link
|
|
343
|
+
* Use {@link VersionDispatchingCodecBuilder.build} to create an instance of this class.
|
|
275
344
|
* @remarks
|
|
276
345
|
* Inputs to this are assumed to be constants in the code controlled by the developers of this package,
|
|
277
346
|
* and constructed at least once during tests.
|
|
@@ -286,13 +355,20 @@ export class ClientVersionDispatchingCodecBuilder<
|
|
|
286
355
|
/**
|
|
287
356
|
* The registry of codecs which this builder can use to encode and decode data.
|
|
288
357
|
*/
|
|
289
|
-
inputRegistry: readonly CodecVersion<
|
|
358
|
+
inputRegistry: readonly CodecVersion<
|
|
359
|
+
TDecoded,
|
|
360
|
+
TEncodeContext,
|
|
361
|
+
TFormatVersion,
|
|
362
|
+
TBuildOptions,
|
|
363
|
+
TDecodeContext
|
|
364
|
+
>[],
|
|
290
365
|
) {
|
|
291
366
|
type Normalized = NormalizedCodecVersion<
|
|
292
367
|
TDecoded,
|
|
293
|
-
|
|
368
|
+
TEncodeContext,
|
|
294
369
|
TFormatVersion,
|
|
295
|
-
TBuildOptions
|
|
370
|
+
TBuildOptions,
|
|
371
|
+
TDecodeContext
|
|
296
372
|
>;
|
|
297
373
|
const normalizedRegistry: Normalized[] = [];
|
|
298
374
|
const formats: Set<FormatVersion> = new Set();
|
|
@@ -333,14 +409,14 @@ export class ClientVersionDispatchingCodecBuilder<
|
|
|
333
409
|
}
|
|
334
410
|
|
|
335
411
|
/**
|
|
336
|
-
* Applies
|
|
412
|
+
* Applies `options` to the codec registry to produce a list of evaluated codecs.
|
|
337
413
|
* @remarks
|
|
338
414
|
* This is used by build, which is what production code should use.
|
|
339
415
|
* This is only exposed for testing purposes.
|
|
340
416
|
*/
|
|
341
417
|
public applyOptions(
|
|
342
418
|
options: TBuildOptions,
|
|
343
|
-
): EvaluatedCodecVersion<TDecoded,
|
|
419
|
+
): EvaluatedCodecVersion<TDecoded, TEncodeContext, TFormatVersion, TDecodeContext>[] {
|
|
344
420
|
return this.registry.map((codec) => ({
|
|
345
421
|
minVersionForCollab: codec.minVersionForCollab,
|
|
346
422
|
formatVersion: codec.formatVersion,
|
|
@@ -349,26 +425,17 @@ export class ClientVersionDispatchingCodecBuilder<
|
|
|
349
425
|
}
|
|
350
426
|
|
|
351
427
|
/**
|
|
352
|
-
*
|
|
428
|
+
* Builds a complete {@link VersionDispatchingCodec} that can decode all registered versions
|
|
429
|
+
* and encode a version selected by the provided options.
|
|
353
430
|
*/
|
|
354
|
-
public build(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
JsonCompatibleReadOnly,
|
|
358
|
-
TContext
|
|
359
|
-
> & {
|
|
360
|
-
/**
|
|
361
|
-
* The format version which this codec writes.
|
|
362
|
-
* @remarks
|
|
363
|
-
* This is selected based on the provided {@link CodecWriteOptions}.
|
|
364
|
-
*/
|
|
365
|
-
readonly writeVersion: TFormatVersion;
|
|
366
|
-
} {
|
|
431
|
+
public build(
|
|
432
|
+
options: TBuildOptions & CodecWriteOptions,
|
|
433
|
+
): VersionDispatchingCodec<TDecoded, TEncodeContext, TFormatVersion, TDecodeContext> {
|
|
367
434
|
const [applied, decoder] = this.buildDecoderInternal(options);
|
|
368
435
|
const writeVersion = getWriteVersion(this.name, options, applied);
|
|
369
436
|
return {
|
|
370
437
|
...decoder,
|
|
371
|
-
encode: (data: TDecoded, context:
|
|
438
|
+
encode: (data: TDecoded, context: TEncodeContext): JsonCompatibleReadOnly => {
|
|
372
439
|
return writeVersion.codec.encode(data, context);
|
|
373
440
|
},
|
|
374
441
|
writeVersion: writeVersion.formatVersion,
|
|
@@ -378,21 +445,27 @@ export class ClientVersionDispatchingCodecBuilder<
|
|
|
378
445
|
private buildDecoderInternal(
|
|
379
446
|
options: TBuildOptions,
|
|
380
447
|
): [
|
|
381
|
-
EvaluatedCodecVersion<TDecoded,
|
|
448
|
+
EvaluatedCodecVersion<TDecoded, TEncodeContext, TFormatVersion, TDecodeContext>[],
|
|
382
449
|
Pick<
|
|
383
|
-
IJsonCodec<
|
|
450
|
+
IJsonCodec<
|
|
451
|
+
TDecoded,
|
|
452
|
+
JsonCompatibleReadOnly,
|
|
453
|
+
JsonCompatibleReadOnly,
|
|
454
|
+
TEncodeContext,
|
|
455
|
+
TDecodeContext
|
|
456
|
+
>,
|
|
384
457
|
"decode"
|
|
385
458
|
>,
|
|
386
459
|
] {
|
|
387
460
|
const applied = this.applyOptions(options);
|
|
388
461
|
const fromFormatVersion = new Map<
|
|
389
462
|
FormatVersion,
|
|
390
|
-
EvaluatedCodecVersion<TDecoded,
|
|
463
|
+
EvaluatedCodecVersion<TDecoded, TEncodeContext, TFormatVersion, TDecodeContext>
|
|
391
464
|
>(applied.map((codec) => [codec.formatVersion, codec]));
|
|
392
465
|
return [
|
|
393
466
|
applied,
|
|
394
467
|
{
|
|
395
|
-
decode: (data: JsonCompatibleReadOnly, context:
|
|
468
|
+
decode: (data: JsonCompatibleReadOnly, context: TDecodeContext): TDecoded => {
|
|
396
469
|
const versioned = data as Partial<Versioned>;
|
|
397
470
|
const codec = fromFormatVersion.get(versioned.version);
|
|
398
471
|
if (codec === undefined) {
|
|
@@ -408,12 +481,19 @@ The client which encoded this data likely specified an "minVersionForCollab" val
|
|
|
408
481
|
}
|
|
409
482
|
|
|
410
483
|
/**
|
|
411
|
-
*
|
|
484
|
+
* Builds a decoder-only codec that can decode any supported format without encoding capability.
|
|
485
|
+
*
|
|
486
|
+
* @remarks
|
|
487
|
+
* The returned codec contains only the `decode` method and can be used when only decoding is needed.
|
|
488
|
+
* This is useful for scenarios where reading/decoding versioned data is sufficient.
|
|
489
|
+
*
|
|
490
|
+
* @param options - Build options (typically containing the `jsonValidator`)
|
|
491
|
+
* @returns An object with a `decode` method that can handle any supported format version
|
|
412
492
|
*/
|
|
413
493
|
public buildDecoder(
|
|
414
494
|
options: TBuildOptions,
|
|
415
495
|
): Pick<
|
|
416
|
-
|
|
496
|
+
VersionDispatchingCodec<TDecoded, TEncodeContext, TFormatVersion, TDecodeContext>,
|
|
417
497
|
"decode"
|
|
418
498
|
> {
|
|
419
499
|
return this.buildDecoderInternal(options)[1];
|
|
@@ -429,42 +509,62 @@ The client which encoded this data likely specified an "minVersionForCollab" val
|
|
|
429
509
|
}
|
|
430
510
|
|
|
431
511
|
/**
|
|
432
|
-
*
|
|
512
|
+
* Creates a new VersionDispatchingCodecBuilder from the provided codec registry.
|
|
513
|
+
*
|
|
433
514
|
* @remarks
|
|
434
515
|
* This static method infers the types of the builder from the provided registry,
|
|
435
516
|
* making it easier to create builders without needing to explicitly specify all type parameters.
|
|
436
517
|
* This gets better type inference than the constructor.
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* const builder = VersionDispatchingCodecBuilder.build('myCodec', [
|
|
522
|
+
* { minVersionForCollab: lowestMinVersionForCollab, formatVersion: 1, codec: { encode, decode, schema } },
|
|
523
|
+
* { minVersionForCollab: '2.100.0', formatVersion: 2, codec: { encode, decode, schema } },
|
|
524
|
+
* ]);
|
|
525
|
+
* ```
|
|
437
526
|
*/
|
|
438
527
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
439
528
|
public static build<
|
|
440
529
|
Name extends CodecName,
|
|
441
|
-
Entry extends CodecVersion<unknown, unknown, FormatVersion, never>,
|
|
530
|
+
Entry extends CodecVersion<unknown, unknown, FormatVersion, never, unknown>,
|
|
442
531
|
>(name: Name, inputRegistry: readonly Entry[]) {
|
|
443
532
|
type TDecoded2 =
|
|
444
|
-
Entry extends CodecVersion<infer D, unknown, FormatVersion, never> ? D : never;
|
|
445
|
-
type
|
|
446
|
-
Entry extends CodecVersion<unknown, infer C, FormatVersion, never> ? C : never;
|
|
533
|
+
Entry extends CodecVersion<infer D, unknown, FormatVersion, never, unknown> ? D : never;
|
|
534
|
+
type TEncodeContext2 =
|
|
535
|
+
Entry extends CodecVersion<unknown, infer C, FormatVersion, never, unknown> ? C : never;
|
|
447
536
|
type TFormatVersion2 =
|
|
448
|
-
Entry extends CodecVersion<unknown, unknown, infer F, never> ? F : never;
|
|
537
|
+
Entry extends CodecVersion<unknown, unknown, infer F, never, unknown> ? F : never;
|
|
449
538
|
type TBuildOptions2 =
|
|
450
|
-
Entry extends CodecVersion<unknown, unknown, FormatVersion, infer B>
|
|
539
|
+
Entry extends CodecVersion<unknown, unknown, FormatVersion, infer B, unknown>
|
|
540
|
+
? B
|
|
541
|
+
: never;
|
|
542
|
+
type TDecodeContext2 =
|
|
543
|
+
Entry extends CodecVersion<unknown, unknown, FormatVersion, never, infer D> ? D : never;
|
|
544
|
+
|
|
545
|
+
type ResolvedEncodeContext = unknown extends TEncodeContext2 ? void : TEncodeContext2;
|
|
546
|
+
type ResolvedDecodeContext = unknown extends TDecodeContext2
|
|
547
|
+
? ResolvedEncodeContext
|
|
548
|
+
: TDecodeContext2;
|
|
451
549
|
|
|
452
550
|
type CodecFinal = CodecVersion<
|
|
453
551
|
TDecoded2,
|
|
454
552
|
// If it does not matter what context is provided, undefined is fine, so allow it to be omitted.
|
|
455
|
-
|
|
553
|
+
ResolvedEncodeContext,
|
|
456
554
|
TFormatVersion2,
|
|
457
|
-
TBuildOptions2
|
|
555
|
+
TBuildOptions2,
|
|
556
|
+
ResolvedDecodeContext
|
|
458
557
|
>;
|
|
459
558
|
|
|
460
559
|
const input = inputRegistry as readonly unknown[] as readonly CodecFinal[];
|
|
461
560
|
|
|
462
|
-
const builder = new
|
|
561
|
+
const builder = new VersionDispatchingCodecBuilder<
|
|
463
562
|
TBuildOptions2,
|
|
464
563
|
TDecoded2,
|
|
465
|
-
|
|
564
|
+
ResolvedEncodeContext,
|
|
466
565
|
TFormatVersion2,
|
|
467
|
-
Name
|
|
566
|
+
Name,
|
|
567
|
+
ResolvedDecodeContext
|
|
468
568
|
>(name, input);
|
|
469
569
|
return builder;
|
|
470
570
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
export { Versioned, versionField } from "./format.js";
|
|
7
7
|
export {
|
|
8
8
|
makeDiscontinuedCodecAndSchema,
|
|
9
|
-
|
|
9
|
+
VersionDispatchingCodecBuilder,
|
|
10
|
+
type VersionDispatchingCodec,
|
|
10
11
|
type CodecVersion,
|
|
11
12
|
type CodecAndSchema,
|
|
12
13
|
} from "./codec.js";
|
|
@@ -60,7 +60,7 @@ export function areDetachedNodeIdsEqual(a: DetachedNodeId, b: DetachedNodeId): b
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Returns true if a delta field map contains any changes that would be visible in the document (
|
|
63
|
+
* Returns true if a delta field map contains any changes that would be visible in the document (i.e., a detach or an attach)
|
|
64
64
|
* @param fields - Delta FieldMap to check for visible changes
|
|
65
65
|
* @returns True if change map contains any changes that would be visible in the document, false otherwise
|
|
66
66
|
*/
|
|
@@ -77,7 +77,7 @@ export function deltaFieldMapHasVisibleChanges(fields: FieldMap | undefined): bo
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* Returns true if the given field changes contains any changes that would be visible in the document (
|
|
80
|
+
* Returns true if the given field changes contains any changes that would be visible in the document (i.e., a detach or an attach)
|
|
81
81
|
* @param fieldChanges - Field changes to check for visible changes
|
|
82
82
|
* @returns True if the field changes contain any changes that would be visible in the document, false otherwise
|
|
83
83
|
*/
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
8
|
+
import { isFinalId } from "@fluidframework/id-compressor/internal";
|
|
8
9
|
|
|
9
10
|
import type { CodecAndSchema, IJsonCodec } from "../../codec/index.js";
|
|
10
11
|
import { brand } from "../../util/index.js";
|
|
@@ -46,7 +47,7 @@ class MajorCodec implements IJsonCodec<Major, EncodedRevisionTag> {
|
|
|
46
47
|
* The assert below will fail in such a scenario. This is addressed in the v2 codec.
|
|
47
48
|
*/
|
|
48
49
|
assert(
|
|
49
|
-
id === "root" || id
|
|
50
|
+
id === "root" || isFinalId(id),
|
|
50
51
|
0x88f /* Expected final id on encode of detached field index revision */,
|
|
51
52
|
);
|
|
52
53
|
return id;
|
|
@@ -54,7 +55,7 @@ class MajorCodec implements IJsonCodec<Major, EncodedRevisionTag> {
|
|
|
54
55
|
|
|
55
56
|
public decode(major: EncodedRevisionTag): RevisionTag {
|
|
56
57
|
assert(
|
|
57
|
-
major === "root" || major
|
|
58
|
+
major === "root" || isFinalId(major),
|
|
58
59
|
0x890 /* Expected final id on decode of detached field index revision */,
|
|
59
60
|
);
|
|
60
61
|
return this.revisionTagCodec.decode(major, {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import type { IIdCompressor, StableId } from "@fluidframework/id-compressor";
|
|
8
|
-
import { isStableId } from "@fluidframework/id-compressor/internal";
|
|
8
|
+
import { isFinalId, isStableId } from "@fluidframework/id-compressor/internal";
|
|
9
9
|
|
|
10
10
|
import type { CodecAndSchema, IJsonCodec } from "../../codec/index.js";
|
|
11
11
|
import type { EncodedRevisionTag, RevisionTagCodec, RevisionTag } from "../rebase/index.js";
|
|
@@ -25,7 +25,7 @@ class MajorCodec implements IJsonCodec<Major> {
|
|
|
25
25
|
assert(major !== undefined, 0xbfb /* Unexpected undefined revision */);
|
|
26
26
|
const id = this.revisionTagCodec.encode(major);
|
|
27
27
|
|
|
28
|
-
if (id !== "root" && id
|
|
28
|
+
if (id !== "root" && !isFinalId(id)) {
|
|
29
29
|
/**
|
|
30
30
|
* This code path handles the case where the major revision is not finalized.
|
|
31
31
|
* This can happen the SharedTree is being attached to an already attached container.
|
|
@@ -39,7 +39,9 @@ class MajorCodec implements IJsonCodec<Major> {
|
|
|
39
39
|
|
|
40
40
|
public decode(major: EncodedRevisionTag | StableId): RevisionTag {
|
|
41
41
|
assert(
|
|
42
|
-
major === "root" ||
|
|
42
|
+
major === "root" ||
|
|
43
|
+
(typeof major === "string" && isStableId(major)) ||
|
|
44
|
+
(typeof major === "number" && isFinalId(major)),
|
|
43
45
|
0xbfd /* Expected root, stable, or final compressed id */,
|
|
44
46
|
);
|
|
45
47
|
if (typeof major === "string" && isStableId(major)) {
|
|
@@ -7,7 +7,7 @@ import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
|
7
7
|
import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
VersionDispatchingCodecBuilder,
|
|
11
11
|
FluidClientVersion,
|
|
12
12
|
type ICodecOptions,
|
|
13
13
|
} from "../../codec/index.js";
|
|
@@ -22,7 +22,7 @@ type BuildData = ICodecOptions & {
|
|
|
22
22
|
readonly idCompressor: IIdCompressor;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const detachedFieldIndexCodecBuilder =
|
|
25
|
+
export const detachedFieldIndexCodecBuilder = VersionDispatchingCodecBuilder.build(
|
|
26
26
|
"DetachedFieldIndex",
|
|
27
27
|
[
|
|
28
28
|
{
|