@fluidframework/tree 2.23.0-323641 → 2.23.0-325054
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +1 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +47 -0
- package/api-report/tree.alpha.api.md +169 -10
- package/api-report/tree.beta.api.md +101 -9
- package/api-report/tree.legacy.alpha.api.md +101 -9
- package/api-report/tree.legacy.public.api.md +101 -9
- package/api-report/tree.public.api.md +101 -9
- package/dist/alpha.d.ts +20 -0
- package/dist/beta.d.ts +15 -0
- package/dist/codec/codec.js +3 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/discriminatedUnions.d.ts.map +1 -1
- package/dist/codec/discriminatedUnions.js +1 -1
- package/dist/codec/discriminatedUnions.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -3
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +5 -4
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/treeTextFormat.js +1 -1
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +11 -8
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -2
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +3 -3
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.js +14 -14
- package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +6 -4
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +4 -3
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +5 -4
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +6 -4
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js +4 -4
- package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +5 -5
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +1 -1
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +1 -1
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +1 -1
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +1 -1
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +6 -4
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +113 -0
- package/dist/jsonDomainSchema.d.ts.map +1 -0
- package/dist/jsonDomainSchema.js +101 -0
- package/dist/jsonDomainSchema.js.map +1 -0
- package/dist/legacy.d.ts +15 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +15 -0
- package/dist/serializableDomainSchema.d.ts +108 -0
- package/dist/serializableDomainSchema.d.ts.map +1 -0
- package/dist/serializableDomainSchema.js +90 -0
- package/dist/serializableDomainSchema.js.map +1 -0
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -1
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +35 -19
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +14 -17
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeApiAlpha.js +4 -4
- package/dist/shared-tree/treeApiAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +8 -7
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -2
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +2 -2
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/component.d.ts +30 -0
- package/dist/simple-tree/api/component.d.ts.map +1 -0
- package/dist/simple-tree/api/component.js +26 -0
- package/dist/simple-tree/api/component.js.map +1 -0
- package/dist/simple-tree/api/customTree.js +3 -3
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +0 -8
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -25
- package/dist/simple-tree/api/schemaFactory.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/api/simpleTreeIndex.js +3 -3
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +2 -3
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +7 -18
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +127 -19
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js +17 -0
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +5 -4
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/api/view.js +1 -1
- package/dist/simple-tree/api/view.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +1 -1
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +2 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/schemaCaching.js +1 -1
- package/dist/simple-tree/core/schemaCaching.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +6 -6
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/flexList.d.ts +4 -5
- package/dist/simple-tree/flexList.d.ts.map +1 -1
- package/dist/simple-tree/flexList.js +1 -14
- package/dist/simple-tree/flexList.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +6 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +25 -2
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +4 -2
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.js +1 -1
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +211 -9
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +83 -2
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.js +3 -3
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +3 -6
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts +7 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +18 -7
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/util/idAllocator.js +1 -1
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +4 -4
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts +2 -10
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +9 -28
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts +7 -6
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +18 -13
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +20 -0
- package/lib/beta.d.ts +15 -0
- package/lib/codec/codec.js +3 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/discriminatedUnions.d.ts.map +1 -1
- package/lib/codec/discriminatedUnions.js +1 -1
- package/lib/codec/discriminatedUnions.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +5 -4
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/treeTextFormat.js +1 -1
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +11 -8
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +3 -3
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.js +14 -14
- package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +6 -4
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +4 -3
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +5 -4
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +6 -4
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js +4 -4
- package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +6 -6
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +1 -1
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +1 -1
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +1 -1
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +1 -1
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +6 -4
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +113 -0
- package/lib/jsonDomainSchema.d.ts.map +1 -0
- package/lib/jsonDomainSchema.js +98 -0
- package/lib/jsonDomainSchema.js.map +1 -0
- package/lib/legacy.d.ts +15 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +15 -0
- package/lib/serializableDomainSchema.d.ts +108 -0
- package/lib/serializableDomainSchema.d.ts.map +1 -0
- package/lib/serializableDomainSchema.js +87 -0
- package/lib/serializableDomainSchema.js.map +1 -0
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -1
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +35 -19
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +15 -18
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeApiAlpha.js +4 -4
- package/lib/shared-tree/treeApiAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +8 -7
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -2
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +2 -2
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/component.d.ts +30 -0
- package/lib/simple-tree/api/component.d.ts.map +1 -0
- package/lib/simple-tree/api/component.js +23 -0
- package/lib/simple-tree/api/component.js.map +1 -0
- package/lib/simple-tree/api/customTree.js +3 -3
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +0 -8
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -22
- package/lib/simple-tree/api/schemaFactory.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/api/simpleTreeIndex.js +3 -3
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +3 -4
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +9 -20
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +127 -19
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js +15 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +5 -4
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/api/view.js +1 -1
- package/lib/simple-tree/api/view.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +1 -1
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +2 -2
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/schemaCaching.js +1 -1
- package/lib/simple-tree/core/schemaCaching.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +6 -6
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +5 -5
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/flexList.d.ts +4 -5
- package/lib/simple-tree/flexList.d.ts.map +1 -1
- package/lib/simple-tree/flexList.js +0 -12
- package/lib/simple-tree/flexList.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +25 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +4 -2
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.js +1 -1
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +211 -9
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +81 -3
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.js +3 -3
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +5 -8
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts +7 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +18 -7
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/util/idAllocator.js +1 -1
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts +2 -10
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +5 -23
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts +7 -6
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +15 -11
- package/lib/util/utils.js.map +1 -1
- package/package.json +27 -23
- package/src/codec/codec.ts +3 -3
- package/src/codec/discriminatedUnions.ts +2 -1
- package/src/core/schema-stored/schema.ts +5 -3
- package/src/core/tree/anchorSet.ts +5 -4
- package/src/core/tree/treeTextFormat.ts +1 -1
- package/src/feature-libraries/chunked-forest/basicChunk.ts +11 -8
- package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -2
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +2 -2
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +4 -3
- package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncoding.ts +4 -3
- package/src/feature-libraries/chunked-forest/emptyChunk.ts +14 -14
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +6 -4
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
- package/src/feature-libraries/default-schema/schemaChecker.ts +1 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +6 -8
- package/src/feature-libraries/flex-tree/lazyNode.ts +6 -4
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -1
- package/src/feature-libraries/modular-schema/comparison.ts +7 -5
- package/src/feature-libraries/modular-schema/isNeverTree.ts +6 -4
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -4
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +7 -6
- package/src/feature-libraries/node-key/mockNodeKeyManager.ts +1 -1
- package/src/feature-libraries/object-forest/objectForest.ts +1 -1
- package/src/feature-libraries/schema-index/codec.ts +1 -1
- package/src/feature-libraries/sequence-field/compose.ts +1 -1
- package/src/feature-libraries/sequence-field/invert.ts +1 -1
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +1 -1
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +1 -1
- package/src/feature-libraries/sequence-field/utils.ts +1 -1
- package/src/feature-libraries/treeCursorUtils.ts +6 -4
- package/src/index.ts +22 -1
- package/src/jsonDomainSchema.ts +129 -0
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +121 -0
- package/src/shared-tree/index.ts +0 -1
- package/src/shared-tree/schematizeTree.ts +1 -1
- package/src/shared-tree/sharedTree.ts +26 -41
- package/src/shared-tree/sharedTreeChangeFamily.ts +1 -1
- package/src/shared-tree/treeApiAlpha.ts +12 -4
- package/src/shared-tree/treeCheckout.ts +1 -1
- package/src/shared-tree-core/editManager.ts +8 -7
- package/src/shared-tree-core/sharedTreeCore.ts +6 -4
- package/src/simple-tree/api/component.ts +42 -0
- package/src/simple-tree/api/customTree.ts +3 -3
- package/src/simple-tree/api/index.ts +7 -0
- package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
- package/src/simple-tree/api/schemaFactory.ts +1 -28
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
- package/src/simple-tree/api/simpleTreeIndex.ts +3 -3
- package/src/simple-tree/api/tree.ts +3 -3
- package/src/simple-tree/api/treeNodeApi.ts +10 -18
- package/src/simple-tree/api/typesUnsafe.ts +193 -18
- package/src/simple-tree/api/verboseTree.ts +8 -4
- package/src/simple-tree/api/view.ts +1 -1
- package/src/simple-tree/arrayNode.ts +2 -2
- package/src/simple-tree/core/getOrCreateNode.ts +2 -1
- package/src/simple-tree/core/schemaCaching.ts +1 -1
- package/src/simple-tree/core/treeNodeKernel.ts +9 -6
- package/src/simple-tree/core/unhydratedFlexTree.ts +7 -5
- package/src/simple-tree/flexList.ts +4 -14
- package/src/simple-tree/index.ts +25 -1
- package/src/simple-tree/objectNode.ts +50 -5
- package/src/simple-tree/proxies.ts +1 -1
- package/src/simple-tree/schemaTypes.ts +322 -23
- package/src/simple-tree/toMapTree.ts +3 -3
- package/src/simple-tree/toStoredSchema.ts +5 -7
- package/src/simple-tree/treeNodeValid.ts +21 -7
- package/src/util/idAllocator.ts +1 -1
- package/src/util/index.ts +2 -2
- package/src/util/nestedMap.ts +9 -33
- package/src/util/utils.ts +20 -12
|
@@ -27,13 +27,13 @@ import {
|
|
|
27
27
|
type TreeFieldFromImplicitField,
|
|
28
28
|
type UnsafeUnknownSchema,
|
|
29
29
|
FieldKind,
|
|
30
|
+
markSchemaMostDerived,
|
|
30
31
|
} from "../schemaTypes.js";
|
|
31
32
|
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
32
33
|
import { toStoredSchema } from "../toStoredSchema.js";
|
|
33
34
|
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
34
35
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
35
36
|
import { isObjectNodeSchema, type ObjectNodeSchema } from "../objectNodeTypes.js";
|
|
36
|
-
import { markSchemaMostDerived } from "./schemaFactory.js";
|
|
37
37
|
import { fail, getOrCreate } from "../../util/index.js";
|
|
38
38
|
import type { MakeNominal } from "../../util/index.js";
|
|
39
39
|
import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
@@ -280,7 +280,7 @@ export class TreeViewConfiguration<
|
|
|
280
280
|
// This ensures if multiple schema extending the same schema factory generated class are present (or have been constructed, or get constructed in the future),
|
|
281
281
|
// an error is reported.
|
|
282
282
|
|
|
283
|
-
node: markSchemaMostDerived,
|
|
283
|
+
node: (schema) => markSchemaMostDerived(schema, true),
|
|
284
284
|
allowedTypes(types): void {
|
|
285
285
|
if (config.preventAmbiguity) {
|
|
286
286
|
checkUnion(types, ambiguityErrors);
|
|
@@ -376,7 +376,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
376
376
|
// For each field of schema, remove schema from possiblyAmbiguous that do not have that field
|
|
377
377
|
for (const [key, field] of schema.fields) {
|
|
378
378
|
if (field.kind === FieldKind.Required) {
|
|
379
|
-
const withKey = allObjectKeys.get(key) ?? fail(
|
|
379
|
+
const withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);
|
|
380
380
|
for (const candidate of possiblyAmbiguous) {
|
|
381
381
|
if (!withKey.has(candidate)) {
|
|
382
382
|
possiblyAmbiguous.delete(candidate);
|
|
@@ -7,13 +7,14 @@ import { assert, oob } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
|
|
8
8
|
import { EmptyKey, rootFieldKey } from "../../core/index.js";
|
|
9
9
|
import { type TreeStatus, isTreeValue, FieldKinds } from "../../feature-libraries/index.js";
|
|
10
|
-
import { fail, extractFromOpaque
|
|
10
|
+
import { fail, extractFromOpaque } from "../../util/index.js";
|
|
11
11
|
import {
|
|
12
12
|
type TreeLeafValue,
|
|
13
13
|
type ImplicitFieldSchema,
|
|
14
14
|
FieldSchema,
|
|
15
15
|
type ImplicitAllowedTypes,
|
|
16
16
|
type TreeNodeFromImplicitAllowedTypes,
|
|
17
|
+
normalizeAllowedTypes,
|
|
17
18
|
} from "../schemaTypes.js";
|
|
18
19
|
import {
|
|
19
20
|
booleanSchema,
|
|
@@ -39,7 +40,6 @@ import {
|
|
|
39
40
|
getOrCreateInnerNode,
|
|
40
41
|
} from "../core/index.js";
|
|
41
42
|
import { isObjectNodeSchema } from "../objectNodeTypes.js";
|
|
42
|
-
import { isLazy, type LazyItem } from "../flexList.js";
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Provides various functions for analyzing {@link TreeNode}s.
|
|
@@ -174,7 +174,7 @@ export const treeNodeApi: TreeNodeApi = {
|
|
|
174
174
|
changedFields,
|
|
175
175
|
(field) =>
|
|
176
176
|
nodeSchema.storedKeyToPropertyKey.get(field) ??
|
|
177
|
-
fail(
|
|
177
|
+
fail(0xb36 /* Could not find stored key in schema. */),
|
|
178
178
|
),
|
|
179
179
|
);
|
|
180
180
|
listener({ changedProperties });
|
|
@@ -203,26 +203,18 @@ export const treeNodeApi: TreeNodeApi = {
|
|
|
203
203
|
value: unknown,
|
|
204
204
|
schema: TSchema,
|
|
205
205
|
): value is TreeNodeFromImplicitAllowedTypes<TSchema> {
|
|
206
|
+
// This "is" utility would return false if the provided schema is a base type of the actual schema.
|
|
207
|
+
// This could be confusing, and that case can only be hit when violating the rule that there is a single most derived schema that gets used (See documentation on TreeNodeSchemaClass).
|
|
208
|
+
// Therefore this uses markSchemaMostDerived to ensure an informative usage error is thrown in the case where a base type is used.
|
|
209
|
+
|
|
206
210
|
const actualSchema = tryGetSchema(value);
|
|
207
211
|
if (actualSchema === undefined) {
|
|
208
212
|
return false;
|
|
209
213
|
}
|
|
210
|
-
|
|
211
|
-
for (const singleSchema of schema) {
|
|
212
|
-
const testSchema = isLazy(singleSchema) ? singleSchema() : singleSchema;
|
|
213
|
-
if (testSchema === actualSchema) {
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return false;
|
|
218
|
-
} else {
|
|
219
|
-
// Linter is incorrect about this bering unnecessary: it does not compile without the type assertion.
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
221
|
-
return (schema as TreeNodeSchema) === actualSchema;
|
|
222
|
-
}
|
|
214
|
+
return normalizeAllowedTypes(schema).has(actualSchema);
|
|
223
215
|
},
|
|
224
216
|
schema(node: TreeNode | TreeLeafValue): TreeNodeSchema {
|
|
225
|
-
return tryGetSchema(node) ?? fail(
|
|
217
|
+
return tryGetSchema(node) ?? fail(0xb37 /* Not a tree node */);
|
|
226
218
|
},
|
|
227
219
|
shortId(node: TreeNode): number | string | undefined {
|
|
228
220
|
const schema = node[typeSchemaSymbol];
|
|
@@ -341,7 +333,7 @@ function getPropertyKeyFromStoredKey(
|
|
|
341
333
|
}
|
|
342
334
|
|
|
343
335
|
if (fields[storedKey] === undefined) {
|
|
344
|
-
fail(
|
|
336
|
+
fail(0xb38 /* Existing stored key should always map to a property key */);
|
|
345
337
|
}
|
|
346
338
|
|
|
347
339
|
return storedKey;
|
|
@@ -8,6 +8,8 @@ import type { RestrictiveStringRecord, UnionToIntersection } from "../../util/in
|
|
|
8
8
|
import type {
|
|
9
9
|
ApplyKind,
|
|
10
10
|
ApplyKindInput,
|
|
11
|
+
CustomizedSchemaTyping,
|
|
12
|
+
CustomTypes,
|
|
11
13
|
FieldKind,
|
|
12
14
|
FieldSchema,
|
|
13
15
|
ImplicitAllowedTypes,
|
|
@@ -25,6 +27,7 @@ import type {
|
|
|
25
27
|
} from "../core/index.js";
|
|
26
28
|
import type { TreeArrayNode } from "../arrayNode.js";
|
|
27
29
|
import type { FlexListToUnion, LazyItem } from "../flexList.js";
|
|
30
|
+
import type { ApplyKindAssignment } from "../objectNode.js";
|
|
28
31
|
|
|
29
32
|
/*
|
|
30
33
|
* TODO:
|
|
@@ -48,17 +51,168 @@ import type { FlexListToUnion, LazyItem } from "../flexList.js";
|
|
|
48
51
|
*/
|
|
49
52
|
export type Unenforced<_DesiredExtendsConstraint> = unknown;
|
|
50
53
|
|
|
54
|
+
/**
|
|
55
|
+
* {@link Unenforced} version of {@link customizeSchemaTyping} for use with recursive schema types.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* When using this API to modify a schema derived type such that the type is no longer recursive,
|
|
59
|
+
* or uses an externally defined type (which can be recursive), {@link customizeSchemaTyping} should be used instead for an improved developer experience.
|
|
60
|
+
* Additionally, in this case, none of the "unsafe" type variants should be needed: the whole schema (with runtime but not schema derived type recursion)
|
|
61
|
+
* should use the normal (not unsafe/recursive) APIs.
|
|
62
|
+
* @alpha
|
|
63
|
+
*/
|
|
64
|
+
export function customizeSchemaTypingUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>>(
|
|
65
|
+
schema: TSchema,
|
|
66
|
+
): CustomizerUnsafe<TSchema> {
|
|
67
|
+
// This function just does type branding, and duplicating the typing here to avoid any would just make it harder to maintain not easier:
|
|
68
|
+
const f = (): any => schema;
|
|
69
|
+
return { simplified: f, simplifiedUnrestricted: f, custom: f };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* {@link Unenforced} version of `Customizer`.
|
|
74
|
+
* @remarks
|
|
75
|
+
* This has fewer options than the safe version, but all options can still be expressed using the "custom" method.
|
|
76
|
+
* @sealed @public
|
|
77
|
+
*/
|
|
78
|
+
export interface CustomizerUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> {
|
|
79
|
+
/**
|
|
80
|
+
* Replace typing with a single substitute type which allowed types must implement.
|
|
81
|
+
* @remarks
|
|
82
|
+
* This is generally type safe for reading the tree, but allows instances of `T` other than those listed in the schema to be assigned,
|
|
83
|
+
* which can be out of schema and err at runtime in the same way {@link CustomizerUnsafe.relaxed} does.
|
|
84
|
+
* Until with {@link CustomizerUnsafe.relaxed}, implicit construction is disabled, meaning all nodes must be explicitly constructed (and thus implement `T`) before being inserted.
|
|
85
|
+
*/
|
|
86
|
+
simplified<
|
|
87
|
+
T extends (TreeNode | TreeLeafValue) & TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>,
|
|
88
|
+
>(): CustomizedSchemaTyping<
|
|
89
|
+
TSchema,
|
|
90
|
+
{
|
|
91
|
+
input: T;
|
|
92
|
+
readWrite: T;
|
|
93
|
+
output: T;
|
|
94
|
+
}
|
|
95
|
+
>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The same as {@link CustomizerUnsafe} except that more T values are allowed, even ones not known to be implemented by `TSchema`.
|
|
99
|
+
*/
|
|
100
|
+
simplifiedUnrestricted<T extends TreeNode | TreeLeafValue>(): CustomizedSchemaTyping<
|
|
101
|
+
TSchema,
|
|
102
|
+
{
|
|
103
|
+
input: T;
|
|
104
|
+
readWrite: T;
|
|
105
|
+
output: T;
|
|
106
|
+
}
|
|
107
|
+
>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fully arbitrary customization.
|
|
111
|
+
* Provided types override existing types.
|
|
112
|
+
* @remarks
|
|
113
|
+
* This can express any of the customizations possible via other {@link CustomizerUnsafe} methods:
|
|
114
|
+
* this API is however more verbose and can more easily be used to unsafe typing.
|
|
115
|
+
*/
|
|
116
|
+
custom<T extends Partial<CustomTypes>>(): CustomizedSchemaTyping<
|
|
117
|
+
TSchema,
|
|
118
|
+
Pick<CustomTypes, "readWrite" | "output"> & {
|
|
119
|
+
// Check if property is provided. This check is needed to early out missing values so if undefined is allowed,
|
|
120
|
+
// not providing the field doesn't overwrite the corresponding type with undefined.
|
|
121
|
+
// TODO: test this case
|
|
122
|
+
[Property in keyof CustomTypes]: Property extends keyof T
|
|
123
|
+
? T[Property] extends CustomTypes[Property]
|
|
124
|
+
? T[Property]
|
|
125
|
+
: GetTypesUnsafe<TSchema>[Property]
|
|
126
|
+
: GetTypesUnsafe<TSchema>[Property];
|
|
127
|
+
}
|
|
128
|
+
>;
|
|
129
|
+
}
|
|
130
|
+
|
|
51
131
|
/**
|
|
52
132
|
* {@link Unenforced} version of `ObjectFromSchemaRecord`.
|
|
53
133
|
* @remarks
|
|
54
|
-
* Do
|
|
134
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
55
135
|
* @system @public
|
|
56
136
|
*/
|
|
57
137
|
export type ObjectFromSchemaRecordUnsafe<
|
|
58
138
|
T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>,
|
|
59
|
-
> =
|
|
60
|
-
|
|
61
|
-
|
|
139
|
+
> =
|
|
140
|
+
// Due to https://github.com/microsoft/TypeScript/issues/43826 we can not set the desired setter type.
|
|
141
|
+
// Attempts to implement this in the cleaner way ObjectFromSchemaRecord uses cause recursive types to fail to compile.
|
|
142
|
+
// Supporting explicit field schema wrapping CustomizedSchemaTyping here breaks compilation of recursive cases as well.
|
|
143
|
+
{
|
|
144
|
+
-readonly [Property in keyof T as [T[Property]] extends [
|
|
145
|
+
CustomizedSchemaTyping<
|
|
146
|
+
unknown,
|
|
147
|
+
{
|
|
148
|
+
readonly readWrite: never;
|
|
149
|
+
readonly input: unknown;
|
|
150
|
+
readonly output: TreeNode | TreeLeafValue;
|
|
151
|
+
}
|
|
152
|
+
>,
|
|
153
|
+
]
|
|
154
|
+
? never // Remove readWrite version for cases using CustomizedSchemaTyping to set readWrite to never.
|
|
155
|
+
: Property]: AssignableTreeFieldFromImplicitFieldUnsafe<T[Property]>;
|
|
156
|
+
} & {
|
|
157
|
+
readonly [Property in keyof T as [T[Property]] extends [
|
|
158
|
+
CustomizedSchemaTyping<
|
|
159
|
+
unknown,
|
|
160
|
+
{
|
|
161
|
+
readonly readWrite: never;
|
|
162
|
+
readonly input: unknown;
|
|
163
|
+
readonly output: TreeNode | TreeLeafValue;
|
|
164
|
+
}
|
|
165
|
+
>,
|
|
166
|
+
]
|
|
167
|
+
? // Inverse of the conditional above: only include readonly fields when not including the readWrite one. This is required to make recursive types compile.
|
|
168
|
+
Property
|
|
169
|
+
: never]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* {@link Unenforced} version of `AssignableTreeFieldFromImplicitField`.
|
|
174
|
+
* @remarks
|
|
175
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
176
|
+
* @privateRemarks
|
|
177
|
+
* Recursive version doesn't remove setters when this is never, so this uses covariant not contravariant union handling.
|
|
178
|
+
* @system @public
|
|
179
|
+
*/
|
|
180
|
+
export type AssignableTreeFieldFromImplicitFieldUnsafe<
|
|
181
|
+
TSchema extends Unenforced<ImplicitFieldSchema>,
|
|
182
|
+
> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types>
|
|
183
|
+
? ApplyKindAssignment<GetTypesUnsafe<Types>["readWrite"], Kind>
|
|
184
|
+
: GetTypesUnsafe<TSchema>["readWrite"];
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* {@link Unenforced} version of `TypesUnsafe`.
|
|
188
|
+
* @remarks
|
|
189
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
190
|
+
* @system @public
|
|
191
|
+
*/
|
|
192
|
+
export type GetTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = [
|
|
193
|
+
TSchema,
|
|
194
|
+
] extends [CustomizedSchemaTyping<unknown, infer TCustom>]
|
|
195
|
+
? TCustom
|
|
196
|
+
: StrictTypesUnsafe<TSchema>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* {@link Unenforced} version of `StrictTypes`.
|
|
200
|
+
* @remarks
|
|
201
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
202
|
+
* @system @public
|
|
203
|
+
*/
|
|
204
|
+
export interface StrictTypesUnsafe<
|
|
205
|
+
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
206
|
+
TInput = DefaultInsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>,
|
|
207
|
+
TOutput = DefaultTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>,
|
|
208
|
+
> {
|
|
209
|
+
input: TInput;
|
|
210
|
+
// Partial mitigation setter limitations (removal of setters when TInput is never by setting this to never) breaks compilation if used here,
|
|
211
|
+
// so recursive objects end up allowing some unsafe assignments which will error at runtime.
|
|
212
|
+
// This unsafety occurs when schema types are not exact, so output types are generalized which results in setters being generalized (wince they get the same type) which is unsafe.
|
|
213
|
+
readWrite: TOutput; // TInput extends never ? never : TOutput;
|
|
214
|
+
output: TOutput;
|
|
215
|
+
}
|
|
62
216
|
|
|
63
217
|
/**
|
|
64
218
|
* {@link Unenforced} version of {@link TreeNodeSchema}.
|
|
@@ -121,7 +275,7 @@ export interface TreeNodeSchemaNonClassUnsafe<
|
|
|
121
275
|
/**
|
|
122
276
|
* {@link Unenforced} version of {@link TreeObjectNode}.
|
|
123
277
|
* @remarks
|
|
124
|
-
* Do
|
|
278
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
125
279
|
* @system @public
|
|
126
280
|
*/
|
|
127
281
|
export type TreeObjectNodeUnsafe<
|
|
@@ -132,7 +286,7 @@ export type TreeObjectNodeUnsafe<
|
|
|
132
286
|
/**
|
|
133
287
|
* {@link Unenforced} version of {@link TreeFieldFromImplicitField}.
|
|
134
288
|
* @remarks
|
|
135
|
-
* Do
|
|
289
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
136
290
|
* @system @public
|
|
137
291
|
*/
|
|
138
292
|
export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> =
|
|
@@ -153,11 +307,21 @@ export type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
|
|
153
307
|
/**
|
|
154
308
|
* {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.
|
|
155
309
|
* @remarks
|
|
156
|
-
* Do
|
|
310
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
157
311
|
* @system @public
|
|
158
312
|
*/
|
|
159
313
|
export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
160
314
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
315
|
+
> = GetTypesUnsafe<TSchema>["output"];
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* {@link Unenforced} version of {@link DefaultTreeNodeFromImplicitAllowedTypesUnsafe}.
|
|
319
|
+
* @remarks
|
|
320
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
321
|
+
* @system @public
|
|
322
|
+
*/
|
|
323
|
+
export type DefaultTreeNodeFromImplicitAllowedTypesUnsafe<
|
|
324
|
+
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
161
325
|
> = TSchema extends TreeNodeSchemaUnsafe
|
|
162
326
|
? NodeFromSchemaUnsafe<TSchema>
|
|
163
327
|
: TSchema extends AllowedTypesUnsafe
|
|
@@ -168,11 +332,22 @@ export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
|
168
332
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
169
333
|
* @see {@link Input}
|
|
170
334
|
* @remarks
|
|
171
|
-
* Do
|
|
335
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
172
336
|
* @system @public
|
|
173
337
|
*/
|
|
174
338
|
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<
|
|
175
339
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
340
|
+
> = GetTypesUnsafe<TSchema>["input"];
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* {@link Unenforced} version of {@link DefaultInsertableTreeNodeFromImplicitAllowedTypes}.
|
|
344
|
+
* @see {@link Input}
|
|
345
|
+
* @remarks
|
|
346
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
347
|
+
* @system @public
|
|
348
|
+
*/
|
|
349
|
+
export type DefaultInsertableTreeNodeFromImplicitAllowedTypesUnsafe<
|
|
350
|
+
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
176
351
|
> = [TSchema] extends [TreeNodeSchemaUnsafe]
|
|
177
352
|
? InsertableTypedNodeUnsafe<TSchema>
|
|
178
353
|
: [TSchema] extends [AllowedTypesUnsafe]
|
|
@@ -197,7 +372,7 @@ export type InsertableTreeNodeFromAllowedTypesUnsafe<
|
|
|
197
372
|
* {@link Unenforced} version of {@link InsertableTypedNode}.
|
|
198
373
|
* @see {@link Input}
|
|
199
374
|
* @remarks
|
|
200
|
-
* Do
|
|
375
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
201
376
|
* @privateRemarks
|
|
202
377
|
* TODO:
|
|
203
378
|
* This is less strict than InsertableTypedNode when given non-exact schema to avoid compilation issues.
|
|
@@ -216,7 +391,7 @@ export type InsertableTypedNodeUnsafe<
|
|
|
216
391
|
/**
|
|
217
392
|
* {@link Unenforced} version of {@link NodeFromSchema}.
|
|
218
393
|
* @remarks
|
|
219
|
-
* Do
|
|
394
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
220
395
|
* @system @public
|
|
221
396
|
*/
|
|
222
397
|
export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
@@ -225,7 +400,7 @@ export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
225
400
|
/**
|
|
226
401
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
227
402
|
* @remarks
|
|
228
|
-
* Do
|
|
403
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
229
404
|
* @system @public
|
|
230
405
|
*/
|
|
231
406
|
export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
@@ -234,7 +409,7 @@ export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
234
409
|
/**
|
|
235
410
|
* {@link Unenforced} version of {@link (TreeArrayNode:interface)}.
|
|
236
411
|
* @remarks
|
|
237
|
-
* Do
|
|
412
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
238
413
|
* @system @sealed @public
|
|
239
414
|
*/
|
|
240
415
|
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>>
|
|
@@ -247,7 +422,7 @@ export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAl
|
|
|
247
422
|
/**
|
|
248
423
|
* {@link Unenforced} version of {@link TreeMapNode}.
|
|
249
424
|
* @remarks
|
|
250
|
-
* Do
|
|
425
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
251
426
|
* @system @sealed @public
|
|
252
427
|
*/
|
|
253
428
|
export interface TreeMapNodeUnsafe<T extends Unenforced<ImplicitAllowedTypes>>
|
|
@@ -271,7 +446,7 @@ export interface TreeMapNodeUnsafe<T extends Unenforced<ImplicitAllowedTypes>>
|
|
|
271
446
|
* Copy of TypeScript's ReadonlyMap, but with `TreeNodeFromImplicitAllowedTypesUnsafe<T>` inlined into it.
|
|
272
447
|
* Using this instead of ReadonlyMap in TreeMapNodeUnsafe is necessary to make recursive map schema not generate compile errors in the d.ts files when exported.
|
|
273
448
|
* @remarks
|
|
274
|
-
* Do
|
|
449
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
275
450
|
* @privateRemarks
|
|
276
451
|
* This is the same as `ReadonlyMap<K, TreeNodeFromImplicitAllowedTypesUnsafe<T>>` (Checked in test),
|
|
277
452
|
* except that it avoids the above mentioned compile error.
|
|
@@ -313,7 +488,7 @@ export interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes
|
|
|
313
488
|
/**
|
|
314
489
|
* {@link Unenforced} version of `FieldHasDefault`.
|
|
315
490
|
* @remarks
|
|
316
|
-
* Do
|
|
491
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
317
492
|
* @system @sealed @public
|
|
318
493
|
*/
|
|
319
494
|
export type FieldHasDefaultUnsafe<T extends Unenforced<ImplicitFieldSchema>> =
|
|
@@ -328,7 +503,7 @@ export type FieldHasDefaultUnsafe<T extends Unenforced<ImplicitFieldSchema>> =
|
|
|
328
503
|
* {@link Unenforced} version of `InsertableObjectFromSchemaRecord`.
|
|
329
504
|
* @see {@link Input}
|
|
330
505
|
* @remarks
|
|
331
|
-
* Do
|
|
506
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
332
507
|
* @system @public
|
|
333
508
|
*/
|
|
334
509
|
export type InsertableObjectFromSchemaRecordUnsafe<
|
|
@@ -350,7 +525,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<
|
|
|
350
525
|
* {@link Unenforced} version of {@link InsertableTreeFieldFromImplicitField}.
|
|
351
526
|
* @see {@link Input}
|
|
352
527
|
* @remarks
|
|
353
|
-
* Do
|
|
528
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
354
529
|
* @system @public
|
|
355
530
|
*/
|
|
356
531
|
export type InsertableTreeFieldFromImplicitFieldUnsafe<
|
|
@@ -365,7 +540,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<
|
|
|
365
540
|
/**
|
|
366
541
|
* {@link Unenforced} version of {@link FieldSchema}.
|
|
367
542
|
* @remarks
|
|
368
|
-
* Do
|
|
543
|
+
* Do not use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
369
544
|
* @public
|
|
370
545
|
*/
|
|
371
546
|
export interface FieldSchemaUnsafe<
|
|
@@ -172,7 +172,8 @@ export function applySchemaToParserOptions<TCustom>(
|
|
|
172
172
|
: {
|
|
173
173
|
encode: (type, key: FieldKey): string => {
|
|
174
174
|
// translate stored key into property key.
|
|
175
|
-
const simpleNodeSchema =
|
|
175
|
+
const simpleNodeSchema =
|
|
176
|
+
context.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);
|
|
176
177
|
if (isObjectNodeSchema(simpleNodeSchema)) {
|
|
177
178
|
const propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);
|
|
178
179
|
if (propertyKey !== undefined) {
|
|
@@ -193,10 +194,12 @@ export function applySchemaToParserOptions<TCustom>(
|
|
|
193
194
|
return key;
|
|
194
195
|
},
|
|
195
196
|
parse: (type, inputKey): FieldKey => {
|
|
196
|
-
const simpleNodeSchema =
|
|
197
|
+
const simpleNodeSchema =
|
|
198
|
+
context.schema.get(brand(type)) ?? fail(0xb3a /* missing schema */);
|
|
197
199
|
if (isObjectNodeSchema(simpleNodeSchema)) {
|
|
198
200
|
const info =
|
|
199
|
-
simpleNodeSchema.flexKeyMap.get(inputKey) ??
|
|
201
|
+
simpleNodeSchema.flexKeyMap.get(inputKey) ??
|
|
202
|
+
fail(0xb3b /* missing field info */);
|
|
200
203
|
return info.storedKey;
|
|
201
204
|
}
|
|
202
205
|
return brand(inputKey);
|
|
@@ -345,7 +348,8 @@ function verboseFromCursorInner<TCustom>(
|
|
|
345
348
|
schema: ReadonlyMap<string, TreeNodeSchema>,
|
|
346
349
|
): VerboseTree<TCustom> {
|
|
347
350
|
const fields = customFromCursor(reader, options, schema, verboseFromCursorInner);
|
|
348
|
-
const nodeSchema =
|
|
351
|
+
const nodeSchema =
|
|
352
|
+
schema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);
|
|
349
353
|
if (nodeSchema.kind === NodeKind.Leaf) {
|
|
350
354
|
return fields as CustomTreeValue<TCustom>;
|
|
351
355
|
}
|
|
@@ -250,7 +250,7 @@ export class ViewSchema {
|
|
|
250
250
|
this.viewSchemaAsStored.nodeSchema.get(adapter.output),
|
|
251
251
|
)
|
|
252
252
|
) {
|
|
253
|
-
fail(
|
|
253
|
+
fail(0xb3d /* tree adapter for stored adapter.output should not be never */);
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -858,7 +858,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
858
858
|
// Therefore it must include `length`,
|
|
859
859
|
// even though this "length" is never invoked (due to being shadowed by the proxy provided own property).
|
|
860
860
|
public get length(): number {
|
|
861
|
-
return fail(
|
|
861
|
+
return fail(0xadb /* Proxy should intercept length */);
|
|
862
862
|
}
|
|
863
863
|
|
|
864
864
|
public [Symbol.iterator](): IterableIterator<TreeNodeFromImplicitAllowedTypes<T>> {
|
|
@@ -1045,7 +1045,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
1045
1045
|
throw new UsageError(`Concurrent editing and iteration is not allowed.`);
|
|
1046
1046
|
}
|
|
1047
1047
|
for (let i = 0; i < this.length; i++) {
|
|
1048
|
-
yield this.at(i) ?? fail(
|
|
1048
|
+
yield this.at(i) ?? fail(0xadc /* Index is out of bounds */);
|
|
1049
1049
|
if (initialLastUpdatedStamp !== kernel.generationNumber) {
|
|
1050
1050
|
throw new UsageError(`Concurrent editing and iteration is not allowed.`);
|
|
1051
1051
|
}
|
|
@@ -31,7 +31,8 @@ export function getOrCreateNodeFromInnerNode(flexNode: InnerNode): TreeNode | Tr
|
|
|
31
31
|
return cached;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const classSchema =
|
|
34
|
+
const classSchema =
|
|
35
|
+
getSimpleNodeSchemaFromInnerNode(flexNode) ?? fail(0xb3e /* Missing schema */);
|
|
35
36
|
const node = flexNode as unknown as InternalTreeNode;
|
|
36
37
|
// eslint-disable-next-line unicorn/prefer-ternary
|
|
37
38
|
if (typeof classSchema === "function") {
|
|
@@ -17,7 +17,7 @@ import { SimpleContextSlot, type Context } from "./context.js";
|
|
|
17
17
|
*/
|
|
18
18
|
export function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {
|
|
19
19
|
const context: Context = getSimpleContextFromInnerNode(innerNode);
|
|
20
|
-
return context.schema.get(innerNode.schema) ?? fail(
|
|
20
|
+
return context.schema.get(innerNode.schema) ?? fail(0xb3f /* missing schema from context */);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -184,7 +184,7 @@ export class TreeNodeKernel {
|
|
|
184
184
|
// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.
|
|
185
185
|
return (
|
|
186
186
|
this.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??
|
|
187
|
-
fail(
|
|
187
|
+
fail(0xb40 /* missing simple-tree context */)
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
return this.initialContext;
|
|
@@ -303,7 +303,8 @@ export class TreeNodeKernel {
|
|
|
303
303
|
this.#hydrationState.innerNode = flexNode;
|
|
304
304
|
} else {
|
|
305
305
|
// ...otherwise, the flex node must be created
|
|
306
|
-
const context =
|
|
306
|
+
const context =
|
|
307
|
+
anchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);
|
|
307
308
|
const cursor = context.checkout.forest.allocateCursor("getFlexNode");
|
|
308
309
|
context.checkout.forest.moveCursorToPath(anchorNode, cursor);
|
|
309
310
|
this.#hydrationState.innerNode = makeTree(context, cursor);
|
|
@@ -332,7 +333,8 @@ export class TreeNodeKernel {
|
|
|
332
333
|
public anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {
|
|
333
334
|
assert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);
|
|
334
335
|
const anchor = anchors.track(path);
|
|
335
|
-
const anchorNode =
|
|
336
|
+
const anchorNode =
|
|
337
|
+
anchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);
|
|
336
338
|
this.hydrate(anchorNode);
|
|
337
339
|
const forget = (): void => {
|
|
338
340
|
if (anchors.locate(anchor)) {
|
|
@@ -434,9 +436,9 @@ export function getTreeNodeSchemaFromHydratedFlexNode(flexNode: FlexTreeNode): T
|
|
|
434
436
|
|
|
435
437
|
const context =
|
|
436
438
|
flexNode.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??
|
|
437
|
-
fail(
|
|
439
|
+
fail(0xb43 /* Missing SimpleContextSlot */);
|
|
438
440
|
|
|
439
|
-
return context.schema.get(flexNode.schema) ?? fail(
|
|
441
|
+
return context.schema.get(flexNode.schema) ?? fail(0xb44 /* Missing schema */);
|
|
440
442
|
}
|
|
441
443
|
|
|
442
444
|
/**
|
|
@@ -461,7 +463,8 @@ function flexNodeFromAnchor(anchorNode: AnchorNode): FlexTreeNode {
|
|
|
461
463
|
if (flexNode !== undefined) {
|
|
462
464
|
return flexNode; // If it does have a flex node, return it...
|
|
463
465
|
} // ...otherwise, the flex node must be created
|
|
464
|
-
const context =
|
|
466
|
+
const context =
|
|
467
|
+
anchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);
|
|
465
468
|
const cursor = context.checkout.forest.allocateCursor("getFlexNode");
|
|
466
469
|
context.checkout.forest.moveCursorToPath(anchorNode, cursor);
|
|
467
470
|
const newFlexNode = makeTree(context, cursor);
|
|
@@ -79,7 +79,9 @@ export class UnhydratedFlexTreeNode implements UnhydratedFlexTreeNode {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
public get storedSchema(): TreeNodeStoredSchema {
|
|
82
|
-
return
|
|
82
|
+
return (
|
|
83
|
+
this.context.schema.nodeSchema.get(this.mapTree.type) ?? fail(0xb46 /* missing schema */)
|
|
84
|
+
);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
public readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;
|
|
@@ -215,7 +217,7 @@ export class UnhydratedFlexTreeNode implements UnhydratedFlexTreeNode {
|
|
|
215
217
|
public get anchorNode(): AnchorNode {
|
|
216
218
|
// This API is relevant to `LazyTreeNode`s, but not `UnhydratedFlexTreeNode`s.
|
|
217
219
|
// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.
|
|
218
|
-
return fail(
|
|
220
|
+
return fail(0xb47 /* UnhydratedFlexTreeNode does not implement anchorNode */);
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
private walkTree(): void {
|
|
@@ -294,10 +296,10 @@ const unparentedLocation: LocationInField = {
|
|
|
294
296
|
},
|
|
295
297
|
schema: brand(forbiddenFieldKindIdentifier),
|
|
296
298
|
get context(): never {
|
|
297
|
-
return fail(
|
|
299
|
+
return fail(0xb48 /* unsupported */);
|
|
298
300
|
},
|
|
299
301
|
getFieldPath() {
|
|
300
|
-
fail(
|
|
302
|
+
fail(0xb49 /* unsupported */);
|
|
301
303
|
},
|
|
302
304
|
},
|
|
303
305
|
index: -1,
|
|
@@ -489,7 +491,7 @@ export class UnhydratedTreeSequenceField
|
|
|
489
491
|
this.edit((mapTrees) => {
|
|
490
492
|
removed = mapTrees.splice(index, count);
|
|
491
493
|
});
|
|
492
|
-
return removed ?? fail(
|
|
494
|
+
return removed ?? fail(0xb4a /* Expected removed to be set by edit */);
|
|
493
495
|
},
|
|
494
496
|
};
|
|
495
497
|
|
|
@@ -44,28 +44,18 @@ export function markEager<T>(t: T): T {
|
|
|
44
44
|
* By default, items that are of type `"function"` will be considered lazy and all other items will be considered eager.
|
|
45
45
|
* To force a `"function"` item to be treated as an eager item, call `markEager` before putting it in the list.
|
|
46
46
|
* This is necessary e.g. when the eager list items are function types and the lazy items are functions that _return_ function types.
|
|
47
|
-
*
|
|
47
|
+
* Our one use of FlexList has some special normalization logic, see {@link normalizeAllowedTypes}.
|
|
48
48
|
* @system @public
|
|
49
49
|
*/
|
|
50
50
|
export type FlexList<Item = unknown> = readonly LazyItem<Item>[];
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Given a `FlexList` of eager and lazy items, return an equivalent list where all items are eager.
|
|
54
|
-
*/
|
|
55
|
-
export function normalizeFlexListEager<T>(t: FlexList<T>): T[] {
|
|
56
|
-
const data: T[] = t.map((value: LazyItem<T>) => {
|
|
57
|
-
if (isLazy(value)) {
|
|
58
|
-
return value();
|
|
59
|
-
}
|
|
60
|
-
return value;
|
|
61
|
-
});
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
52
|
/**
|
|
66
53
|
* An "eager" or "lazy" Item in a `FlexList`.
|
|
67
54
|
* Lazy items are wrapped in a function to allow referring to themselves before they are declared.
|
|
68
55
|
* This makes recursive and co-recursive items possible.
|
|
56
|
+
* @privateRemarks
|
|
57
|
+
* `schemaTypes.ts`'s `evaluateLazySchema` (via {@link normalizeAllowedTypes})
|
|
58
|
+
* applies caching for the only current use of this type.
|
|
69
59
|
* @public
|
|
70
60
|
*/
|
|
71
61
|
export type LazyItem<Item = unknown> = Item | (() => Item);
|