@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
package/src/codec/codec.ts
CHANGED
|
@@ -173,8 +173,9 @@ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
* `
|
|
177
|
-
*
|
|
176
|
+
* `TEncodeContext` and `TDecodeContext` allow passing context to the codec which may configure how data is encoded/decoded.
|
|
177
|
+
* `TDecodeContext` defaults to `TEncodeContext`; specify them separately when encode and decode need different context (for example, when encoding uses heuristics that are unneeded when decoding).
|
|
178
|
+
* These parameters are typically used for:
|
|
178
179
|
* - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.
|
|
179
180
|
* The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating
|
|
180
181
|
* additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the
|
|
@@ -196,9 +197,10 @@ export interface IJsonCodec<
|
|
|
196
197
|
TDecoded,
|
|
197
198
|
TEncoded = JsonCompatibleReadOnly,
|
|
198
199
|
TValidate = TEncoded,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
TEncodeContext = void,
|
|
201
|
+
TDecodeContext = TEncodeContext,
|
|
202
|
+
> extends IEncoder<TDecoded, TEncoded, TEncodeContext>,
|
|
203
|
+
IDecoder<TDecoded, TValidate, TDecodeContext> {
|
|
202
204
|
encodedSchema?: TAnySchema;
|
|
203
205
|
}
|
|
204
206
|
|
|
@@ -211,9 +213,13 @@ export interface IJsonCodec<
|
|
|
211
213
|
*
|
|
212
214
|
* This portion of a codec is not responsible for managing versioning or validation of the data against the schema.
|
|
213
215
|
*/
|
|
214
|
-
export interface JsonCodecPart<
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
export interface JsonCodecPart<
|
|
217
|
+
TDecoded,
|
|
218
|
+
TEncodedSchema extends TAnySchema,
|
|
219
|
+
TEncodeContext = void,
|
|
220
|
+
TDecodeContext = TEncodeContext,
|
|
221
|
+
> extends IEncoder<TDecoded, Static<TEncodedSchema>, TEncodeContext>,
|
|
222
|
+
IDecoder<TDecoded, Static<TEncodedSchema>, TDecodeContext> {
|
|
217
223
|
/**
|
|
218
224
|
* TypeBox schema which describes the encoded format for this chunk of data.
|
|
219
225
|
* @remarks
|
|
@@ -230,11 +236,18 @@ export function eraseEncodedType<
|
|
|
230
236
|
TDecoded,
|
|
231
237
|
TEncoded = JsonCompatibleReadOnly,
|
|
232
238
|
TValidate = TEncoded,
|
|
233
|
-
|
|
239
|
+
TEncodeContext = void,
|
|
240
|
+
TDecodeContext = TEncodeContext,
|
|
234
241
|
>(
|
|
235
|
-
codec: IJsonCodec<TDecoded, TEncoded, TValidate,
|
|
236
|
-
): IJsonCodec<TDecoded, TValidate, TValidate,
|
|
237
|
-
return codec as unknown as IJsonCodec<
|
|
242
|
+
codec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,
|
|
243
|
+
): IJsonCodec<TDecoded, TValidate, TValidate, TEncodeContext, TDecodeContext> {
|
|
244
|
+
return codec as unknown as IJsonCodec<
|
|
245
|
+
TDecoded,
|
|
246
|
+
TValidate,
|
|
247
|
+
TValidate,
|
|
248
|
+
TEncodeContext,
|
|
249
|
+
TDecodeContext
|
|
250
|
+
>;
|
|
238
251
|
}
|
|
239
252
|
|
|
240
253
|
/**
|
|
@@ -246,11 +259,15 @@ export function eraseEncodedType<
|
|
|
246
259
|
* allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not
|
|
247
260
|
* involve mixed format versions.
|
|
248
261
|
*
|
|
249
|
-
* @privateRemarks
|
|
250
|
-
*
|
|
251
|
-
*
|
|
262
|
+
* @privateRemarks
|
|
263
|
+
* Encode and decode can be parameterized independently — the encode-side context type need not equal the decode-side context type.
|
|
264
|
+
* `TDecodeContext` defaults to `TEncodeContext` so callers that share a single context shape (the common case) don't need to specify it.
|
|
252
265
|
*/
|
|
253
|
-
export interface ICodecFamily<
|
|
266
|
+
export interface ICodecFamily<
|
|
267
|
+
TDecoded,
|
|
268
|
+
TEncodeContext = void,
|
|
269
|
+
TDecodeContext = TEncodeContext,
|
|
270
|
+
> {
|
|
254
271
|
/**
|
|
255
272
|
* @returns a codec that can be used to encode and decode data in the specified format.
|
|
256
273
|
* @throws if the format version is not supported by this family.
|
|
@@ -260,7 +277,13 @@ export interface ICodecFamily<TDecoded, TContext = void> {
|
|
|
260
277
|
*/
|
|
261
278
|
resolve(
|
|
262
279
|
formatVersion: FormatVersion,
|
|
263
|
-
): IJsonCodec<
|
|
280
|
+
): IJsonCodec<
|
|
281
|
+
TDecoded,
|
|
282
|
+
JsonCompatibleReadOnly,
|
|
283
|
+
JsonCompatibleReadOnly,
|
|
284
|
+
TEncodeContext,
|
|
285
|
+
TDecodeContext
|
|
286
|
+
>;
|
|
264
287
|
|
|
265
288
|
/**
|
|
266
289
|
* @returns an iterable of all format versions supported by this family.
|
|
@@ -338,17 +361,29 @@ export const DependentFormatVersion = {
|
|
|
338
361
|
/**
|
|
339
362
|
* Creates a codec family from a registry of codecs.
|
|
340
363
|
*/
|
|
341
|
-
export function makeCodecFamily<TDecoded,
|
|
364
|
+
export function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(
|
|
342
365
|
registry: Iterable<
|
|
343
366
|
[
|
|
344
367
|
formatVersion: FormatVersion,
|
|
345
|
-
codec: IJsonCodec<
|
|
368
|
+
codec: IJsonCodec<
|
|
369
|
+
TDecoded,
|
|
370
|
+
JsonCompatibleReadOnly,
|
|
371
|
+
JsonCompatibleReadOnly,
|
|
372
|
+
TEncodeContext,
|
|
373
|
+
TDecodeContext
|
|
374
|
+
>,
|
|
346
375
|
]
|
|
347
376
|
>,
|
|
348
|
-
): ICodecFamily<TDecoded,
|
|
377
|
+
): ICodecFamily<TDecoded, TEncodeContext, TDecodeContext> {
|
|
349
378
|
const codecs: Map<
|
|
350
379
|
FormatVersion,
|
|
351
|
-
IJsonCodec<
|
|
380
|
+
IJsonCodec<
|
|
381
|
+
TDecoded,
|
|
382
|
+
JsonCompatibleReadOnly,
|
|
383
|
+
JsonCompatibleReadOnly,
|
|
384
|
+
TEncodeContext,
|
|
385
|
+
TDecodeContext
|
|
386
|
+
>
|
|
352
387
|
> = new Map();
|
|
353
388
|
for (const [formatVersion, codec] of registry) {
|
|
354
389
|
if (codecs.has(formatVersion)) {
|
|
@@ -360,7 +395,13 @@ export function makeCodecFamily<TDecoded, TContext>(
|
|
|
360
395
|
return {
|
|
361
396
|
resolve(
|
|
362
397
|
formatVersion: FormatVersion,
|
|
363
|
-
): IJsonCodec<
|
|
398
|
+
): IJsonCodec<
|
|
399
|
+
TDecoded,
|
|
400
|
+
JsonCompatibleReadOnly,
|
|
401
|
+
JsonCompatibleReadOnly,
|
|
402
|
+
TEncodeContext,
|
|
403
|
+
TDecodeContext
|
|
404
|
+
> {
|
|
364
405
|
const codec = codecs.get(formatVersion);
|
|
365
406
|
assert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);
|
|
366
407
|
return codec;
|
|
@@ -388,32 +429,39 @@ export const unitCodec: IJsonCodec<
|
|
|
388
429
|
* Wraps a codec with JSON schema validation for its encoded type.
|
|
389
430
|
* @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
|
|
390
431
|
* @remarks
|
|
391
|
-
* Eventually all codecs should use the same pattern implemented by
|
|
432
|
+
* Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.
|
|
392
433
|
*/
|
|
393
434
|
export function withSchemaValidation<
|
|
394
435
|
TInMemoryFormat,
|
|
395
436
|
EncodedSchema extends TSchema,
|
|
396
437
|
TEncodedFormat,
|
|
397
438
|
TValidate,
|
|
398
|
-
|
|
439
|
+
TEncodeContext,
|
|
440
|
+
TDecodeContext = TEncodeContext,
|
|
399
441
|
>(
|
|
400
442
|
schema: EncodedSchema,
|
|
401
|
-
codec: IJsonCodec<
|
|
443
|
+
codec: IJsonCodec<
|
|
444
|
+
TInMemoryFormat,
|
|
445
|
+
TEncodedFormat,
|
|
446
|
+
TValidate,
|
|
447
|
+
TEncodeContext,
|
|
448
|
+
TDecodeContext
|
|
449
|
+
>,
|
|
402
450
|
validator?: JsonValidator | FormatValidator,
|
|
403
|
-
): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate,
|
|
451
|
+
): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext> {
|
|
404
452
|
if (!validator) {
|
|
405
453
|
return codec;
|
|
406
454
|
}
|
|
407
455
|
const compiledFormat = extractJsonValidator(validator).compile(schema);
|
|
408
456
|
return {
|
|
409
|
-
encode: (obj: TInMemoryFormat, context:
|
|
457
|
+
encode: (obj: TInMemoryFormat, context: TEncodeContext): TEncodedFormat => {
|
|
410
458
|
const encoded = codec.encode(obj, context);
|
|
411
459
|
if (!compiledFormat.check(encoded)) {
|
|
412
460
|
fail(0xac0 /* Encoded data should validate */);
|
|
413
461
|
}
|
|
414
462
|
return encoded;
|
|
415
463
|
},
|
|
416
|
-
decode: (encoded: TValidate, context:
|
|
464
|
+
decode: (encoded: TValidate, context: TDecodeContext): TInMemoryFormat => {
|
|
417
465
|
if (!compiledFormat.check(encoded)) {
|
|
418
466
|
fail(0xac1 /* Data being decoded should validate */);
|
|
419
467
|
}
|
|
@@ -424,62 +472,23 @@ export function withSchemaValidation<
|
|
|
424
472
|
}
|
|
425
473
|
|
|
426
474
|
/**
|
|
427
|
-
* Versions of Fluid Framework client packages.
|
|
475
|
+
* Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.
|
|
428
476
|
* @remarks
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* When no compatibility-impacting change is made in a given version, the value associated with its enum entry may point to the older version which it's fully compatible with.
|
|
432
|
-
* Note that this can change if a future version of the framework introduces an option to use something which is only supported at a particular version. In which case, the values of the enum may shift,
|
|
433
|
-
* but the semantics of keys in this enum will not change.
|
|
434
|
-
*
|
|
435
|
-
* Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.
|
|
436
|
-
*
|
|
437
|
-
* Some release may also be omitted if there is currently no need to express that specific version.
|
|
438
|
-
* If the need arises, they might be added in the future.
|
|
477
|
+
* Versions with no notable impact may be omitted, and added later if needed.
|
|
439
478
|
*
|
|
440
479
|
* @privateRemarks
|
|
441
|
-
*
|
|
442
|
-
* - The user
|
|
443
|
-
*
|
|
444
|
-
* -
|
|
445
|
-
* version will write. For example, document if a new summary or encoding format is added in a version.
|
|
446
|
-
* - Whether the above features or data formats introduced in a version are enabled by default or require the
|
|
447
|
-
* {@link minVersionForCollab} option to be set to that particular version.
|
|
448
|
-
*
|
|
449
|
-
* Versions with no notable impact can be omitted.
|
|
450
|
-
*
|
|
451
|
-
* This scheme assumes a single version will always be enough to communicate compatibility.
|
|
452
|
-
* For this to work, compatibility has to be strictly increasing.
|
|
453
|
-
* If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),
|
|
454
|
-
* a more complex scheme may be needed to allow safely opting into incompatible features in those cases:
|
|
455
|
-
* such a system can be added if/when its needed since it will be opt in and thus non-breaking.
|
|
456
|
-
*
|
|
457
|
-
* TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.
|
|
458
|
-
* TODO: compatibility requirements for how this enum can and cannot be changed should be clarified when/if it's used across multiple layers in the stack.
|
|
459
|
-
* For example, if needed, would adding more leading zeros to the minor version break things.
|
|
480
|
+
* Each entry should document:
|
|
481
|
+
* - The user-facing impact of opting into it (e.g. encoding efficiency improvements).
|
|
482
|
+
* - Any new data formats introduced in that version.
|
|
483
|
+
* - Whether those features/formats are enabled by default or require {@link MinimumVersionForCollab | minVersionForCollab} to be set accordingly.
|
|
460
484
|
* @alpha
|
|
461
485
|
*/
|
|
462
486
|
export const FluidClientVersion = {
|
|
463
|
-
/**
|
|
464
|
-
* Fluid Framework Client 1.4 and newer.
|
|
465
|
-
* @remarks
|
|
466
|
-
* This opts into support for the 1.4 LTS branch.
|
|
467
|
-
* @privateRemarks
|
|
468
|
-
* As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.
|
|
469
|
-
*/
|
|
470
|
-
// v1_4 = 1.004,
|
|
471
|
-
|
|
472
487
|
/**
|
|
473
488
|
* Fluid Framework Client 2.0 and newer.
|
|
474
489
|
*/
|
|
475
490
|
v2_0: "2.0.0",
|
|
476
491
|
|
|
477
|
-
/** Fluid Framework Client 2.1 and newer. */
|
|
478
|
-
// If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),
|
|
479
|
-
// we could add an entry like this to allow users to indicate that they can be opted in once we are ready,
|
|
480
|
-
// then update it to "2.001" once we actually have the opt in working.
|
|
481
|
-
// v2_1 = v2_0,
|
|
482
|
-
|
|
483
492
|
/**
|
|
484
493
|
* Fluid Framework Client 2.43 and newer.
|
|
485
494
|
* @remarks
|
package/src/codec/index.ts
CHANGED