@fluidframework/tree 2.63.0 → 2.70.0-360753
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/api-report/tree.alpha.api.md +31 -27
- package/api-report/tree.beta.api.md +36 -1
- package/api-report/tree.legacy.beta.api.md +36 -1
- package/dist/alpha.d.ts +4 -4
- package/dist/beta.d.ts +4 -0
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializableDomainSchema.d.ts +12 -10
- package/dist/serializableDomainSchema.d.ts.map +1 -1
- package/dist/serializableDomainSchema.js +7 -7
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +17 -13
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/tableSchema.d.ts +37 -24
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +81 -54
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/utils.d.ts +11 -2
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +4 -4
- package/lib/beta.d.ts +4 -0
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializableDomainSchema.d.ts +12 -10
- package/lib/serializableDomainSchema.d.ts.map +1 -1
- package/lib/serializableDomainSchema.js +8 -8
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -2
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +18 -14
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/tableSchema.d.ts +37 -24
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +81 -54
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/utils.d.ts +11 -2
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +16 -14
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +8 -4
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +2 -0
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +65 -13
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +11 -11
- package/src/shared-tree/sharedTree.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +38 -22
- package/src/simple-tree/api/schemaFactoryAlpha.ts +8 -17
- package/src/simple-tree/api/schemaFactoryBeta.ts +17 -23
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -4
- package/src/simple-tree/node-kinds/map/mapNode.ts +5 -3
- package/src/simple-tree/node-kinds/object/objectNode.ts +8 -7
- package/src/simple-tree/node-kinds/record/recordNode.ts +6 -18
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -2
- package/src/tableSchema.ts +143 -81
- package/src/treeFactory.ts +1 -0
- package/src/util/utils.ts +11 -2
|
@@ -281,7 +281,7 @@ export interface FieldSchemaMetadata<TCustomMetadata = unknown> {
|
|
|
281
281
|
readonly description?: string | undefined;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
// @
|
|
284
|
+
// @beta
|
|
285
285
|
export type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;
|
|
286
286
|
|
|
287
287
|
// @public @system
|
|
@@ -301,7 +301,7 @@ export const FluidClientVersion: {
|
|
|
301
301
|
readonly v2_52: "2.52.0";
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
// @
|
|
304
|
+
// @beta
|
|
305
305
|
export namespace FluidSerializableAsTree {
|
|
306
306
|
// @sealed
|
|
307
307
|
export class Array extends _APIExtractorWorkaroundArrayBase {
|
|
@@ -318,7 +318,9 @@ export namespace FluidSerializableAsTree {
|
|
|
318
318
|
// @system
|
|
319
319
|
export type _RecursiveArrayWorkaroundJsonArray = FixRecursiveArraySchema<typeof Array>;
|
|
320
320
|
const // @system
|
|
321
|
-
_APIExtractorWorkaroundArrayBase:
|
|
321
|
+
_APIExtractorWorkaroundArrayBase: TreeNodeSchemaClass_2<"com.fluidframework.serializable.array", NodeKind_2.Array, System_Unsafe_2.TreeArrayNodeUnsafe<readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>]> & WithType_2<"com.fluidframework.serializable.array", NodeKind_2.Array, unknown>, {
|
|
322
|
+
[Symbol.iterator](): Iterator<string | number | IFluidHandle<unknown> | System_Unsafe_2.InsertableTypedNodeUnsafe<LeafSchema_2<"boolean", boolean>, LeafSchema_2<"boolean", boolean>> | FluidSerializableObject | Array | null, any, undefined>;
|
|
323
|
+
}, false, readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>], undefined>;
|
|
322
324
|
// (undocumented)
|
|
323
325
|
export type Tree = TreeNodeFromImplicitAllowedTypes<typeof Tree>;
|
|
324
326
|
}
|
|
@@ -520,10 +522,10 @@ export namespace JsonAsTree {
|
|
|
520
522
|
export type Tree = TreeNodeFromImplicitAllowedTypes<typeof Tree>;
|
|
521
523
|
}
|
|
522
524
|
|
|
523
|
-
// @
|
|
525
|
+
// @beta
|
|
524
526
|
export type JsonCompatible<TExtra = never> = string | number | boolean | null | JsonCompatible<TExtra>[] | JsonCompatibleObject<TExtra> | TExtra;
|
|
525
527
|
|
|
526
|
-
// @
|
|
528
|
+
// @beta
|
|
527
529
|
export type JsonCompatibleObject<TExtra = never> = {
|
|
528
530
|
[P in string]?: JsonCompatible<TExtra>;
|
|
529
531
|
};
|
|
@@ -760,14 +762,14 @@ TSchema
|
|
|
760
762
|
] extends [ImplicitFieldSchema] ? TSchema : ImplicitFieldSchema;
|
|
761
763
|
|
|
762
764
|
// @alpha @sealed @system
|
|
763
|
-
export interface RecordNodeCustomizableSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Record, TreeRecordNode<T> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<T>, ImplicitlyConstructable, T,
|
|
765
|
+
export interface RecordNodeCustomizableSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Record, TreeRecordNode<T> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<T>, ImplicitlyConstructable, T, undefined, TCustomMetadata>, SimpleRecordNodeSchema<TCustomMetadata> {
|
|
764
766
|
}
|
|
765
767
|
|
|
766
768
|
// @beta @system
|
|
767
769
|
export type RecordNodeInsertableData<T extends ImplicitAllowedTypes> = RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
|
768
770
|
|
|
769
771
|
// @alpha @sealed @system
|
|
770
|
-
export interface RecordNodePojoEmulationSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaNonClass<TName, NodeKind.Record, TreeRecordNode<T> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<T>, ImplicitlyConstructable, T,
|
|
772
|
+
export interface RecordNodePojoEmulationSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaNonClass<TName, NodeKind.Record, TreeRecordNode<T> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<T>, ImplicitlyConstructable, T, undefined, TCustomMetadata>, SimpleRecordNodeSchema<TCustomMetadata> {
|
|
771
773
|
}
|
|
772
774
|
|
|
773
775
|
// @alpha
|
|
@@ -928,7 +930,7 @@ export class SchemaFactoryBeta<out TScope extends string | undefined = string |
|
|
|
928
930
|
// (undocumented)
|
|
929
931
|
objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: ObjectSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, System_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>, false, T>;
|
|
930
932
|
record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchemaNonClass<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
931
|
-
record<const Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
933
|
+
record<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined, TCustomMetadata>;
|
|
932
934
|
recordRecursive<Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record, unknown>, {
|
|
933
935
|
readonly [x: string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
|
|
934
936
|
}, false, T, undefined, TCustomMetadata>;
|
|
@@ -1067,9 +1069,9 @@ export namespace System_TableSchema {
|
|
|
1067
1069
|
// @sealed @system
|
|
1068
1070
|
export type ColumnSchemaBase<TScope extends string | undefined = string | undefined, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createColumnSchema<TScope, TCellSchema, TPropsSchema>>;
|
|
1069
1071
|
// @system
|
|
1070
|
-
export type CreateColumnOptionsBase<TSchemaFactory extends
|
|
1072
|
+
export type CreateColumnOptionsBase<TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta, TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
1071
1073
|
// @system
|
|
1072
|
-
export function createColumnSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory:
|
|
1074
|
+
export function createColumnSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TInputScope>, cellSchema: TCellSchema, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Column">, NodeKind.Object, TreeNode & TableSchema.Column<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Column">, NodeKind, unknown>, object & {
|
|
1073
1075
|
readonly id?: string | undefined;
|
|
1074
1076
|
} & (FieldHasDefault<TPropsSchema> extends true ? {
|
|
1075
1077
|
props?: InsertableTreeFieldFromImplicitField<TPropsSchema> | undefined;
|
|
@@ -1080,11 +1082,11 @@ export namespace System_TableSchema {
|
|
|
1080
1082
|
readonly id: FieldSchema_2<FieldKind_2.Identifier, LeafSchema_2<"string", string>, unknown>;
|
|
1081
1083
|
}>;
|
|
1082
1084
|
// @system
|
|
1083
|
-
export type CreateRowOptionsBase<TSchemaFactory extends
|
|
1085
|
+
export type CreateRowOptionsBase<TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta, TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
1084
1086
|
// @sealed
|
|
1085
|
-
export function createRowSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory:
|
|
1087
|
+
export function createRowSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TInputScope>, cellSchema: TCellSchema, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row">, NodeKind.Object, TreeNode & TableSchema.Row<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row">, NodeKind, unknown>, object & {
|
|
1086
1088
|
readonly id?: string | undefined;
|
|
1087
|
-
readonly cells: (InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, TreeRecordNode_2<TCellSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined>> | undefined) & InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, TreeRecordNode_2<TCellSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined>>;
|
|
1089
|
+
readonly cells: (InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, TreeRecordNode_2<TCellSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>> | undefined) & InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, TreeRecordNode_2<TCellSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>>;
|
|
1088
1090
|
} & (FieldHasDefault<TPropsSchema> extends true ? {
|
|
1089
1091
|
props?: InsertableTreeFieldFromImplicitField<TPropsSchema> | undefined;
|
|
1090
1092
|
} : {
|
|
@@ -1092,10 +1094,10 @@ export namespace System_TableSchema {
|
|
|
1092
1094
|
}), true, {
|
|
1093
1095
|
readonly props: TPropsSchema;
|
|
1094
1096
|
readonly id: FieldSchema_2<FieldKind_2.Identifier, LeafSchema_2<"string", string>, unknown>;
|
|
1095
|
-
readonly cells:
|
|
1097
|
+
readonly cells: FieldSchema_2<FieldKind_2.Required, TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, TreeRecordNode_2<TCellSchema> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>, unknown>;
|
|
1096
1098
|
}>;
|
|
1097
1099
|
// @system
|
|
1098
|
-
export function createTableSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TColumnSchema extends ColumnSchemaBase<TInputScope, TCellSchema>, const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>>(inputSchemaFactory:
|
|
1100
|
+
export function createTableSchema<const TInputScope extends string | undefined, const TCellSchema extends ImplicitAllowedTypes, const TColumnSchema extends ColumnSchemaBase<TInputScope, TCellSchema>, const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>>(inputSchemaFactory: SchemaFactoryBeta<TInputScope>, _cellSchema: TCellSchema, columnSchema: TColumnSchema, rowSchema: TRowSchema): TreeNodeSchemaCore_2<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Table">, NodeKind.Object, true, {
|
|
1099
1101
|
readonly rows: TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Table.rows">, NodeKind.Array, TreeArrayNode<TRowSchema, [TRowSchema] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TRowSchema> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, [TRowSchema] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema> : never, ReadonlyArrayNode_2<TreeNode | TreeLeafValue_2>> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Table.rows">, NodeKind.Array, unknown>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>, true, TRowSchema, undefined>;
|
|
1100
1102
|
readonly columns: TreeNodeSchemaClass<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Table.columns">, NodeKind.Array, TreeArrayNode<TColumnSchema, [TColumnSchema] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TColumnSchema> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, [TColumnSchema] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema> : never, ReadonlyArrayNode_2<TreeNode | TreeLeafValue_2>> & WithType<ScopedSchemaName<ScopedSchemaName<TInputScope, "table">, "Table.columns">, NodeKind.Array, unknown>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>>, true, TColumnSchema, undefined>;
|
|
1101
1103
|
}, object & {
|
|
@@ -1117,13 +1119,13 @@ export namespace System_TableSchema {
|
|
|
1117
1119
|
readonly cell: TCellSchema;
|
|
1118
1120
|
}
|
|
1119
1121
|
// @system
|
|
1120
|
-
export interface OptionsWithSchemaFactory<TSchemaFactory extends
|
|
1122
|
+
export interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryBeta> {
|
|
1121
1123
|
readonly schemaFactory: TSchemaFactory;
|
|
1122
1124
|
}
|
|
1123
1125
|
// @sealed @system
|
|
1124
1126
|
export type RowSchemaBase<TScope extends string | undefined = string | undefined, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createRowSchema<TScope, TCellSchema, TPropsSchema>>;
|
|
1125
1127
|
// @system
|
|
1126
|
-
export type TableFactoryOptionsBase<TSchemaFactory extends
|
|
1128
|
+
export type TableFactoryOptionsBase<TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta, TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
1127
1129
|
// @sealed @system
|
|
1128
1130
|
export type TableSchemaBase<TScope extends string | undefined, TCell extends ImplicitAllowedTypes, TColumn extends ColumnSchemaBase<TScope, TCell>, TRow extends RowSchemaBase<TScope, TCell>> = ReturnType<typeof createTableSchema<TScope, TCell, TColumn, TRow>>;
|
|
1129
1131
|
}
|
|
@@ -1214,8 +1216,8 @@ export namespace System_Unsafe {
|
|
|
1214
1216
|
// @alpha
|
|
1215
1217
|
export namespace TableSchema {
|
|
1216
1218
|
export interface CellKey<TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
|
|
1217
|
-
readonly column: string | TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
1218
|
-
readonly row: string | TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1219
|
+
readonly column: string | number | TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
1220
|
+
readonly row: string | number | TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1219
1221
|
}
|
|
1220
1222
|
// @sealed
|
|
1221
1223
|
export interface Column<TCell extends ImplicitAllowedTypes, TProps extends ImplicitFieldSchema = ImplicitFieldSchema> {
|
|
@@ -1227,8 +1229,8 @@ export namespace TableSchema {
|
|
|
1227
1229
|
get props(): TreeFieldFromImplicitField<TProps>;
|
|
1228
1230
|
set props(value: InsertableTreeFieldFromImplicitField<TProps>);
|
|
1229
1231
|
}
|
|
1230
|
-
export function column<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateColumnOptionsBase<
|
|
1231
|
-
export function column<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateColumnOptionsBase<
|
|
1232
|
+
export function column<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryBeta<TScope>, TCell>): System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
|
|
1233
|
+
export function column<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1232
1234
|
readonly props: TProps;
|
|
1233
1235
|
}): System_TableSchema.ColumnSchemaBase<TScope, TCell, TProps>;
|
|
1234
1236
|
export interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
|
|
@@ -1255,8 +1257,8 @@ export namespace TableSchema {
|
|
|
1255
1257
|
setCell(column: Column<TCell>, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
|
|
1256
1258
|
setCell(columnId: string, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
|
|
1257
1259
|
}
|
|
1258
|
-
export function row<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateRowOptionsBase<
|
|
1259
|
-
export function row<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateRowOptionsBase<
|
|
1260
|
+
export function row<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryBeta<TScope>, TCell>): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
|
|
1261
|
+
export function row<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1260
1262
|
readonly props: TProps;
|
|
1261
1263
|
}): System_TableSchema.RowSchemaBase<TScope, TCell, TProps>;
|
|
1262
1264
|
export interface SetCellParameters<TCell extends ImplicitAllowedTypes, TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
|
|
@@ -1268,7 +1270,9 @@ export namespace TableSchema {
|
|
|
1268
1270
|
readonly columns: TreeArrayNode<TColumn>;
|
|
1269
1271
|
getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1270
1272
|
getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
|
|
1273
|
+
getColumn(index: number): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
|
|
1271
1274
|
getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
|
|
1275
|
+
getRow(index: number): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
|
|
1272
1276
|
insertColumns(params: InsertColumnsParameters<TColumn>): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1273
1277
|
insertRows(params: InsertRowsParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
1274
1278
|
removeCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
@@ -1281,14 +1285,14 @@ export namespace TableSchema {
|
|
|
1281
1285
|
readonly rows: TreeArrayNode<TRow>;
|
|
1282
1286
|
setCell(params: SetCellParameters<TCell, TColumn, TRow>): void;
|
|
1283
1287
|
}
|
|
1284
|
-
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.TableFactoryOptionsBase<
|
|
1285
|
-
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<
|
|
1288
|
+
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell>): System_TableSchema.TableSchemaBase<TScope, TCell, System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>, System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>>;
|
|
1289
|
+
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1286
1290
|
readonly column: TColumn;
|
|
1287
1291
|
}): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>>;
|
|
1288
|
-
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<
|
|
1292
|
+
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1289
1293
|
readonly row: TRow;
|
|
1290
1294
|
}): System_TableSchema.TableSchemaBase<TScope, TCell, System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>, TRow>;
|
|
1291
|
-
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>, const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<
|
|
1295
|
+
export function table<const TScope extends string | undefined, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>, const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1292
1296
|
readonly column: TColumn;
|
|
1293
1297
|
readonly row: TRow;
|
|
1294
1298
|
}): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, TRow>;
|
|
@@ -109,6 +109,9 @@ export interface FieldSchemaMetadata<TCustomMetadata = unknown> {
|
|
|
109
109
|
readonly description?: string | undefined;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
// @beta
|
|
113
|
+
export type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;
|
|
114
|
+
|
|
112
115
|
// @public @system
|
|
113
116
|
type FlattenKeys<T> = [{
|
|
114
117
|
[Property in keyof T]: T[Property];
|
|
@@ -120,6 +123,30 @@ type FlexList<Item = unknown> = readonly LazyItem<Item>[];
|
|
|
120
123
|
// @public @system
|
|
121
124
|
type FlexListToUnion<TList extends FlexList> = ExtractItemType<TList[number]>;
|
|
122
125
|
|
|
126
|
+
// @beta
|
|
127
|
+
export namespace FluidSerializableAsTree {
|
|
128
|
+
// @sealed
|
|
129
|
+
export class Array extends _APIExtractorWorkaroundArrayBase {
|
|
130
|
+
}
|
|
131
|
+
const Tree: readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>];
|
|
132
|
+
export type Data = JsonCompatible<IFluidHandle>;
|
|
133
|
+
const // @system
|
|
134
|
+
_APIExtractorWorkaroundObjectBase: TreeNodeSchemaClass_2<"com.fluidframework.serializable.object", NodeKind_2.Record, TreeRecordNodeUnsafe_2<readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>]> & WithType_2<"com.fluidframework.serializable.object", NodeKind_2.Record, unknown>, {
|
|
135
|
+
readonly [x: string]: string | number | IFluidHandle<unknown> | System_Unsafe_2.InsertableTypedNodeUnsafe<LeafSchema_2<"boolean", boolean>, LeafSchema_2<"boolean", boolean>> | FluidSerializableObject | Array | null;
|
|
136
|
+
}, false, readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>], undefined, unknown>;
|
|
137
|
+
// @sealed
|
|
138
|
+
export class FluidSerializableObject extends _APIExtractorWorkaroundObjectBase {
|
|
139
|
+
}
|
|
140
|
+
// @system
|
|
141
|
+
export type _RecursiveArrayWorkaroundJsonArray = FixRecursiveArraySchema<typeof Array>;
|
|
142
|
+
const // @system
|
|
143
|
+
_APIExtractorWorkaroundArrayBase: TreeNodeSchemaClass_2<"com.fluidframework.serializable.array", NodeKind_2.Array, System_Unsafe_2.TreeArrayNodeUnsafe<readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>]> & WithType_2<"com.fluidframework.serializable.array", NodeKind_2.Array, unknown>, {
|
|
144
|
+
[Symbol.iterator](): Iterator<string | number | IFluidHandle<unknown> | System_Unsafe_2.InsertableTypedNodeUnsafe<LeafSchema_2<"boolean", boolean>, LeafSchema_2<"boolean", boolean>> | FluidSerializableObject | Array | null, any, undefined>;
|
|
145
|
+
}, false, readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>], undefined>;
|
|
146
|
+
// (undocumented)
|
|
147
|
+
export type Tree = TreeNodeFromImplicitAllowedTypes<typeof Tree>;
|
|
148
|
+
}
|
|
149
|
+
|
|
123
150
|
// @beta @input
|
|
124
151
|
export interface ForestOptions {
|
|
125
152
|
readonly forest?: ForestType;
|
|
@@ -226,6 +253,14 @@ export interface ITreeViewConfiguration<TSchema extends ImplicitFieldSchema = Im
|
|
|
226
253
|
readonly schema: TSchema;
|
|
227
254
|
}
|
|
228
255
|
|
|
256
|
+
// @beta
|
|
257
|
+
export type JsonCompatible<TExtra = never> = string | number | boolean | null | JsonCompatible<TExtra>[] | JsonCompatibleObject<TExtra> | TExtra;
|
|
258
|
+
|
|
259
|
+
// @beta
|
|
260
|
+
export type JsonCompatibleObject<TExtra = never> = {
|
|
261
|
+
[P in string]?: JsonCompatible<TExtra>;
|
|
262
|
+
};
|
|
263
|
+
|
|
229
264
|
// @beta @input
|
|
230
265
|
export enum KeyEncodingOptions {
|
|
231
266
|
allStoredKeys = "allStoredKeys",
|
|
@@ -412,7 +447,7 @@ export class SchemaFactoryBeta<out TScope extends string | undefined = string |
|
|
|
412
447
|
// (undocumented)
|
|
413
448
|
objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: ObjectSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, System_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>, false, T>;
|
|
414
449
|
record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchemaNonClass<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
415
|
-
record<const Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
450
|
+
record<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined, TCustomMetadata>;
|
|
416
451
|
recordRecursive<Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record, unknown>, {
|
|
417
452
|
readonly [x: string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
|
|
418
453
|
}, false, T, undefined, TCustomMetadata>;
|
|
@@ -112,6 +112,9 @@ export interface FieldSchemaMetadata<TCustomMetadata = unknown> {
|
|
|
112
112
|
readonly description?: string | undefined;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// @beta
|
|
116
|
+
export type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;
|
|
117
|
+
|
|
115
118
|
// @public @system
|
|
116
119
|
type FlattenKeys<T> = [{
|
|
117
120
|
[Property in keyof T]: T[Property];
|
|
@@ -123,6 +126,30 @@ type FlexList<Item = unknown> = readonly LazyItem<Item>[];
|
|
|
123
126
|
// @public @system
|
|
124
127
|
type FlexListToUnion<TList extends FlexList> = ExtractItemType<TList[number]>;
|
|
125
128
|
|
|
129
|
+
// @beta
|
|
130
|
+
export namespace FluidSerializableAsTree {
|
|
131
|
+
// @sealed
|
|
132
|
+
export class Array extends _APIExtractorWorkaroundArrayBase {
|
|
133
|
+
}
|
|
134
|
+
const Tree: readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>];
|
|
135
|
+
export type Data = JsonCompatible<IFluidHandle>;
|
|
136
|
+
const // @system
|
|
137
|
+
_APIExtractorWorkaroundObjectBase: TreeNodeSchemaClass_2<"com.fluidframework.serializable.object", NodeKind_2.Record, TreeRecordNodeUnsafe_2<readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>]> & WithType_2<"com.fluidframework.serializable.object", NodeKind_2.Record, unknown>, {
|
|
138
|
+
readonly [x: string]: string | number | IFluidHandle<unknown> | System_Unsafe_2.InsertableTypedNodeUnsafe<LeafSchema_2<"boolean", boolean>, LeafSchema_2<"boolean", boolean>> | FluidSerializableObject | Array | null;
|
|
139
|
+
}, false, readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>], undefined, unknown>;
|
|
140
|
+
// @sealed
|
|
141
|
+
export class FluidSerializableObject extends _APIExtractorWorkaroundObjectBase {
|
|
142
|
+
}
|
|
143
|
+
// @system
|
|
144
|
+
export type _RecursiveArrayWorkaroundJsonArray = FixRecursiveArraySchema<typeof Array>;
|
|
145
|
+
const // @system
|
|
146
|
+
_APIExtractorWorkaroundArrayBase: TreeNodeSchemaClass_2<"com.fluidframework.serializable.array", NodeKind_2.Array, System_Unsafe_2.TreeArrayNodeUnsafe<readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>]> & WithType_2<"com.fluidframework.serializable.array", NodeKind_2.Array, unknown>, {
|
|
147
|
+
[Symbol.iterator](): Iterator<string | number | IFluidHandle<unknown> | System_Unsafe_2.InsertableTypedNodeUnsafe<LeafSchema_2<"boolean", boolean>, LeafSchema_2<"boolean", boolean>> | FluidSerializableObject | Array | null, any, undefined>;
|
|
148
|
+
}, false, readonly [() => typeof FluidSerializableObject, () => typeof Array, LeafSchema_2<"string", string>, LeafSchema_2<"number", number>, LeafSchema_2<"boolean", boolean>, LeafSchema_2<"null", null>, LeafSchema_2<"handle", IFluidHandle<unknown>>], undefined>;
|
|
149
|
+
// (undocumented)
|
|
150
|
+
export type Tree = TreeNodeFromImplicitAllowedTypes<typeof Tree>;
|
|
151
|
+
}
|
|
152
|
+
|
|
126
153
|
// @beta @input
|
|
127
154
|
export interface ForestOptions {
|
|
128
155
|
readonly forest?: ForestType;
|
|
@@ -229,6 +256,14 @@ export interface ITreeViewConfiguration<TSchema extends ImplicitFieldSchema = Im
|
|
|
229
256
|
readonly schema: TSchema;
|
|
230
257
|
}
|
|
231
258
|
|
|
259
|
+
// @beta
|
|
260
|
+
export type JsonCompatible<TExtra = never> = string | number | boolean | null | JsonCompatible<TExtra>[] | JsonCompatibleObject<TExtra> | TExtra;
|
|
261
|
+
|
|
262
|
+
// @beta
|
|
263
|
+
export type JsonCompatibleObject<TExtra = never> = {
|
|
264
|
+
[P in string]?: JsonCompatible<TExtra>;
|
|
265
|
+
};
|
|
266
|
+
|
|
232
267
|
// @beta @input
|
|
233
268
|
export enum KeyEncodingOptions {
|
|
234
269
|
allStoredKeys = "allStoredKeys",
|
|
@@ -415,7 +450,7 @@ export class SchemaFactoryBeta<out TScope extends string | undefined = string |
|
|
|
415
450
|
// (undocumented)
|
|
416
451
|
objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: ObjectSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, System_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>, false, T>;
|
|
417
452
|
record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchemaNonClass<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
418
|
-
record<const Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined>;
|
|
453
|
+
record<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>, RecordNodeInsertableData<T>, true, T, undefined, TCustomMetadata>;
|
|
419
454
|
recordRecursive<Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record, unknown>, {
|
|
420
455
|
readonly [x: string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
|
|
421
456
|
}, false, T, undefined, TCustomMetadata>;
|
package/dist/alpha.d.ts
CHANGED
|
@@ -94,11 +94,15 @@ export {
|
|
|
94
94
|
|
|
95
95
|
// #region @beta APIs
|
|
96
96
|
ConciseTree,
|
|
97
|
+
FixRecursiveArraySchema,
|
|
98
|
+
FluidSerializableAsTree,
|
|
97
99
|
ForestOptions,
|
|
98
100
|
ForestType,
|
|
99
101
|
ForestTypeExpensiveDebug,
|
|
100
102
|
ForestTypeOptimized,
|
|
101
103
|
ForestTypeReference,
|
|
104
|
+
JsonCompatible,
|
|
105
|
+
JsonCompatibleObject,
|
|
102
106
|
KeyEncodingOptions,
|
|
103
107
|
NodeChangedData,
|
|
104
108
|
ObjectSchemaOptions,
|
|
@@ -145,9 +149,7 @@ export {
|
|
|
145
149
|
FieldPropsAlpha,
|
|
146
150
|
FieldSchemaAlpha,
|
|
147
151
|
FieldSchemaAlphaUnsafe,
|
|
148
|
-
FixRecursiveArraySchema,
|
|
149
152
|
FluidClientVersion,
|
|
150
|
-
FluidSerializableAsTree,
|
|
151
153
|
FormatValidator,
|
|
152
154
|
FormatValidatorBasic,
|
|
153
155
|
FormatValidatorNoOp,
|
|
@@ -160,8 +162,6 @@ export {
|
|
|
160
162
|
InsertableField,
|
|
161
163
|
JsonArrayNodeSchema,
|
|
162
164
|
JsonAsTree,
|
|
163
|
-
JsonCompatible,
|
|
164
|
-
JsonCompatibleObject,
|
|
165
165
|
JsonCompatibleReadOnly,
|
|
166
166
|
JsonCompatibleReadOnlyObject,
|
|
167
167
|
JsonFieldSchema,
|
package/dist/beta.d.ts
CHANGED
|
@@ -94,11 +94,15 @@ export {
|
|
|
94
94
|
|
|
95
95
|
// #region @beta APIs
|
|
96
96
|
ConciseTree,
|
|
97
|
+
FixRecursiveArraySchema,
|
|
98
|
+
FluidSerializableAsTree,
|
|
97
99
|
ForestOptions,
|
|
98
100
|
ForestType,
|
|
99
101
|
ForestTypeExpensiveDebug,
|
|
100
102
|
ForestTypeOptimized,
|
|
101
103
|
ForestTypeReference,
|
|
104
|
+
JsonCompatible,
|
|
105
|
+
JsonCompatibleObject,
|
|
102
106
|
KeyEncodingOptions,
|
|
103
107
|
NodeChangedData,
|
|
104
108
|
ObjectSchemaOptions,
|
|
@@ -58,8 +58,8 @@ export declare class InlineArrayDecoder implements ChunkDecoder {
|
|
|
58
58
|
* Decoder for {@link EncodedIncrementalChunkShape}s.
|
|
59
59
|
*/
|
|
60
60
|
export declare class IncrementalChunkDecoder implements ChunkDecoder {
|
|
61
|
-
private readonly
|
|
62
|
-
constructor(
|
|
61
|
+
private readonly context;
|
|
62
|
+
constructor(context: DecoderContext<EncodedChunkShape>);
|
|
63
63
|
decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EAEb,SAAS,EACT,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAGX,KAAK,EACL,SAAS,EACT,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EAOjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,aAAa,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC;CACxB;AACD;;GAEG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE;IAAE,YAAY,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,SAAS,CAAA;CAAE,EAC3E,kBAAkB,CAAC,EAAE,kBAAkB,GACrC,SAAS,EAAE,CAOb;AAwBD;;GAEG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,iBAAiB,EACxB,iBAAiB,EAAE,iBAAiB,GAClC,KAAK,CAgCP;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,CAyB/D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,CAU7D;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,uBAAuB;IAC3D,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CA0BjF;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,uBAAuB;IAC3D,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CASjF;AAED;;GAEG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"chunkDecoding.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EAEb,SAAS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AAY,GAAG,SAAS;CA0BjF;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,uBAAuB;IAC3D,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CASjF;AAED;;GAEG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC;IACvE,MAAM,CAAC,CAAC,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CAuB1E;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,YAMxB,CAAC;AAyBF;;GAEG;AACH,qBAAa,WAAY,YAAW,YAAY;IAI9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+B;gBAE3C,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC;IAWrD,MAAM,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS;CAmCjF"}
|
|
@@ -171,19 +171,18 @@ exports.InlineArrayDecoder = InlineArrayDecoder;
|
|
|
171
171
|
* Decoder for {@link EncodedIncrementalChunkShape}s.
|
|
172
172
|
*/
|
|
173
173
|
class IncrementalChunkDecoder {
|
|
174
|
-
constructor(
|
|
175
|
-
this.
|
|
174
|
+
constructor(context) {
|
|
175
|
+
this.context = context;
|
|
176
176
|
}
|
|
177
177
|
decode(_, stream) {
|
|
178
|
-
(0, internal_1.assert)(this.
|
|
178
|
+
(0, internal_1.assert)(this.context.incrementalDecoder !== undefined, 0xc27 /* incremental decoder not available for incremental field decoding */);
|
|
179
|
+
const chunkDecoder = (batch) => {
|
|
180
|
+
const context = new chunkDecodingGeneric_js_1.DecoderContext(batch.identifiers, batch.shapes, this.context.idDecodingContext, this.context.incrementalDecoder);
|
|
181
|
+
const chunks = (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, context, batch, exports.anyDecoder);
|
|
182
|
+
return aggregateChunks(chunks);
|
|
183
|
+
};
|
|
179
184
|
const chunkReferenceId = (0, chunkCodecUtilities_js_1.readStreamNumber)(stream);
|
|
180
|
-
|
|
181
|
-
(0, internal_1.assert)(batch !== undefined, 0xc28 /* Incremental chunk data missing */);
|
|
182
|
-
// The incremental chunk data is self-describing, i.e., it contain its own shapes list and identifier table.
|
|
183
|
-
// Use these to create a new decoder context to be used to decode the incremental chunk's data.
|
|
184
|
-
const context = new chunkDecodingGeneric_js_1.DecoderContext(batch.identifiers, batch.shapes, this.cache.idDecodingContext, this.cache.incrementalDecoder);
|
|
185
|
-
const chunks = (0, chunkDecodingGeneric_js_1.decode)(decoderLibrary, context, batch, exports.anyDecoder);
|
|
186
|
-
return aggregateChunks(chunks);
|
|
185
|
+
return this.context.incrementalDecoder.decodeIncrementalChunk((0, index_js_2.brand)(chunkReferenceId), chunkDecoder);
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
188
|
exports.IncrementalChunkDecoder = IncrementalChunkDecoder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAAiE;AACjE,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CAUqB;AAUrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E,EAC3E,kBAAuC;IAEvC,OAAO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D,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex, brand } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedIncrementalChunkShape,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\nimport type { IncrementalDecoder } from \"./codecs.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n\tincrementalDecoder?: IncrementalDecoder,\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n\te(shape: EncodedIncrementalChunkShape, cache): ChunkDecoder {\n\t\treturn new IncrementalChunkDecoder(cache);\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedIncrementalChunkShape}s.\n */\nexport class IncrementalChunkDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly cache: DecoderContext<EncodedChunkShape>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.cache.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\tconst batch = this.cache.incrementalDecoder.getEncodedIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t);\n\t\tassert(batch !== undefined, 0xc28 /* Incremental chunk data missing */);\n\t\t// The incremental chunk data is self-describing, i.e., it contain its own shapes list and identifier table.\n\t\t// Use these to create a new decoder context to be used to decode the incremental chunk's data.\n\t\tconst context = new DecoderContext(\n\t\t\tbatch.identifiers,\n\t\t\tbatch.shapes,\n\t\t\tthis.cache.idDecodingContext,\n\t\t\tthis.cache.incrementalDecoder,\n\t\t);\n\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const decoder of this.fieldDecoders) {\n\t\t\tconst [key, content] = decoder(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAAiE;AACjE,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AACnC,2CAUqB;AAUrB;;GAEG;AACH,SAAgB,MAAM,CACrB,KAAwB,EACxB,iBAA2E,EAC3E,kBAAuC;IAEvC,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,wCAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,EAC1F,KAAK,EACL,kBAAU,CACV,CAAC;AACH,CAAC;AAXD,wBAWC;AAED,MAAM,cAAc,GAAG,IAAI,uCAA4B,CAIrD;IACD,CAAC,CAAC,KAA8B,EAAE,OAAO;QACxC,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,CAAC,CAAC,KAA8B,EAAE,OAAO;QACxC,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,CAAC,CAAC,KAAuB,EAAE,OAAO;QACjC,OAAO,IAAI,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,CAAC,CAAC,KAAsB;QACvB,OAAO,kBAAU,CAAC;IACnB,CAAC;IACD,CAAC,CAAC,KAAmC,EAAE,KAAK;QAC3C,OAAO,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACD,C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AI,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAA,yCAAgB,EAAC,MAAM,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex, brand } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedIncrementalChunkShape,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedValueShape,\n\tSpecialField,\n} from \"./format.js\";\nimport type { IncrementalDecoder } from \"./codecs.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n}\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatch,\n\tidDecodingContext: { idCompressor: IIdCompressor; originatorId: SessionId },\n\tincrementalDecoder?: IncrementalDecoder,\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n\te(shape: EncodedIncrementalChunkShape, cache): ChunkDecoder {\n\t\treturn new IncrementalChunkDecoder(cache);\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\treturn typeof streamValue === \"number\"\n\t\t\t\t? idCompressor.decompress(\n\t\t\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: streamValue;\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0:\n\t\t\treturn emptyChunk;\n\t\tcase 1:\n\t\t\treturn chunks[0] ?? oob();\n\t\tdefault:\n\t\t\treturn new SequenceChunk(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedIncrementalChunkShape}s.\n */\nexport class IncrementalChunkDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly context: DecoderContext<EncodedChunkShape>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.context.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\n\t\tconst chunkDecoder = (batch: EncodedFieldBatch): TreeChunk => {\n\t\t\tconst context = new DecoderContext(\n\t\t\t\tbatch.identifiers,\n\t\t\t\tbatch.shapes,\n\t\t\t\tthis.context.idDecodingContext,\n\t\t\t\tthis.context.incrementalDecoder,\n\t\t\t);\n\t\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\t\treturn aggregateChunks(chunks);\n\t\t};\n\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\treturn this.context.incrementalDecoder.decodeIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t\tchunkDecoder,\n\t\t);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`) {@link EncodedChunkShape}.\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length !== 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const decoder of this.fieldDecoders) {\n\t\t\tconst [key, content] = decoder(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
|
|
@@ -49,11 +49,12 @@ export interface IncrementalEncoder {
|
|
|
49
49
|
*/
|
|
50
50
|
export interface IncrementalDecoder {
|
|
51
51
|
/**
|
|
52
|
-
* Called to
|
|
53
|
-
* @param referenceId - The reference ID of the chunk to
|
|
54
|
-
* @
|
|
52
|
+
* Called to decode an incremental chunk with the given reference ID.
|
|
53
|
+
* @param referenceId - The reference ID of the chunk to decode.
|
|
54
|
+
* @param chunkDecoder - A function that decodes the chunk.
|
|
55
|
+
* @returns The decoded chunk.
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
decodeIncrementalChunk(referenceId: ChunkReferenceId, chunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk): TreeChunk;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,EACN,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEN,KAAK,KAAK,EACV,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGN,KAAK,8BAA8B,EACnC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAiB,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG7F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAGxE;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,yBAAyB,EAAE,yBAAyB,CAAC;IACrD;;;;;;;OAOG;IACH,sBAAsB,CACrB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,iBAAiB,GACnD,gBAAgB,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,E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