@fluidframework/tree 2.102.0 → 2.110.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 +65 -0
- package/api-report/tree.alpha.api.md +12 -3
- package/api-report/tree.beta.api.md +11 -3
- package/api-report/tree.legacy.beta.api.md +11 -3
- package/dist/codec/versioned/format.d.ts +5 -4
- package/dist/codec/versioned/format.d.ts.map +1 -1
- package/dist/codec/versioned/format.js +4 -3
- package/dist/codec/versioned/format.js.map +1 -1
- package/dist/core/rebase/types.d.ts +4 -3
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +5 -4
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/formatV1.d.ts +16 -15
- package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
- package/dist/core/schema-stored/formatV1.js +9 -8
- package/dist/core/schema-stored/formatV1.js.map +1 -1
- package/dist/core/schema-stored/formatV2.d.ts +29 -28
- package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
- package/dist/core/schema-stored/formatV2.js +11 -10
- package/dist/core/schema-stored/formatV2.js.map +1 -1
- package/dist/core/schema-stored/index.js +3 -25
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/tree/anchorSet.js +4 -8
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +11 -10
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.js +11 -10
- package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +7 -6
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV2.js +3 -2
- package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.d.ts +19 -18
- package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js +11 -10
- package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/dist/entrypoints/internal.js +2 -15
- package/dist/entrypoints/internal.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +7 -11
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +13 -12
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js +14 -13
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +36 -35
- package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +19 -18
- package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +26 -25
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +5 -4
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +24 -23
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +8 -7
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +66 -14
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +101 -36
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +36 -14
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -19
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -13
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -5
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.js +4 -3
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/dist/feature-libraries/index.js +2 -24
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +4 -3
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +4 -3
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +10 -30
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +45 -44
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +26 -25
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +23 -22
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +7 -6
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -5
- 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/object-forest/objectForest.js +11 -55
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +9 -8
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +9 -8
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +14 -13
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +12 -11
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +5 -4
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -2
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +15 -14
- package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.js +5 -4
- package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +20 -19
- package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/formatV2.js +5 -4
- package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +1 -3
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV1.d.ts +283 -282
- package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV1.js +41 -40
- package/dist/feature-libraries/sequence-field/formatV1.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.d.ts +180 -179
- package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.js +33 -32
- package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.d.ts +126 -125
- package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.js +5 -4
- package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -1
- package/dist/index.js +2 -24
- 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/schematizingTreeView.d.ts +1 -0
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +7 -41
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +2 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +6 -45
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
- package/dist/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFormat.js +6 -5
- package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +14 -5
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +106 -136
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.js +13 -17
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +2 -2
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +35 -34
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +17 -16
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +15 -15
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +11 -10
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +40 -40
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +5 -4
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +3 -2
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +5 -5
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +9 -8
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -7
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.js +7 -6
- package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +6 -43
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.js +20 -30
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +2 -24
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -24
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +10 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +5 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +119 -105
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +6 -10
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +2 -12
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +2 -6
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts +121 -120
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js +32 -31
- package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/dist/tableSchema.d.ts +50 -4
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +202 -106
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/arrayUtilities.d.ts +20 -0
- package/dist/util/arrayUtilities.d.ts.map +1 -1
- package/dist/util/arrayUtilities.js +24 -1
- package/dist/util/arrayUtilities.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +3 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/rangeMap.d.ts +13 -0
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +69 -8
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/typeboxBrand.d.ts +1 -1
- package/dist/util/typeboxBrand.d.ts.map +1 -1
- package/dist/util/typeboxBrand.js +4 -3
- package/dist/util/typeboxBrand.js.map +1 -1
- package/dist/util/utils.d.ts +2 -2
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +3 -2
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +14 -0
- package/lib/codec/versioned/format.d.ts +5 -4
- package/lib/codec/versioned/format.d.ts.map +1 -1
- package/lib/codec/versioned/format.js +1 -1
- package/lib/codec/versioned/format.js.map +1 -1
- package/lib/core/rebase/types.d.ts +4 -3
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +1 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/formatV1.d.ts +16 -15
- package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
- package/lib/core/schema-stored/formatV1.js +1 -1
- package/lib/core/schema-stored/formatV1.js.map +1 -1
- package/lib/core/schema-stored/formatV2.d.ts +29 -28
- package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
- package/lib/core/schema-stored/formatV2.js +1 -1
- package/lib/core/schema-stored/formatV2.js.map +1 -1
- package/lib/core/tree/anchorSet.js +1 -5
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +11 -10
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.js +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +7 -6
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV2.js +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.d.ts +19 -18
- package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.js +1 -1
- package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +1 -5
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +13 -12
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +36 -35
- package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +26 -25
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +24 -23
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +66 -14
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +101 -36
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +36 -14
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +1 -11
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +1 -11
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -5
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +4 -3
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -30
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +45 -44
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +23 -22
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -5
- 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/object-forest/objectForest.js +1 -45
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +9 -8
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +14 -13
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +5 -4
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +15 -14
- package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.js +1 -1
- package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +20 -19
- package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/formatV2.js +1 -1
- package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +1 -3
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.d.ts +283 -282
- package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.js +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.d.ts +180 -179
- package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.js +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.d.ts +126 -125
- package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.js +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.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/schematizingTreeView.d.ts +1 -0
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +4 -38
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +2 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -41
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
- package/lib/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFormat.js +1 -1
- package/lib/shared-tree/sharedTreeChangeFormat.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +14 -5
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +63 -93
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.js +1 -5
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +2 -2
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +35 -34
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +15 -15
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +40 -40
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +5 -5
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -7
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -38
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.js +1 -11
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +10 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +5 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +36 -23
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +1 -5
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +1 -11
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -5
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts +121 -120
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/lib/tableSchema.d.ts +50 -4
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +171 -75
- package/lib/tableSchema.js.map +1 -1
- package/lib/util/arrayUtilities.d.ts +20 -0
- package/lib/util/arrayUtilities.d.ts.map +1 -1
- package/lib/util/arrayUtilities.js +22 -0
- package/lib/util/arrayUtilities.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/rangeMap.d.ts +13 -0
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +69 -8
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/typeboxBrand.d.ts +1 -1
- package/lib/util/typeboxBrand.d.ts.map +1 -1
- package/lib/util/typeboxBrand.js +1 -1
- package/lib/util/typeboxBrand.js.map +1 -1
- package/lib/util/utils.d.ts +2 -2
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +24 -23
- package/src/codec/versioned/format.ts +2 -1
- package/src/core/rebase/types.ts +1 -1
- package/src/core/schema-stored/formatV1.ts +2 -1
- package/src/core/schema-stored/formatV2.ts +2 -1
- package/src/core/tree/detachedFieldIndexFormatCommon.ts +2 -1
- package/src/core/tree/detachedFieldIndexFormatV2.ts +2 -1
- package/src/core/tree/persistedTreeTextFormat.ts +2 -1
- package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -2
- package/src/feature-libraries/chunked-forest/codec/format/formatGeneric.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/format/formatV1.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/format/formatVText.ts +2 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +131 -44
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +36 -14
- package/src/feature-libraries/forest-summary/formatCommon.ts +2 -1
- package/src/feature-libraries/modular-schema/genericFieldKindFormat.ts +2 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +14 -47
- package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -1
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +2 -1
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -5
- package/src/feature-libraries/optional-field/optionalFieldChangeFormatV1.ts +2 -1
- package/src/feature-libraries/optional-field/optionalFieldChangeFormatV2.ts +2 -1
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +2 -1
- package/src/feature-libraries/schema-index/formatV1.ts +2 -1
- package/src/feature-libraries/schema-index/formatV2.ts +2 -1
- package/src/feature-libraries/sequence-field/compose.ts +1 -4
- package/src/feature-libraries/sequence-field/formatV1.ts +2 -1
- package/src/feature-libraries/sequence-field/formatV2.ts +2 -1
- package/src/feature-libraries/sequence-field/formatV3.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +4 -0
- package/src/shared-tree/sharedTree.ts +3 -10
- package/src/shared-tree/sharedTreeChangeFormat.ts +2 -1
- package/src/shared-tree/treeCheckout.ts +61 -56
- package/src/shared-tree-core/editManager.ts +2 -2
- package/src/shared-tree-core/editManagerFormatCommons.ts +2 -1
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +2 -1
- package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageFormatV1ToV4.ts +2 -1
- package/src/shared-tree-core/messageFormatVSharedBranches.ts +2 -1
- package/src/simple-tree/api/tree.ts +11 -0
- package/src/simple-tree/core/treeNodeKernel.ts +39 -15
- package/src/simple-tree/simpleSchemaFormatV1.ts +2 -1
- package/src/tableSchema.ts +306 -80
- package/src/util/arrayUtilities.ts +35 -0
- package/src/util/index.ts +2 -0
- package/src/util/rangeMap.ts +108 -9
- package/src/util/typeboxBrand.ts +2 -1
- package/src/util/utils.ts +2 -1
- package/tsconfig.json +5 -0
package/src/tableSchema.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { fail } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, fail, oob } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import { EmptyKey } from "./core/index.js";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
type TransactionConstraintAlpha,
|
|
42
42
|
createCustomizedFluidFrameworkScopedFactory,
|
|
43
43
|
} from "./simple-tree/index.js";
|
|
44
|
-
import { validateIndex, validateIndexRange } from "./util/index.js";
|
|
44
|
+
import { collectContiguousRanges, validateIndex, validateIndexRange } from "./util/index.js";
|
|
45
45
|
|
|
46
46
|
// Future improvement TODOs:
|
|
47
47
|
// - Omit `cells` property from Row insertion type.
|
|
@@ -486,6 +486,7 @@ export namespace System_TableSchema {
|
|
|
486
486
|
type Scope = typeof schemaFactory.scope;
|
|
487
487
|
|
|
488
488
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
489
|
+
type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
489
490
|
type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
490
491
|
type ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>;
|
|
491
492
|
type RowValueType = TreeNodeFromImplicitAllowedTypes<TRowSchema>;
|
|
@@ -619,18 +620,34 @@ export namespace System_TableSchema {
|
|
|
619
620
|
return undefined;
|
|
620
621
|
}
|
|
621
622
|
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
623
|
+
const columnId = this.#tryGetColumnId(columnOrIdOrIndex);
|
|
624
|
+
if (columnId === undefined) {
|
|
624
625
|
return undefined;
|
|
625
626
|
}
|
|
626
627
|
|
|
627
|
-
return (row as RowValueInternalType).cells[
|
|
628
|
+
return (row as RowValueInternalType).cells[columnId];
|
|
628
629
|
}
|
|
629
630
|
|
|
630
|
-
public insertColumns(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
631
|
+
public insertColumns(
|
|
632
|
+
columnsOrParams:
|
|
633
|
+
| readonly ColumnInsertableType[]
|
|
634
|
+
| TableSchema.InsertColumnsParameters<TColumnSchema>,
|
|
635
|
+
maybeIndex?: number,
|
|
636
|
+
): ColumnValueType[] {
|
|
637
|
+
// Dispatch on the runtime type of the first argument to disambiguate the two overloads:
|
|
638
|
+
// * Array → positional `(columns, index?)` overload
|
|
639
|
+
// * object → deprecated `(params)` property-bag overload
|
|
640
|
+
let index: number | undefined;
|
|
641
|
+
let columns: readonly ColumnInsertableType[];
|
|
642
|
+
if (Array.isArray(columnsOrParams)) {
|
|
643
|
+
index = maybeIndex;
|
|
644
|
+
columns = columnsOrParams;
|
|
645
|
+
} else {
|
|
646
|
+
const params = columnsOrParams as TableSchema.InsertColumnsParameters<TColumnSchema>;
|
|
647
|
+
index = params.index;
|
|
648
|
+
columns = params.columns;
|
|
649
|
+
}
|
|
650
|
+
|
|
634
651
|
// #region Input validation
|
|
635
652
|
|
|
636
653
|
// Ensure specified index is valid
|
|
@@ -675,10 +692,26 @@ export namespace System_TableSchema {
|
|
|
675
692
|
return columns as unknown as ColumnValueType[];
|
|
676
693
|
}
|
|
677
694
|
|
|
678
|
-
public insertRows(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
695
|
+
public insertRows(
|
|
696
|
+
rowsOrParams:
|
|
697
|
+
| readonly RowInsertableType[]
|
|
698
|
+
| TableSchema.InsertRowsParameters<TRowSchema>,
|
|
699
|
+
maybeIndex?: number,
|
|
700
|
+
): RowValueType[] {
|
|
701
|
+
// Dispatch on the runtime type of the first argument to disambiguate the two overloads:
|
|
702
|
+
// * Array → positional `(rows, index?)` overload
|
|
703
|
+
// * object → deprecated `(params)` property-bag overload
|
|
704
|
+
let index: number | undefined;
|
|
705
|
+
let rows: readonly RowInsertableType[];
|
|
706
|
+
if (Array.isArray(rowsOrParams)) {
|
|
707
|
+
index = maybeIndex;
|
|
708
|
+
rows = rowsOrParams;
|
|
709
|
+
} else {
|
|
710
|
+
const params = rowsOrParams as TableSchema.InsertRowsParameters<TRowSchema>;
|
|
711
|
+
index = params.index;
|
|
712
|
+
rows = params.rows;
|
|
713
|
+
}
|
|
714
|
+
|
|
682
715
|
// #region Input validation
|
|
683
716
|
|
|
684
717
|
// Ensure specified index is valid
|
|
@@ -691,17 +724,15 @@ export namespace System_TableSchema {
|
|
|
691
724
|
|
|
692
725
|
// #endregion
|
|
693
726
|
|
|
694
|
-
// Relevant invariant: each cell corresponds to an existing row and column
|
|
727
|
+
// Relevant invariant: each cell corresponds to an existing row and column.
|
|
695
728
|
// Prevents cell leaks from concurrently removed columns.
|
|
696
729
|
// Example scenario: Client A removes a column while concurrently Client B adds a row with cells for those columns (including the one A removed).
|
|
697
730
|
// If client B is sequenced after A, then B's row could have cells that do not correspond to existing columns.
|
|
698
|
-
//
|
|
731
|
+
// We only need to constrain columns that the new rows actually reference — a removed column with no
|
|
732
|
+
// corresponding cell in the inserted rows cannot orphan anything from this insertion.
|
|
699
733
|
// TODO: Replace with "no detach" constraint on the column array when available.
|
|
700
|
-
const columnConstraints
|
|
701
|
-
|
|
702
|
-
type: "nodeInDocument",
|
|
703
|
-
node: column as ColumnValueType,
|
|
704
|
-
}),
|
|
734
|
+
const columnConstraints = this.#buildColumnInDocumentConstraintsForRows(
|
|
735
|
+
rows as RowValueType[],
|
|
705
736
|
);
|
|
706
737
|
|
|
707
738
|
this.#applyEditsInBatch({
|
|
@@ -716,18 +747,42 @@ export namespace System_TableSchema {
|
|
|
716
747
|
this.table.rows.insertAt(index, TreeArrayNode.spread(rows) as any);
|
|
717
748
|
}
|
|
718
749
|
},
|
|
719
|
-
preconditions: columnConstraints
|
|
750
|
+
preconditions: columnConstraints,
|
|
720
751
|
});
|
|
721
752
|
|
|
722
753
|
// Inserting the input nodes into the tree hydrates them, making them usable as nodes.
|
|
723
754
|
return rows as unknown as RowValueType[];
|
|
724
755
|
}
|
|
725
756
|
|
|
726
|
-
public setCell(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
757
|
+
public setCell(
|
|
758
|
+
rowOrParams:
|
|
759
|
+
| string
|
|
760
|
+
| number
|
|
761
|
+
| RowValueType
|
|
762
|
+
| TableSchema.SetCellParameters<TCellSchema, TColumnSchema, TRowSchema>,
|
|
763
|
+
maybeColumn?: string | number | ColumnValueType,
|
|
764
|
+
maybeCell?: CellInsertableType,
|
|
765
|
+
): void {
|
|
766
|
+
// Dispatch on the presence of the second argument to disambiguate the two overloads:
|
|
767
|
+
// * `maybeColumn === undefined` → deprecated `(params)` property-bag overload; unpack from `params.key`/`params.cell`
|
|
768
|
+
// * otherwise → positional `(row, column, cell)` overload
|
|
769
|
+
let rowOrId: string | number | RowValueType;
|
|
770
|
+
let columnOrId: string | number | ColumnValueType;
|
|
771
|
+
let cell: CellInsertableType;
|
|
772
|
+
if (maybeColumn === undefined) {
|
|
773
|
+
const params = rowOrParams as TableSchema.SetCellParameters<
|
|
774
|
+
TCellSchema,
|
|
775
|
+
TColumnSchema,
|
|
776
|
+
TRowSchema
|
|
777
|
+
>;
|
|
778
|
+
rowOrId = params.key.row as string | number | RowValueType;
|
|
779
|
+
columnOrId = params.key.column as string | number | ColumnValueType;
|
|
780
|
+
cell = params.cell as CellInsertableType;
|
|
781
|
+
} else {
|
|
782
|
+
rowOrId = rowOrParams as string | number | RowValueType;
|
|
783
|
+
columnOrId = maybeColumn;
|
|
784
|
+
cell = maybeCell as CellInsertableType;
|
|
785
|
+
}
|
|
731
786
|
|
|
732
787
|
const row = this.#getRow(rowOrId);
|
|
733
788
|
const column = this.#getColumn(columnOrId);
|
|
@@ -794,13 +849,15 @@ export namespace System_TableSchema {
|
|
|
794
849
|
endIndex,
|
|
795
850
|
) as ColumnValueType[];
|
|
796
851
|
|
|
797
|
-
// First, remove all cells that correspond to each column from each row
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
852
|
+
// First, remove all cells that correspond to each column from each row.
|
|
853
|
+
// Rows are the outer loop so each row's `cells` record is touched contiguously,
|
|
854
|
+
// and the per-column `id` values are read once up front instead of per (column, row) pair.
|
|
855
|
+
const idsToDelete = columnsToRemove.map((column) => column.id);
|
|
856
|
+
for (const row of this.table.rows) {
|
|
857
|
+
const cells = (row as RowValueInternalType).cells;
|
|
858
|
+
for (const id of idsToDelete) {
|
|
802
859
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is currently how Record node entries are deleted.
|
|
803
|
-
delete
|
|
860
|
+
delete cells[id];
|
|
804
861
|
}
|
|
805
862
|
}
|
|
806
863
|
|
|
@@ -823,33 +880,47 @@ export namespace System_TableSchema {
|
|
|
823
880
|
}
|
|
824
881
|
|
|
825
882
|
// Resolve any IDs to actual nodes.
|
|
826
|
-
// This validates that all of the
|
|
883
|
+
// This validates that all of the columns exist before starting transaction.
|
|
827
884
|
// This improves user-facing error experience.
|
|
828
|
-
|
|
885
|
+
// Set insertion order is preserved on iteration, which matches the caller-supplied order
|
|
886
|
+
// expected by both the cell-deletion loop and the returned array.
|
|
887
|
+
const columnsToRemove = new Set<ColumnValueType>();
|
|
829
888
|
for (const columnOrIdToRemove of indexOrColumns) {
|
|
830
|
-
columnsToRemove.
|
|
889
|
+
columnsToRemove.add(this.#getColumn(columnOrIdToRemove));
|
|
831
890
|
}
|
|
832
891
|
|
|
892
|
+
// Collect contiguous runs of columns-to-remove as [start, end) ranges so they can be
|
|
893
|
+
// removed via a small number of `removeRange` calls below.
|
|
894
|
+
const ranges = collectContiguousRanges(this.table.columns, (column) =>
|
|
895
|
+
columnsToRemove.has(column as ColumnValueType),
|
|
896
|
+
);
|
|
897
|
+
|
|
898
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
899
|
+
// So if we throw an error here for any column, no columns will be removed.
|
|
833
900
|
this.#applyEditsInBatch({
|
|
834
901
|
applyEdits: () => {
|
|
835
|
-
//
|
|
836
|
-
//
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
902
|
+
// Remove the corresponding cell from every row.
|
|
903
|
+
// The per-column `id` values are hoisted out of the row loop so each row's `cells`
|
|
904
|
+
// record is indexed by a plain string rather than re-reading a tree-node property.
|
|
905
|
+
const idsToDelete = Array.from(columnsToRemove, (column) => column.id);
|
|
906
|
+
for (const row of this.table.rows) {
|
|
907
|
+
const cells = (row as RowValueInternalType).cells;
|
|
908
|
+
for (const id of idsToDelete) {
|
|
842
909
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is currently how Record node entries are deleted.
|
|
843
|
-
delete
|
|
910
|
+
delete cells[id];
|
|
844
911
|
}
|
|
912
|
+
}
|
|
845
913
|
|
|
846
|
-
|
|
847
|
-
|
|
914
|
+
// Remove column nodes. Ranges are iterated in reverse so each `removeRange`
|
|
915
|
+
// call doesn't shift the indices of yet-to-remove ranges at lower positions.
|
|
916
|
+
for (let r = ranges.length - 1; r >= 0; r--) {
|
|
917
|
+
const { start, end } = ranges[r] ?? oob();
|
|
918
|
+
this.table.columns.removeRange(start, end);
|
|
848
919
|
}
|
|
849
920
|
},
|
|
850
921
|
preconditions,
|
|
851
922
|
});
|
|
852
|
-
return columnsToRemove;
|
|
923
|
+
return [...columnsToRemove];
|
|
853
924
|
}
|
|
854
925
|
}
|
|
855
926
|
|
|
@@ -857,19 +928,6 @@ export namespace System_TableSchema {
|
|
|
857
928
|
indexOrRows: number | undefined | readonly string[] | readonly RowValueType[],
|
|
858
929
|
count?: number | undefined,
|
|
859
930
|
): RowValueType[] {
|
|
860
|
-
// Relevant invariant: each cell corresponds to an existing row and column
|
|
861
|
-
// Adding a constraint on columns here to prevent cells being orphaned. The relevant scenario is:
|
|
862
|
-
// Client A removes rows
|
|
863
|
-
// Client B (either concurrently or not, so long as B's edit is sequenced after A's edit) removes a column,
|
|
864
|
-
// Client A reverts the removal of the rows
|
|
865
|
-
// TODO: Replace with "no detach on revert" constraint on the column array when available.
|
|
866
|
-
const columnConstraints: TransactionConstraintAlpha[] = this.table.columns.map(
|
|
867
|
-
(column) => ({
|
|
868
|
-
type: "nodeInDocument",
|
|
869
|
-
node: column as ColumnValueType,
|
|
870
|
-
}),
|
|
871
|
-
);
|
|
872
|
-
|
|
873
931
|
if (typeof indexOrRows === "number" || indexOrRows === undefined) {
|
|
874
932
|
let removedRows: RowValueType[] | undefined;
|
|
875
933
|
const startIndex = indexOrRows ?? 0;
|
|
@@ -881,6 +939,13 @@ export namespace System_TableSchema {
|
|
|
881
939
|
}
|
|
882
940
|
|
|
883
941
|
validateIndexRange(startIndex, endIndex, this.table.rows, "Table.removeRows");
|
|
942
|
+
|
|
943
|
+
// Compute revert constraints from the rows being removed.
|
|
944
|
+
const rowsBeingRemoved = this.table.rows.slice(
|
|
945
|
+
startIndex,
|
|
946
|
+
endIndex,
|
|
947
|
+
) as readonly RowValueType[];
|
|
948
|
+
|
|
884
949
|
this.#applyEditsInBatch({
|
|
885
950
|
applyEdits: () => {
|
|
886
951
|
removedRows = removeRangeFromArray(
|
|
@@ -890,8 +955,13 @@ export namespace System_TableSchema {
|
|
|
890
955
|
"Table.removeRows",
|
|
891
956
|
);
|
|
892
957
|
},
|
|
958
|
+
// Relevant invariant: each cell corresponds to an existing row and column.
|
|
959
|
+
// On revert, the removed rows come back with their original cells, so we need
|
|
960
|
+
// each column referenced by those cells to still exist. Columns the removed rows
|
|
961
|
+
// don't reference cannot be orphaned by the revert and need not be constrained.
|
|
962
|
+
// TODO: Replace with "no detach on revert" constraint on the column array when available.
|
|
893
963
|
preconditionsOnRevert:
|
|
894
|
-
|
|
964
|
+
this.#buildColumnInDocumentConstraintsForRows(rowsBeingRemoved),
|
|
895
965
|
});
|
|
896
966
|
return removedRows ?? fail(0xccd /* Transaction did not complete */);
|
|
897
967
|
}
|
|
@@ -904,29 +974,61 @@ export namespace System_TableSchema {
|
|
|
904
974
|
// Resolve any IDs to actual nodes.
|
|
905
975
|
// This validates that all of the rows exist before starting transaction.
|
|
906
976
|
// This improves user-facing error experience.
|
|
907
|
-
|
|
977
|
+
// Set insertion order is preserved on iteration, which matches the caller-supplied order
|
|
978
|
+
// expected by the returned array.
|
|
979
|
+
const rowsToRemove = new Set<RowValueType>();
|
|
908
980
|
for (const rowToRemove of indexOrRows) {
|
|
909
|
-
rowsToRemove.
|
|
981
|
+
rowsToRemove.add(this.#getRow(rowToRemove));
|
|
910
982
|
}
|
|
983
|
+
|
|
984
|
+
// Collect contiguous runs of rows-to-remove as [start, end) ranges so they can be
|
|
985
|
+
// removed via a small number of `removeRange` calls below.
|
|
986
|
+
const ranges = collectContiguousRanges(this.table.rows, (row) =>
|
|
987
|
+
rowsToRemove.has(row as RowValueType),
|
|
988
|
+
);
|
|
989
|
+
|
|
990
|
+
// Note, throwing an error within a transaction will abort the entire transaction.
|
|
991
|
+
// So if we throw an error here for any row, no rows will be removed.
|
|
911
992
|
this.#applyEditsInBatch({
|
|
912
993
|
applyEdits: () => {
|
|
913
|
-
//
|
|
914
|
-
//
|
|
915
|
-
for (
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
this.table.rows.removeAt(index);
|
|
994
|
+
// Ranges are iterated in reverse so each `removeRange` call doesn't shift
|
|
995
|
+
// the indices of yet-to-remove ranges at lower positions.
|
|
996
|
+
for (let r = ranges.length - 1; r >= 0; r--) {
|
|
997
|
+
const { start, end } = ranges[r] ?? oob();
|
|
998
|
+
this.table.rows.removeRange(start, end);
|
|
919
999
|
}
|
|
920
1000
|
},
|
|
921
|
-
|
|
1001
|
+
// Relevant invariant: each cell corresponds to an existing row and column.
|
|
1002
|
+
// On revert, the removed rows come back with their original cells, so we need
|
|
1003
|
+
// each column referenced by those cells to still exist. Columns the removed rows
|
|
1004
|
+
// don't reference cannot be orphaned by the revert and need not be constrained.
|
|
1005
|
+
// TODO: Replace with "no detach on revert" constraint on the column array when available.
|
|
1006
|
+
preconditionsOnRevert: this.#buildColumnInDocumentConstraintsForRows(rowsToRemove),
|
|
922
1007
|
});
|
|
923
|
-
return rowsToRemove;
|
|
1008
|
+
return [...rowsToRemove];
|
|
924
1009
|
}
|
|
925
1010
|
|
|
926
1011
|
public removeCell(
|
|
927
|
-
|
|
1012
|
+
rowOrKey:
|
|
1013
|
+
| string
|
|
1014
|
+
| number
|
|
1015
|
+
| RowValueType
|
|
1016
|
+
| TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
1017
|
+
maybeColumn?: string | number | ColumnValueType,
|
|
928
1018
|
): CellValueType | undefined {
|
|
929
|
-
|
|
1019
|
+
// Dispatch on the presence of the second argument to disambiguate the two overloads:
|
|
1020
|
+
// * `maybeColumn === undefined` → deprecated `(key)` overload; unpack from `key.row`/`key.column`
|
|
1021
|
+
// * otherwise → positional `(row, column)` overload
|
|
1022
|
+
let rowOrIdOrIndex: string | number | RowValueType;
|
|
1023
|
+
let columnOrIdOrIndex: string | number | ColumnValueType;
|
|
1024
|
+
if (maybeColumn === undefined) {
|
|
1025
|
+
const key = rowOrKey as TableSchema.CellKey<TColumnSchema, TRowSchema>;
|
|
1026
|
+
rowOrIdOrIndex = key.row as string | number | RowValueType;
|
|
1027
|
+
columnOrIdOrIndex = key.column as string | number | ColumnValueType;
|
|
1028
|
+
} else {
|
|
1029
|
+
rowOrIdOrIndex = rowOrKey as string | number | RowValueType;
|
|
1030
|
+
columnOrIdOrIndex = maybeColumn;
|
|
1031
|
+
}
|
|
930
1032
|
const row = this.#getRow(rowOrIdOrIndex) as RowValueInternalType;
|
|
931
1033
|
const column = this.#getColumn(columnOrIdOrIndex);
|
|
932
1034
|
|
|
@@ -1046,6 +1148,59 @@ export namespace System_TableSchema {
|
|
|
1046
1148
|
});
|
|
1047
1149
|
}
|
|
1048
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* Builds an array of `nodeInDocument` constraints over each column referenced by a cell
|
|
1153
|
+
* in any of `rows`.
|
|
1154
|
+
*
|
|
1155
|
+
* @remarks
|
|
1156
|
+
* The orphan-cell invariant only cares about columns that have cells in the affected rows;
|
|
1157
|
+
* columns absent from those rows' cells have no cell to orphan, so they need not be
|
|
1158
|
+
* constrained. This keeps the constraint set proportional to the cells touched rather than
|
|
1159
|
+
* the total column count, which matters for sparse tables.
|
|
1160
|
+
*
|
|
1161
|
+
* Returns `undefined` when:
|
|
1162
|
+
* - The table is unhydrated (no transaction will run), or
|
|
1163
|
+
* - None of `rows` reference any cells.
|
|
1164
|
+
*
|
|
1165
|
+
* In those cases there is nothing to constrain, and returning `undefined` avoids
|
|
1166
|
+
* allocating an array that would only be discarded.
|
|
1167
|
+
*/
|
|
1168
|
+
#buildColumnInDocumentConstraintsForRows(
|
|
1169
|
+
rows: Iterable<RowValueType>,
|
|
1170
|
+
): TransactionConstraintAlpha[] | undefined {
|
|
1171
|
+
if (!TreeAlpha.context(this).isBranch()) {
|
|
1172
|
+
return undefined;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
const referencedColumnIds = new Set<string>();
|
|
1176
|
+
for (const row of rows) {
|
|
1177
|
+
// `cells` is intentionally hidden on the public row type, so cast to read it.
|
|
1178
|
+
const cells = (row as RowValueInternalType).cells;
|
|
1179
|
+
if (cells === undefined) {
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
for (const id of Object.keys(cells)) {
|
|
1183
|
+
referencedColumnIds.add(id);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
if (referencedColumnIds.size === 0) {
|
|
1188
|
+
return undefined;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
const columnCache = this.#getColumnCache();
|
|
1192
|
+
const constraints: TransactionConstraintAlpha[] = [];
|
|
1193
|
+
for (const id of referencedColumnIds) {
|
|
1194
|
+
const column = columnCache.get(id) ?? fail(0xd05 /* Column ID not found in cache */);
|
|
1195
|
+
constraints.push({ type: "nodeInDocument", node: column });
|
|
1196
|
+
}
|
|
1197
|
+
assert(
|
|
1198
|
+
constraints.length > 0,
|
|
1199
|
+
0xd06 /* No constraints generated for column references. */,
|
|
1200
|
+
);
|
|
1201
|
+
return constraints;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1049
1204
|
/**
|
|
1050
1205
|
* Returns the column ID → column node cache, building and caching it first if stale.
|
|
1051
1206
|
*
|
|
@@ -1080,6 +1235,19 @@ export namespace System_TableSchema {
|
|
|
1080
1235
|
return cache;
|
|
1081
1236
|
}
|
|
1082
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* Attempts to resolve the provided Column node, ID, or index to the corresponding Column ID.
|
|
1240
|
+
* Returns `undefined` if there is no match.
|
|
1241
|
+
*/
|
|
1242
|
+
#tryGetColumnId(
|
|
1243
|
+
columnOrIdOrIndex: ColumnValueType | string | number,
|
|
1244
|
+
): string | undefined {
|
|
1245
|
+
if (typeof columnOrIdOrIndex === "string") {
|
|
1246
|
+
return columnOrIdOrIndex;
|
|
1247
|
+
}
|
|
1248
|
+
return this.#tryGetColumn(columnOrIdOrIndex)?.id;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1083
1251
|
/**
|
|
1084
1252
|
* Attempts to resolve the provided Column node or ID to a Column node in the table.
|
|
1085
1253
|
* Returns `undefined` if there is no match.
|
|
@@ -1293,10 +1461,9 @@ export namespace System_TableSchema {
|
|
|
1293
1461
|
|
|
1294
1462
|
// Note: we intentionally hide `cells` on `IRow` to avoid leaking the internal data representation as much as possible, so we have to cast here.
|
|
1295
1463
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
for (const key of keys) {
|
|
1464
|
+
const cells = (newRow as any).cells;
|
|
1465
|
+
if (cells !== undefined) {
|
|
1466
|
+
for (const key of Object.keys(cells)) {
|
|
1300
1467
|
if (!columnIds.has(key)) {
|
|
1301
1468
|
throw new UsageError(
|
|
1302
1469
|
`Attempted to insert a row containing a cell under column ID "${key}", but the table does not contain a column with that ID.`,
|
|
@@ -1727,8 +1894,9 @@ export namespace TableSchema {
|
|
|
1727
1894
|
}
|
|
1728
1895
|
|
|
1729
1896
|
/**
|
|
1730
|
-
* {@link TableSchema.Table.insertColumns} parameters.
|
|
1897
|
+
* {@link TableSchema.Table.(insertColumns:2)} parameters.
|
|
1731
1898
|
* @input @beta
|
|
1899
|
+
* @deprecated Use the positional argument overload of {@link TableSchema.Table.(insertColumns:1)} instead.
|
|
1732
1900
|
*/
|
|
1733
1901
|
export interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
|
|
1734
1902
|
/**
|
|
@@ -1744,8 +1912,9 @@ export namespace TableSchema {
|
|
|
1744
1912
|
}
|
|
1745
1913
|
|
|
1746
1914
|
/**
|
|
1747
|
-
* {@link TableSchema.Table.insertRows} parameters.
|
|
1915
|
+
* {@link TableSchema.Table.(insertRows:2)} parameters.
|
|
1748
1916
|
* @input @beta
|
|
1917
|
+
* @deprecated Use the positional argument overload of {@link TableSchema.Table.(insertRows:1)} instead.
|
|
1749
1918
|
*/
|
|
1750
1919
|
export interface InsertRowsParameters<TRow extends ImplicitAllowedTypes> {
|
|
1751
1920
|
/**
|
|
@@ -1761,8 +1930,9 @@ export namespace TableSchema {
|
|
|
1761
1930
|
}
|
|
1762
1931
|
|
|
1763
1932
|
/**
|
|
1764
|
-
* {@link TableSchema.Table.setCell} parameters.
|
|
1933
|
+
* {@link TableSchema.Table.(setCell:2)} parameters.
|
|
1765
1934
|
* @input @beta
|
|
1935
|
+
* @deprecated Use the positional argument overload of {@link TableSchema.Table.(setCell:1)} instead.
|
|
1766
1936
|
*/
|
|
1767
1937
|
export interface SetCellParameters<
|
|
1768
1938
|
TCell extends ImplicitAllowedTypes,
|
|
@@ -1849,17 +2019,46 @@ export namespace TableSchema {
|
|
|
1849
2019
|
*/
|
|
1850
2020
|
getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1851
2021
|
|
|
2022
|
+
/**
|
|
2023
|
+
* Inserts 0 or more columns into the table.
|
|
2024
|
+
* @param columns - The columns to insert.
|
|
2025
|
+
* @param index - The index at which to insert the new columns. If omitted, the columns are appended to the end of the table.
|
|
2026
|
+
* @throws Throws an error if the specified index is out of range. No columns are inserted in this case.
|
|
2027
|
+
*/
|
|
2028
|
+
insertColumns(
|
|
2029
|
+
columns: readonly InsertableTreeNodeFromImplicitAllowedTypes<TColumn>[],
|
|
2030
|
+
index?: number,
|
|
2031
|
+
): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1852
2032
|
/**
|
|
1853
2033
|
* Inserts 0 or more columns into the table.
|
|
1854
2034
|
*
|
|
1855
2035
|
* @throws Throws an error if the specified index is out of range.
|
|
1856
2036
|
*
|
|
1857
2037
|
* No columns are inserted in this case.
|
|
2038
|
+
*
|
|
2039
|
+
* @deprecated Use {@link TableSchema.Table.(insertColumns:1)} instead.
|
|
1858
2040
|
*/
|
|
1859
2041
|
insertColumns(
|
|
1860
2042
|
params: InsertColumnsParameters<TColumn>,
|
|
1861
2043
|
): TreeNodeFromImplicitAllowedTypes<TColumn>[];
|
|
1862
2044
|
|
|
2045
|
+
/**
|
|
2046
|
+
* Inserts 0 or more rows into the table.
|
|
2047
|
+
* @param rows - The rows to insert.
|
|
2048
|
+
* @param index - The index at which to insert the new rows. If omitted, the rows are appended to the end of the table.
|
|
2049
|
+
* @throws
|
|
2050
|
+
* Throws an error in the following cases:
|
|
2051
|
+
*
|
|
2052
|
+
* - One or more of the rows contains cells for columns that do not exist in the table.
|
|
2053
|
+
*
|
|
2054
|
+
* - The specified index is out of range.
|
|
2055
|
+
*
|
|
2056
|
+
* No rows are inserted in these cases.
|
|
2057
|
+
*/
|
|
2058
|
+
insertRows(
|
|
2059
|
+
rows: readonly InsertableTreeNodeFromImplicitAllowedTypes<TRow>[],
|
|
2060
|
+
index?: number,
|
|
2061
|
+
): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
1863
2062
|
/**
|
|
1864
2063
|
* Inserts 0 or more rows into the table.
|
|
1865
2064
|
*
|
|
@@ -1871,12 +2070,27 @@ export namespace TableSchema {
|
|
|
1871
2070
|
* - The specified index is out of range.
|
|
1872
2071
|
*
|
|
1873
2072
|
* No rows are inserted in these cases.
|
|
2073
|
+
*
|
|
2074
|
+
* @deprecated Use {@link TableSchema.Table.(insertRows:1)} instead.
|
|
1874
2075
|
*/
|
|
1875
2076
|
insertRows(params: InsertRowsParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
1876
2077
|
|
|
1877
2078
|
/**
|
|
1878
2079
|
* Sets the cell at the specified location in the table.
|
|
1879
|
-
* @
|
|
2080
|
+
* @param row - The {@link TableSchema.Row}, {@link TableSchema.Row.id}, or row index at which the cell is located.
|
|
2081
|
+
* @param column - The {@link TableSchema.Column}, {@link TableSchema.Column.id}, or column index at which the cell is located.
|
|
2082
|
+
* @param cell - The cell to set.
|
|
2083
|
+
* @remarks To remove a cell, call {@link TableSchema.Table.(removeCell:1)} instead.
|
|
2084
|
+
*/
|
|
2085
|
+
setCell(
|
|
2086
|
+
row: string | number | TreeNodeFromImplicitAllowedTypes<TRow>,
|
|
2087
|
+
column: string | number | TreeNodeFromImplicitAllowedTypes<TColumn>,
|
|
2088
|
+
cell: InsertableTreeNodeFromImplicitAllowedTypes<TCell>,
|
|
2089
|
+
): void;
|
|
2090
|
+
/**
|
|
2091
|
+
* Sets the cell at the specified location in the table.
|
|
2092
|
+
* @remarks To remove a cell, call {@link TableSchema.Table.(removeCell:1)} instead.
|
|
2093
|
+
* @deprecated Use {@link TableSchema.Table.(setCell:1)} instead.
|
|
1880
2094
|
*/
|
|
1881
2095
|
setCell(params: SetCellParameters<TCell, TColumn, TRow>): void;
|
|
1882
2096
|
|
|
@@ -1956,10 +2170,22 @@ export namespace TableSchema {
|
|
|
1956
2170
|
*/
|
|
1957
2171
|
removeRows(rows: readonly string[]): TreeNodeFromImplicitAllowedTypes<TRow>[];
|
|
1958
2172
|
|
|
2173
|
+
/**
|
|
2174
|
+
* Removes the cell at the specified location in the table.
|
|
2175
|
+
* @param row - The {@link TableSchema.Row}, {@link TableSchema.Row.id}, or row index at which the cell is located.
|
|
2176
|
+
* @param column - The {@link TableSchema.Column}, {@link TableSchema.Column.id}, or column index at which the cell is located.
|
|
2177
|
+
* @returns The cell if it exists, otherwise undefined.
|
|
2178
|
+
* @throws Throws an error if the location does not exist in the table.
|
|
2179
|
+
*/
|
|
2180
|
+
removeCell(
|
|
2181
|
+
row: string | number | TreeNodeFromImplicitAllowedTypes<TRow>,
|
|
2182
|
+
column: string | number | TreeNodeFromImplicitAllowedTypes<TColumn>,
|
|
2183
|
+
): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1959
2184
|
/**
|
|
1960
2185
|
* Removes the cell at the specified location in the table.
|
|
1961
2186
|
* @returns The cell if it exists, otherwise undefined.
|
|
1962
2187
|
* @throws Throws an error if the location does not exist in the table.
|
|
2188
|
+
* @deprecated Use {@link TableSchema.Table.(removeCell:1)} instead.
|
|
1963
2189
|
*/
|
|
1964
2190
|
removeCell(
|
|
1965
2191
|
key: CellKey<TColumn, TRow>,
|
|
@@ -86,3 +86,38 @@ export function validateIndexRange(
|
|
|
86
86
|
validateIndex(startIndex, array, apiName, true);
|
|
87
87
|
validateIndex(endIndex, array, apiName, true);
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A half-open `[start, end)` range of array indices.
|
|
92
|
+
*/
|
|
93
|
+
export interface IndexRange {
|
|
94
|
+
/** Start index, inclusive. */
|
|
95
|
+
readonly start: number;
|
|
96
|
+
/** End index, exclusive. */
|
|
97
|
+
readonly end: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Walks `array` in order and collects the indices of every element for which `predicate` returns
|
|
102
|
+
* `true` into contiguous `[start, end)` ranges.
|
|
103
|
+
* @param array - The array (or array-like) to scan.
|
|
104
|
+
* @param shouldInclude - Returns `true` for elements whose indices should be included.
|
|
105
|
+
* @returns The collected ranges in ascending order. The returned array is empty if no elements match.
|
|
106
|
+
*/
|
|
107
|
+
export function collectContiguousRanges<T>(
|
|
108
|
+
array: { readonly length: number; readonly [index: number]: T },
|
|
109
|
+
shouldInclude: (item: T) => boolean,
|
|
110
|
+
): readonly IndexRange[] {
|
|
111
|
+
const ranges: { start: number; end: number }[] = [];
|
|
112
|
+
for (let i = 0; i < array.length; i++) {
|
|
113
|
+
if (shouldInclude(array[i] as T)) {
|
|
114
|
+
const last = ranges[ranges.length - 1];
|
|
115
|
+
if (last?.end === i) {
|
|
116
|
+
last.end = i + 1;
|
|
117
|
+
} else {
|
|
118
|
+
ranges.push({ start: i, end: i + 1 });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return ranges;
|
|
123
|
+
}
|