@fluidframework/tree 2.3.1 → 2.4.0-297027
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-report/tree.alpha.api.md +77 -38
- package/api-report/tree.beta.api.md +50 -30
- package/api-report/tree.legacy.alpha.api.md +50 -30
- package/api-report/tree.legacy.public.api.md +50 -30
- package/api-report/tree.public.api.md +50 -30
- package/dist/alpha.d.ts +7 -0
- package/dist/beta.d.ts +4 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +1 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +8 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +7 -0
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +9 -0
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +1 -2
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +2 -2
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +13 -2
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.d.ts +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.d.ts +3 -230
- package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.js +1 -539
- package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +7 -14
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +3 -3
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +1 -2
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +10 -15
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +18 -20
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +13 -23
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +4 -7
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +5 -31
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +7 -0
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +61 -17
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +3 -0
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV1.d.ts +18 -18
- package/dist/feature-libraries/sequence-field/formatV2.d.ts +18 -18
- package/dist/feature-libraries/sequence-field/formatV3.d.ts +27 -27
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +1 -4
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/typed-schema/flexList.d.ts +1 -46
- package/dist/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/flexList.js +1 -13
- package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
- package/dist/feature-libraries/typed-schema/index.d.ts +2 -4
- package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/index.js +1 -19
- package/dist/feature-libraries/typed-schema/index.js.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -266
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +1 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +4 -0
- package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +3 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -3
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +1 -40
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +2 -11
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +9 -7
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +19 -8
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +19 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +10 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +71 -41
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +116 -84
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +8 -11
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +12 -15
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +1 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +11 -13
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts +3 -3
- package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.js +1 -1
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.d.ts +2 -2
- package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.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/jsonSchema.d.ts +13 -14
- package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/jsonSchema.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +14 -8
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +21 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/simpleSchema.d.ts +18 -10
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +30 -17
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +16 -6
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +4 -4
- 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 +8 -6
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +6 -10
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/{lib/feature-libraries/typed-schema → dist/simple-tree/api}/view.d.ts +4 -11
- package/dist/simple-tree/api/view.d.ts.map +1 -0
- package/dist/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
- package/dist/simple-tree/api/view.js.map +1 -0
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +147 -14
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +32 -20
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/context.d.ts +55 -0
- package/dist/simple-tree/core/context.d.ts.map +1 -0
- package/dist/simple-tree/core/context.js +60 -0
- package/dist/simple-tree/core/context.js.map +1 -0
- package/dist/simple-tree/core/getOrCreateNode.d.ts +15 -0
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
- package/dist/simple-tree/core/getOrCreateNode.js +36 -0
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -0
- package/dist/simple-tree/core/index.d.ts +7 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +16 -7
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/schemaCaching.d.ts +5 -13
- package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
- package/dist/simple-tree/core/schemaCaching.js +16 -45
- package/dist/simple-tree/core/schemaCaching.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +29 -7
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +94 -58
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +24 -0
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +0 -5
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
- package/dist/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +112 -132
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -0
- package/dist/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -0
- package/dist/simple-tree/core/walkSchema.js +34 -0
- package/dist/simple-tree/core/walkSchema.js.map +1 -0
- package/dist/simple-tree/createContext.d.ts +11 -0
- package/dist/simple-tree/createContext.d.ts.map +1 -0
- package/dist/simple-tree/createContext.js +25 -0
- package/dist/simple-tree/createContext.js.map +1 -0
- package/dist/simple-tree/index.d.ts +4 -5
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +7 -7
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +1 -0
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +1 -2
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +4 -4
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +9 -5
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +8 -8
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +33 -14
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +7 -3
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts +1 -2
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +6 -22
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +44 -4
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +10 -0
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +6 -36
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +58 -142
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js +2 -2
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts +13 -5
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +19 -10
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/typesUnsafe.d.ts +4 -4
- package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/walkFieldSchema.d.ts +11 -0
- package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -0
- package/dist/simple-tree/walkFieldSchema.js +17 -0
- package/dist/simple-tree/walkFieldSchema.js.map +1 -0
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeUtils.d.ts +14 -45
- package/dist/util/typeUtils.d.ts.map +1 -1
- package/dist/util/typeUtils.js.map +1 -1
- package/lib/alpha.d.ts +7 -0
- package/lib/beta.d.ts +4 -0
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +1 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +6 -0
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +7 -0
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +9 -0
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +1 -2
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +2 -2
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +13 -2
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.d.ts +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.d.ts +3 -230
- package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.js +1 -532
- package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +7 -14
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +3 -3
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +1 -2
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +10 -15
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +18 -20
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +13 -23
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +4 -7
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +4 -6
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +7 -0
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +62 -18
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +3 -0
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.d.ts +18 -18
- package/lib/feature-libraries/sequence-field/formatV2.d.ts +18 -18
- package/lib/feature-libraries/sequence-field/formatV3.d.ts +27 -27
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +2 -5
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/typed-schema/flexList.d.ts +1 -46
- package/lib/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/flexList.js +0 -11
- package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
- package/lib/feature-libraries/typed-schema/index.d.ts +2 -4
- package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/index.js +0 -3
- package/lib/feature-libraries/typed-schema/index.js.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +1 -253
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +1 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +4 -0
- package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +3 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -2
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +1 -40
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -9
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +9 -7
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +22 -11
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +19 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +10 -3
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +71 -41
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +118 -86
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +8 -11
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +12 -15
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +1 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +14 -16
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts +3 -3
- package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.js +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.d.ts +2 -2
- package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.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/jsonSchema.d.ts +13 -14
- package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/jsonSchema.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +14 -8
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +21 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/simpleSchema.d.ts +18 -10
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +31 -18
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +16 -6
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +4 -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 +10 -8
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +6 -10
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/{dist/feature-libraries/typed-schema → lib/simple-tree/api}/view.d.ts +4 -11
- package/lib/simple-tree/api/view.d.ts.map +1 -0
- package/lib/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
- package/lib/simple-tree/api/view.js.map +1 -0
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +11 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +147 -14
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +37 -25
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/context.d.ts +55 -0
- package/lib/simple-tree/core/context.d.ts.map +1 -0
- package/lib/simple-tree/core/context.js +55 -0
- package/lib/simple-tree/core/context.js.map +1 -0
- package/lib/simple-tree/core/getOrCreateNode.d.ts +15 -0
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
- package/lib/simple-tree/core/getOrCreateNode.js +32 -0
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -0
- package/lib/simple-tree/core/index.d.ts +7 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +6 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/schemaCaching.d.ts +5 -13
- package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
- package/lib/simple-tree/core/schemaCaching.js +13 -39
- package/lib/simple-tree/core/schemaCaching.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +29 -7
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +89 -54
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +24 -0
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +0 -5
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
- package/lib/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +110 -128
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -0
- package/lib/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -0
- package/lib/simple-tree/core/walkSchema.js +29 -0
- package/lib/simple-tree/core/walkSchema.js.map +1 -0
- package/lib/simple-tree/createContext.d.ts +11 -0
- package/lib/simple-tree/createContext.d.ts.map +1 -0
- package/lib/simple-tree/createContext.js +21 -0
- package/lib/simple-tree/createContext.js.map +1 -0
- package/lib/simple-tree/index.d.ts +4 -5
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +3 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +1 -0
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +3 -4
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +4 -4
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +12 -8
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +8 -8
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +36 -17
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +7 -3
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts +1 -2
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +7 -22
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +44 -4
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +10 -0
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +6 -36
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +61 -142
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js +4 -4
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts +13 -5
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +21 -12
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/typesUnsafe.d.ts +4 -4
- package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/walkFieldSchema.d.ts +11 -0
- package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -0
- package/lib/simple-tree/walkFieldSchema.js +13 -0
- package/lib/simple-tree/walkFieldSchema.js.map +1 -0
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeUtils.d.ts +14 -45
- package/lib/util/typeUtils.d.ts.map +1 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +41 -22
- package/src/core/index.ts +1 -0
- package/src/core/rebase/index.ts +1 -0
- package/src/core/rebase/types.ts +11 -0
- package/src/core/schema-stored/schema.ts +18 -0
- package/src/core/tree/anchorSet.ts +3 -4
- package/src/core/tree/detachedFieldIndex.ts +14 -3
- package/src/core/tree/detachedFieldIndexTypes.ts +1 -1
- package/src/feature-libraries/editableTreeBinder.ts +2 -915
- package/src/feature-libraries/flex-tree/context.ts +7 -20
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -18
- package/src/feature-libraries/flex-tree/lazyEntity.ts +1 -4
- package/src/feature-libraries/flex-tree/lazyField.ts +22 -78
- package/src/feature-libraries/flex-tree/lazyNode.ts +24 -39
- package/src/feature-libraries/flex-tree/utilities.ts +1 -1
- package/src/feature-libraries/index.ts +3 -71
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +97 -10
- package/src/feature-libraries/sequence-field/compose.ts +3 -0
- package/src/feature-libraries/sequence-field/utils.ts +2 -4
- package/src/feature-libraries/typed-schema/flexList.ts +3 -84
- package/src/feature-libraries/typed-schema/index.ts +1 -33
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -458
- package/src/index.ts +7 -0
- package/src/internalTypes.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +3 -3
- package/src/shared-tree/index.ts +4 -8
- package/src/shared-tree/schematizeTree.ts +2 -56
- package/src/shared-tree/schematizingTreeView.ts +38 -15
- package/src/shared-tree/sharedTree.ts +36 -8
- package/src/shared-tree/treeCheckout.ts +225 -128
- package/src/shared-tree-core/branch.ts +15 -26
- package/src/simple-tree/api/create.ts +18 -20
- package/src/simple-tree/api/getJsonSchema.ts +3 -3
- package/src/simple-tree/api/getSimpleSchema.ts +2 -2
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/jsonSchema.ts +19 -17
- package/src/simple-tree/api/schemaFactory.ts +53 -18
- package/src/simple-tree/api/schemaFactoryRecursive.ts +3 -6
- package/src/simple-tree/api/simpleSchema.ts +20 -10
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +40 -19
- package/src/simple-tree/api/tree.ts +20 -9
- package/src/simple-tree/api/treeNodeApi.ts +12 -10
- package/src/simple-tree/api/verboseTree.ts +6 -12
- package/src/{feature-libraries/typed-schema → simple-tree/api}/view.ts +9 -22
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +18 -4
- package/src/simple-tree/arrayNode.ts +202 -53
- package/src/simple-tree/core/context.ts +78 -0
- package/src/simple-tree/core/getOrCreateNode.ts +38 -0
- package/src/simple-tree/core/index.ts +11 -7
- package/src/simple-tree/core/schemaCaching.ts +13 -50
- package/src/simple-tree/core/treeNodeKernel.ts +117 -78
- package/src/simple-tree/core/treeNodeSchema.ts +35 -1
- package/src/simple-tree/core/types.ts +0 -5
- package/src/{feature-libraries/flex-map-tree/mapTreeNode.ts → simple-tree/core/unhydratedFlexTree.ts} +167 -210
- package/src/simple-tree/{walkSchema.ts → core/walkSchema.ts} +12 -34
- package/src/simple-tree/createContext.ts +24 -0
- package/src/simple-tree/index.ts +6 -2
- package/src/simple-tree/leafNodeSchema.ts +3 -9
- package/src/simple-tree/mapNode.ts +20 -17
- package/src/simple-tree/objectNode.ts +63 -38
- package/src/simple-tree/objectNodeTypes.ts +8 -5
- package/src/simple-tree/proxies.ts +8 -26
- package/src/simple-tree/schemaTypes.ts +55 -5
- package/src/simple-tree/toFlexSchema.ts +71 -204
- package/src/simple-tree/toMapTree.ts +5 -5
- package/src/simple-tree/treeNodeValid.ts +28 -22
- package/src/simple-tree/typesUnsafe.ts +4 -4
- package/src/simple-tree/walkFieldSchema.ts +19 -0
- package/src/util/index.ts +1 -5
- package/src/util/typeUtils.ts +14 -56
- package/dist/feature-libraries/fieldGenerator.d.ts +0 -43
- package/dist/feature-libraries/fieldGenerator.d.ts.map +0 -1
- package/dist/feature-libraries/fieldGenerator.js +0 -13
- package/dist/feature-libraries/fieldGenerator.js.map +0 -1
- package/dist/feature-libraries/flex-map-tree/index.d.ts +0 -6
- package/dist/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
- package/dist/feature-libraries/flex-map-tree/index.js +0 -14
- package/dist/feature-libraries/flex-map-tree/index.js.map +0 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
- package/dist/feature-libraries/storedToViewSchema.d.ts +0 -17
- package/dist/feature-libraries/storedToViewSchema.d.ts.map +0 -1
- package/dist/feature-libraries/storedToViewSchema.js +0 -67
- package/dist/feature-libraries/storedToViewSchema.js.map +0 -1
- package/dist/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
- package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/schemaCollection.js +0 -160
- package/dist/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
- package/dist/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
- package/dist/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/typeUtils.js +0 -14
- package/dist/feature-libraries/typed-schema/typeUtils.js.map +0 -1
- package/dist/feature-libraries/typed-schema/view.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/view.js.map +0 -1
- package/dist/simple-tree/getSimpleFieldSchema.d.ts +0 -14
- package/dist/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
- package/dist/simple-tree/getSimpleFieldSchema.js +0 -29
- package/dist/simple-tree/getSimpleFieldSchema.js.map +0 -1
- package/dist/simple-tree/walkSchema.d.ts.map +0 -1
- package/dist/simple-tree/walkSchema.js +0 -49
- package/dist/simple-tree/walkSchema.js.map +0 -1
- package/lib/feature-libraries/fieldGenerator.d.ts +0 -43
- package/lib/feature-libraries/fieldGenerator.d.ts.map +0 -1
- package/lib/feature-libraries/fieldGenerator.js +0 -12
- package/lib/feature-libraries/fieldGenerator.js.map +0 -1
- package/lib/feature-libraries/flex-map-tree/index.d.ts +0 -6
- package/lib/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
- package/lib/feature-libraries/flex-map-tree/index.js +0 -6
- package/lib/feature-libraries/flex-map-tree/index.js.map +0 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
- package/lib/feature-libraries/storedToViewSchema.d.ts +0 -17
- package/lib/feature-libraries/storedToViewSchema.d.ts.map +0 -1
- package/lib/feature-libraries/storedToViewSchema.js +0 -62
- package/lib/feature-libraries/storedToViewSchema.js.map +0 -1
- package/lib/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
- package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/schemaCollection.js +0 -153
- package/lib/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
- package/lib/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
- package/lib/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/typeUtils.js +0 -10
- package/lib/feature-libraries/typed-schema/typeUtils.js.map +0 -1
- package/lib/feature-libraries/typed-schema/view.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/view.js.map +0 -1
- package/lib/simple-tree/getSimpleFieldSchema.d.ts +0 -14
- package/lib/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
- package/lib/simple-tree/getSimpleFieldSchema.js +0 -25
- package/lib/simple-tree/getSimpleFieldSchema.js.map +0 -1
- package/lib/simple-tree/walkSchema.d.ts.map +0 -1
- package/lib/simple-tree/walkSchema.js +0 -43
- package/lib/simple-tree/walkSchema.js.map +0 -1
- package/src/feature-libraries/fieldGenerator.ts +0 -47
- package/src/feature-libraries/flex-map-tree/index.ts +0 -14
- package/src/feature-libraries/storedToViewSchema.ts +0 -100
- package/src/feature-libraries/typed-schema/schemaCollection.ts +0 -254
- package/src/feature-libraries/typed-schema/typeUtils.ts +0 -29
- package/src/simple-tree/getSimpleFieldSchema.ts +0 -36
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { type TreeNodeSchema, NodeKind } from "./core/index.js";
|
|
8
|
-
import { LeafNodeSchema } from "./leafNodeSchema.js";
|
|
9
|
-
import { isObjectNodeSchema } from "./objectNodeTypes.js";
|
|
10
|
-
import {
|
|
11
|
-
type ImplicitAllowedTypes,
|
|
12
|
-
normalizeAllowedTypes,
|
|
13
|
-
type ImplicitFieldSchema,
|
|
14
|
-
normalizeFieldSchema,
|
|
15
|
-
} from "./schemaTypes.js";
|
|
6
|
+
import type { TreeNodeSchema } from "./treeNodeSchema.js";
|
|
16
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
|
|
10
|
+
*/
|
|
17
11
|
export function walkNodeSchema(
|
|
18
12
|
schema: TreeNodeSchema,
|
|
19
13
|
visitor: SchemaVisitor,
|
|
@@ -23,20 +17,9 @@ export function walkNodeSchema(
|
|
|
23
17
|
return;
|
|
24
18
|
}
|
|
25
19
|
visitedSet.add(schema);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (const field of schema.fields.values()) {
|
|
30
|
-
walkFieldSchema(field, visitor, visitedSet);
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
assert(
|
|
34
|
-
schema.kind === NodeKind.Array || schema.kind === NodeKind.Map,
|
|
35
|
-
0x9b3 /* invalid schema */,
|
|
36
|
-
);
|
|
37
|
-
const childTypes = schema.info as ImplicitAllowedTypes;
|
|
38
|
-
walkAllowedTypes(normalizeAllowedTypes(childTypes), visitor, visitedSet);
|
|
39
|
-
}
|
|
20
|
+
|
|
21
|
+
walkAllowedTypes(schema.childTypes, visitor, visitedSet);
|
|
22
|
+
|
|
40
23
|
// This visit is done at the end so the traversal order is most inner types first.
|
|
41
24
|
// This was picked since when fixing errors,
|
|
42
25
|
// working from the inner types out to the types that use them will probably go better than the reverse.
|
|
@@ -44,28 +27,23 @@ export function walkNodeSchema(
|
|
|
44
27
|
visitor.node?.(schema);
|
|
45
28
|
}
|
|
46
29
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
visitedSet: Set<TreeNodeSchema> = new Set(),
|
|
51
|
-
): void {
|
|
52
|
-
walkAllowedTypes(normalizeFieldSchema(schema).allowedTypeSet, visitor, visitedSet);
|
|
53
|
-
}
|
|
54
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.
|
|
32
|
+
*/
|
|
55
33
|
export function walkAllowedTypes(
|
|
56
34
|
allowedTypes: Iterable<TreeNodeSchema>,
|
|
57
35
|
visitor: SchemaVisitor,
|
|
58
|
-
visitedSet: Set<TreeNodeSchema
|
|
36
|
+
visitedSet: Set<TreeNodeSchema> = new Set(),
|
|
59
37
|
): void {
|
|
60
38
|
for (const childType of allowedTypes) {
|
|
61
39
|
walkNodeSchema(childType, visitor, visitedSet);
|
|
62
40
|
}
|
|
63
41
|
visitor.allowedTypes?.(allowedTypes);
|
|
64
42
|
}
|
|
43
|
+
|
|
65
44
|
/**
|
|
66
45
|
* Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.
|
|
67
46
|
*/
|
|
68
|
-
|
|
69
47
|
export interface SchemaVisitor {
|
|
70
48
|
/**
|
|
71
49
|
* Called once for each node schema.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defaultSchemaPolicy } from "../feature-libraries/index.js";
|
|
7
|
+
import { getOrCreate } from "../util/index.js";
|
|
8
|
+
import { Context, UnhydratedContext } from "./core/index.js";
|
|
9
|
+
import { normalizeFieldSchema, type ImplicitFieldSchema } from "./schemaTypes.js";
|
|
10
|
+
import { toStoredSchema } from "./toFlexSchema.js";
|
|
11
|
+
|
|
12
|
+
const contextCache: WeakMap<ImplicitFieldSchema, Context> = new WeakMap();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Utility for creating {@link Context}s for unhydrated nodes.
|
|
16
|
+
*/
|
|
17
|
+
export function getUnhydratedContext(schema: ImplicitFieldSchema): Context {
|
|
18
|
+
return getOrCreate(contextCache, schema, (s) => {
|
|
19
|
+
const normalized = normalizeFieldSchema(schema);
|
|
20
|
+
|
|
21
|
+
const flexContext = new UnhydratedContext(defaultSchemaPolicy, toStoredSchema(schema));
|
|
22
|
+
return new Context(normalized.allowedTypeSet, flexContext);
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -20,10 +20,13 @@ export {
|
|
|
20
20
|
type InternalTreeNode,
|
|
21
21
|
isTreeNode,
|
|
22
22
|
tryDisposeTreeNode,
|
|
23
|
+
HydratedContext,
|
|
24
|
+
SimpleContextSlot,
|
|
23
25
|
} from "./core/index.js";
|
|
24
26
|
export {
|
|
25
27
|
type ITree,
|
|
26
28
|
type TreeView,
|
|
29
|
+
type ViewableTree,
|
|
27
30
|
type TreeViewEvents,
|
|
28
31
|
TreeViewConfiguration,
|
|
29
32
|
type ITreeViewConfiguration,
|
|
@@ -64,6 +67,7 @@ export {
|
|
|
64
67
|
type JsonLeafSchemaType,
|
|
65
68
|
getJsonSchema,
|
|
66
69
|
getSimpleSchema,
|
|
70
|
+
ViewSchema,
|
|
67
71
|
} from "./api/index.js";
|
|
68
72
|
export {
|
|
69
73
|
type NodeFromSchema,
|
|
@@ -84,9 +88,9 @@ export {
|
|
|
84
88
|
type FieldProps,
|
|
85
89
|
normalizeFieldSchema,
|
|
86
90
|
type ApplyKind,
|
|
91
|
+
type FieldSchemaMetadata,
|
|
87
92
|
} from "./schemaTypes.js";
|
|
88
93
|
export { getOrCreateInnerNode } from "./proxyBinding.js";
|
|
89
|
-
export { toFlexSchema } from "./toFlexSchema.js";
|
|
90
94
|
export type {
|
|
91
95
|
FieldHasDefaultUnsafe,
|
|
92
96
|
ObjectFromSchemaRecordUnsafe,
|
|
@@ -123,7 +127,7 @@ export {
|
|
|
123
127
|
} from "./objectNode.js";
|
|
124
128
|
export type { TreeMapNode, MapNodeInsertableData } from "./mapNode.js";
|
|
125
129
|
export { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js";
|
|
126
|
-
export { toStoredSchema, getStoredSchema
|
|
130
|
+
export { toStoredSchema, getStoredSchema } from "./toFlexSchema.js";
|
|
127
131
|
export {
|
|
128
132
|
numberSchema,
|
|
129
133
|
stringSchema,
|
|
@@ -7,17 +7,11 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
|
|
8
8
|
import { type TreeValue, ValueSchema } from "../core/index.js";
|
|
9
9
|
import {
|
|
10
|
-
LeafNodeSchema as FlexLeafNodeSchema,
|
|
11
10
|
type FlexTreeNode,
|
|
12
11
|
isFlexTreeNode,
|
|
13
12
|
valueSchemaAllows,
|
|
14
13
|
} from "../feature-libraries/index.js";
|
|
15
|
-
import {
|
|
16
|
-
setFlexSchemaFromClassSchema,
|
|
17
|
-
NodeKind,
|
|
18
|
-
type TreeNodeSchema,
|
|
19
|
-
type TreeNodeSchemaNonClass,
|
|
20
|
-
} from "./core/index.js";
|
|
14
|
+
import { NodeKind, type TreeNodeSchema, type TreeNodeSchemaNonClass } from "./core/index.js";
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* Instances of this class are schema for leaf nodes.
|
|
@@ -35,6 +29,8 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
35
29
|
public readonly kind = NodeKind.Leaf;
|
|
36
30
|
public readonly info: T;
|
|
37
31
|
public readonly implicitlyConstructable = true as const;
|
|
32
|
+
public readonly childTypes: ReadonlySet<TreeNodeSchema> = new Set();
|
|
33
|
+
|
|
38
34
|
public create(data: TreeValue<T> | FlexTreeNode): TreeValue<T> {
|
|
39
35
|
if (isFlexTreeNode(data)) {
|
|
40
36
|
const value = data.value;
|
|
@@ -45,8 +41,6 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
public constructor(name: Name, t: T) {
|
|
48
|
-
const schema: FlexLeafNodeSchema = new FlexLeafNodeSchema({ name: "makeLeaf" }, name, t);
|
|
49
|
-
setFlexSchemaFromClassSchema(this, schema);
|
|
50
44
|
this.identifier = name;
|
|
51
45
|
this.info = t;
|
|
52
46
|
}
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
6
7
|
import {
|
|
7
|
-
type FlexMapNodeSchema,
|
|
8
8
|
type FlexTreeNode,
|
|
9
9
|
type FlexTreeOptionalField,
|
|
10
|
-
type MapTreeNode,
|
|
11
10
|
type OptionalFieldEditBuilder,
|
|
12
|
-
UnhydratedContext,
|
|
13
|
-
getOrCreateMapTreeNode,
|
|
14
11
|
getSchemaAndPolicy,
|
|
15
12
|
} from "../feature-libraries/index.js";
|
|
16
13
|
import { getTreeNodeForField, prepareContentForHydration } from "./proxies.js";
|
|
@@ -18,6 +15,7 @@ import { getOrCreateInnerNode } from "./proxyBinding.js";
|
|
|
18
15
|
import {
|
|
19
16
|
createFieldSchema,
|
|
20
17
|
FieldKind,
|
|
18
|
+
normalizeAllowedTypes,
|
|
21
19
|
type ImplicitAllowedTypes,
|
|
22
20
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
23
21
|
type TreeNodeFromImplicitAllowedTypes,
|
|
@@ -26,23 +24,25 @@ import {
|
|
|
26
24
|
getKernel,
|
|
27
25
|
type InnerNode,
|
|
28
26
|
NodeKind,
|
|
29
|
-
type
|
|
27
|
+
type TreeNodeSchemaBoth,
|
|
30
28
|
type TreeNodeSchema,
|
|
31
29
|
type WithType,
|
|
32
30
|
// eslint-disable-next-line import/no-deprecated
|
|
33
31
|
typeNameSymbol,
|
|
34
32
|
type TreeNode,
|
|
35
33
|
typeSchemaSymbol,
|
|
34
|
+
type Context,
|
|
35
|
+
UnhydratedFlexTreeNode,
|
|
36
36
|
} from "./core/index.js";
|
|
37
37
|
import {
|
|
38
38
|
mapTreeFromNodeData,
|
|
39
39
|
type FactoryContent,
|
|
40
40
|
type InsertableContent,
|
|
41
41
|
} from "./toMapTree.js";
|
|
42
|
-
import {
|
|
43
|
-
import { brand, count, type RestrictiveReadonlyRecord } from "../util/index.js";
|
|
42
|
+
import { brand, count, type RestrictiveStringRecord } from "../util/index.js";
|
|
44
43
|
import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
|
|
45
44
|
import type { ExclusiveMapTree } from "../core/index.js";
|
|
45
|
+
import { getUnhydratedContext } from "./createContext.js";
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* A map of string keys to tree objects.
|
|
@@ -233,8 +233,9 @@ export function mapSchema<
|
|
|
233
233
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
234
234
|
useMapPrototype: boolean,
|
|
235
235
|
) {
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(info));
|
|
237
|
+
|
|
238
|
+
let unhydratedContext: Context;
|
|
238
239
|
|
|
239
240
|
class Schema extends CustomMapNodeBase<T> implements TreeMapNode<T> {
|
|
240
241
|
public static override prepareInstance<T2>(
|
|
@@ -252,26 +253,28 @@ export function mapSchema<
|
|
|
252
253
|
this: typeof TreeNodeValid<T2>,
|
|
253
254
|
instance: TreeNodeValid<T2>,
|
|
254
255
|
input: T2,
|
|
255
|
-
):
|
|
256
|
-
return
|
|
256
|
+
): UnhydratedFlexTreeNode {
|
|
257
|
+
return UnhydratedFlexTreeNode.getOrCreate(
|
|
257
258
|
unhydratedContext,
|
|
258
|
-
flexSchema,
|
|
259
259
|
mapTreeFromNodeData(input as FactoryContent, this as unknown as ImplicitAllowedTypes),
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
protected static override constructorCached: MostDerivedData | undefined = undefined;
|
|
264
264
|
|
|
265
|
-
protected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>):
|
|
265
|
+
protected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {
|
|
266
266
|
const schema = this as unknown as TreeNodeSchema;
|
|
267
|
-
|
|
268
|
-
unhydratedContext
|
|
267
|
+
unhydratedContext = getUnhydratedContext(schema);
|
|
268
|
+
return unhydratedContext;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
public static readonly identifier = identifier;
|
|
272
272
|
public static readonly info = info;
|
|
273
273
|
public static readonly implicitlyConstructable: ImplicitlyConstructable =
|
|
274
274
|
implicitlyConstructable;
|
|
275
|
+
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
276
|
+
return lazyChildTypes.value;
|
|
277
|
+
}
|
|
275
278
|
|
|
276
279
|
// eslint-disable-next-line import/no-deprecated
|
|
277
280
|
public get [typeNameSymbol](): TName {
|
|
@@ -281,7 +284,7 @@ export function mapSchema<
|
|
|
281
284
|
return Schema.constructorCached?.constructor as unknown as typeof schemaErased;
|
|
282
285
|
}
|
|
283
286
|
}
|
|
284
|
-
const schemaErased:
|
|
287
|
+
const schemaErased: TreeNodeSchemaBoth<
|
|
285
288
|
TName,
|
|
286
289
|
NodeKind.Map,
|
|
287
290
|
TreeMapNode<T> & WithType<TName, NodeKind.Map>,
|
|
@@ -298,4 +301,4 @@ export function mapSchema<
|
|
|
298
301
|
*/
|
|
299
302
|
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> =
|
|
300
303
|
| Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>
|
|
301
|
-
|
|
|
304
|
+
| RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
|
@@ -3,22 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, Lazy } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
import type { FieldKey } from "../core/index.js";
|
|
10
10
|
import {
|
|
11
11
|
FieldKinds,
|
|
12
|
-
type FlexObjectNodeSchema,
|
|
13
12
|
type FlexTreeField,
|
|
14
13
|
type FlexTreeNode,
|
|
15
14
|
type FlexTreeOptionalField,
|
|
16
15
|
type FlexTreeRequiredField,
|
|
17
|
-
getOrCreateMapTreeNode,
|
|
18
16
|
getSchemaAndPolicy,
|
|
19
|
-
isMapTreeNode,
|
|
20
|
-
type MapTreeNode,
|
|
21
|
-
UnhydratedContext,
|
|
22
17
|
} from "../feature-libraries/index.js";
|
|
23
18
|
import { getTreeNodeForField, prepareContentForHydration } from "./proxies.js";
|
|
24
19
|
import { getOrCreateInnerNode } from "./proxyBinding.js";
|
|
@@ -42,21 +37,23 @@ import {
|
|
|
42
37
|
typeSchemaSymbol,
|
|
43
38
|
type InternalTreeNode,
|
|
44
39
|
type TreeNode,
|
|
40
|
+
type Context,
|
|
41
|
+
UnhydratedFlexTreeNode,
|
|
45
42
|
} from "./core/index.js";
|
|
46
43
|
import { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js";
|
|
47
|
-
import { type
|
|
48
|
-
import { getFlexSchema, toFlexSchema } from "./toFlexSchema.js";
|
|
44
|
+
import { type RestrictiveStringRecord, fail, type FlattenKeys } from "../util/index.js";
|
|
49
45
|
import type { ObjectNodeSchema, ObjectNodeSchemaInternalData } from "./objectNodeTypes.js";
|
|
50
46
|
import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
|
|
47
|
+
import { getUnhydratedContext } from "./createContext.js";
|
|
51
48
|
|
|
52
49
|
/**
|
|
53
50
|
* Helper used to produce types for object nodes.
|
|
54
51
|
* @system @public
|
|
55
52
|
*/
|
|
56
|
-
export type ObjectFromSchemaRecord<
|
|
57
|
-
T extends
|
|
58
|
-
>
|
|
59
|
-
|
|
53
|
+
export type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = {
|
|
54
|
+
-readonly [Property in keyof T]: Property extends string
|
|
55
|
+
? TreeFieldFromImplicitField<T[Property]>
|
|
56
|
+
: unknown;
|
|
60
57
|
};
|
|
61
58
|
|
|
62
59
|
/**
|
|
@@ -71,7 +68,7 @@ export type ObjectFromSchemaRecord<
|
|
|
71
68
|
* @public
|
|
72
69
|
*/
|
|
73
70
|
export type TreeObjectNode<
|
|
74
|
-
T extends
|
|
71
|
+
T extends RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
75
72
|
TypeName extends string = string,
|
|
76
73
|
> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
|
77
74
|
|
|
@@ -106,15 +103,17 @@ export type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSche
|
|
|
106
103
|
* @system @public
|
|
107
104
|
*/
|
|
108
105
|
export type InsertableObjectFromSchemaRecord<
|
|
109
|
-
T extends
|
|
106
|
+
T extends RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
110
107
|
> = FlattenKeys<
|
|
111
108
|
{
|
|
112
|
-
readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<
|
|
109
|
+
readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<
|
|
110
|
+
T[Property] & string
|
|
111
|
+
>;
|
|
113
112
|
} & {
|
|
114
113
|
// Field does not have a known default, make it required:
|
|
115
|
-
readonly [Property in keyof T as FieldHasDefault<T[Property]> extends false
|
|
114
|
+
readonly [Property in keyof T as FieldHasDefault<T[Property] & string> extends false
|
|
116
115
|
? Property
|
|
117
|
-
: never]: InsertableTreeFieldFromImplicitField<T[Property]>;
|
|
116
|
+
: never]: InsertableTreeFieldFromImplicitField<T[Property] & string>;
|
|
118
117
|
}
|
|
119
118
|
>;
|
|
120
119
|
|
|
@@ -152,7 +151,7 @@ function createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): Simp
|
|
|
152
151
|
* If not provided `{}` is used for the target.
|
|
153
152
|
*/
|
|
154
153
|
function createProxyHandler(
|
|
155
|
-
|
|
154
|
+
schema: ObjectNodeSchema & ObjectNodeSchemaInternalData,
|
|
156
155
|
allowAdditionalProperties: boolean,
|
|
157
156
|
): ProxyHandler<TreeNode> {
|
|
158
157
|
// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same
|
|
@@ -166,7 +165,7 @@ function createProxyHandler(
|
|
|
166
165
|
// a dispatch object to see if it improves performance.
|
|
167
166
|
const handler: ProxyHandler<TreeNode> = {
|
|
168
167
|
get(target, propertyKey, proxy): unknown {
|
|
169
|
-
const fieldInfo = flexKeyMap.get(propertyKey);
|
|
168
|
+
const fieldInfo = schema.flexKeyMap.get(propertyKey);
|
|
170
169
|
|
|
171
170
|
if (fieldInfo !== undefined) {
|
|
172
171
|
const flexNode = getOrCreateInnerNode(proxy);
|
|
@@ -179,7 +178,10 @@ function createProxyHandler(
|
|
|
179
178
|
// Check if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.
|
|
180
179
|
// This means the identifier is an "auto-generated identifier", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.
|
|
181
180
|
// In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.
|
|
182
|
-
if (
|
|
181
|
+
if (
|
|
182
|
+
fieldInfo.schema.kind === FieldKind.Identifier &&
|
|
183
|
+
flexNode instanceof UnhydratedFlexTreeNode
|
|
184
|
+
) {
|
|
183
185
|
throw new UsageError(
|
|
184
186
|
"An automatically generated node identifier may not be queried until the node is inserted into the tree",
|
|
185
187
|
);
|
|
@@ -188,11 +190,20 @@ function createProxyHandler(
|
|
|
188
190
|
return undefined;
|
|
189
191
|
}
|
|
190
192
|
|
|
193
|
+
// POJO mode objects don't have TreeNode's build in members on their targets, so special case them:
|
|
194
|
+
if (propertyKey === typeSchemaSymbol) {
|
|
195
|
+
return schema;
|
|
196
|
+
}
|
|
197
|
+
// eslint-disable-next-line import/no-deprecated
|
|
198
|
+
if (propertyKey === typeNameSymbol) {
|
|
199
|
+
return schema.identifier;
|
|
200
|
+
}
|
|
201
|
+
|
|
191
202
|
// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.
|
|
192
203
|
return Reflect.get(target, propertyKey, proxy);
|
|
193
204
|
},
|
|
194
205
|
set(target, propertyKey, value: InsertableContent | undefined, proxy) {
|
|
195
|
-
const fieldInfo = flexKeyMap.get(propertyKey);
|
|
206
|
+
const fieldInfo = schema.flexKeyMap.get(propertyKey);
|
|
196
207
|
if (fieldInfo === undefined) {
|
|
197
208
|
// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.
|
|
198
209
|
return allowAdditionalProperties
|
|
@@ -215,18 +226,18 @@ function createProxyHandler(
|
|
|
215
226
|
},
|
|
216
227
|
has: (target, propertyKey) => {
|
|
217
228
|
return (
|
|
218
|
-
flexKeyMap.has(propertyKey) ||
|
|
229
|
+
schema.flexKeyMap.has(propertyKey) ||
|
|
219
230
|
(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)
|
|
220
231
|
);
|
|
221
232
|
},
|
|
222
233
|
ownKeys: (target) => {
|
|
223
234
|
return [
|
|
224
|
-
...flexKeyMap.keys(),
|
|
235
|
+
...schema.flexKeyMap.keys(),
|
|
225
236
|
...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),
|
|
226
237
|
];
|
|
227
238
|
},
|
|
228
239
|
getOwnPropertyDescriptor: (target, propertyKey) => {
|
|
229
|
-
const fieldInfo = flexKeyMap.get(propertyKey);
|
|
240
|
+
const fieldInfo = schema.flexKeyMap.get(propertyKey);
|
|
230
241
|
|
|
231
242
|
if (fieldInfo === undefined) {
|
|
232
243
|
return allowAdditionalProperties
|
|
@@ -272,7 +283,7 @@ export function setField(
|
|
|
272
283
|
prepareContentForHydration(mapTree, field.context.checkout.forest);
|
|
273
284
|
}
|
|
274
285
|
|
|
275
|
-
switch (field.schema
|
|
286
|
+
switch (field.schema) {
|
|
276
287
|
case FieldKinds.required.identifier: {
|
|
277
288
|
assert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);
|
|
278
289
|
const typedField = field as FlexTreeRequiredField;
|
|
@@ -291,7 +302,7 @@ export function setField(
|
|
|
291
302
|
}
|
|
292
303
|
|
|
293
304
|
abstract class CustomObjectNodeBase<
|
|
294
|
-
const T extends
|
|
305
|
+
const T extends RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
295
306
|
> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {
|
|
296
307
|
public static readonly kind = NodeKind.Object;
|
|
297
308
|
}
|
|
@@ -304,7 +315,7 @@ abstract class CustomObjectNodeBase<
|
|
|
304
315
|
*/
|
|
305
316
|
export function objectSchema<
|
|
306
317
|
TName extends string,
|
|
307
|
-
const T extends
|
|
318
|
+
const T extends RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
308
319
|
const ImplicitlyConstructable extends boolean,
|
|
309
320
|
>(
|
|
310
321
|
identifier: TName,
|
|
@@ -318,10 +329,20 @@ export function objectSchema<
|
|
|
318
329
|
// Performance optimization: cache property key => stored key and schema.
|
|
319
330
|
const flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);
|
|
320
331
|
|
|
332
|
+
const identifierFieldKeys: FieldKey[] = [];
|
|
333
|
+
for (const item of flexKeyMap.values()) {
|
|
334
|
+
if (item.schema.kind === FieldKind.Identifier) {
|
|
335
|
+
identifierFieldKeys.push(item.storedKey);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const lazyChildTypes = new Lazy(
|
|
340
|
+
() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),
|
|
341
|
+
);
|
|
342
|
+
|
|
321
343
|
let handler: ProxyHandler<object>;
|
|
322
344
|
let customizable: boolean;
|
|
323
|
-
let
|
|
324
|
-
let unhydratedContext: UnhydratedContext;
|
|
345
|
+
let unhydratedContext: Context;
|
|
325
346
|
|
|
326
347
|
class CustomObjectNode extends CustomObjectNodeBase<T> {
|
|
327
348
|
public static readonly fields: ReadonlyMap<string, FieldSchema> = new Map(
|
|
@@ -337,6 +358,7 @@ export function objectSchema<
|
|
|
337
358
|
key as string,
|
|
338
359
|
]),
|
|
339
360
|
);
|
|
361
|
+
public static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;
|
|
340
362
|
|
|
341
363
|
public static override prepareInstance<T2>(
|
|
342
364
|
this: typeof TreeNodeValid<T2>,
|
|
@@ -372,23 +394,21 @@ export function objectSchema<
|
|
|
372
394
|
this: typeof TreeNodeValid<T2>,
|
|
373
395
|
instance: TreeNodeValid<T2>,
|
|
374
396
|
input: T2,
|
|
375
|
-
):
|
|
376
|
-
return
|
|
397
|
+
): UnhydratedFlexTreeNode {
|
|
398
|
+
return UnhydratedFlexTreeNode.getOrCreate(
|
|
377
399
|
unhydratedContext,
|
|
378
|
-
flexSchema,
|
|
379
400
|
mapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),
|
|
380
401
|
);
|
|
381
402
|
}
|
|
382
403
|
|
|
383
404
|
protected static override constructorCached: MostDerivedData | undefined = undefined;
|
|
384
405
|
|
|
385
|
-
protected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>):
|
|
406
|
+
protected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): Context {
|
|
386
407
|
// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.
|
|
387
408
|
customizable = (this as unknown) !== CustomObjectNode;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
unhydratedContext = new UnhydratedContext(toFlexSchema(schema));
|
|
409
|
+
const schema = this as unknown as ObjectNodeSchema & ObjectNodeSchemaInternalData;
|
|
410
|
+
handler = createProxyHandler(schema, customizable);
|
|
411
|
+
unhydratedContext = getUnhydratedContext(schema);
|
|
392
412
|
|
|
393
413
|
// First run, do extra validation.
|
|
394
414
|
// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.
|
|
@@ -414,12 +434,17 @@ export function objectSchema<
|
|
|
414
434
|
prototype = Reflect.getPrototypeOf(prototype) as object;
|
|
415
435
|
}
|
|
416
436
|
}
|
|
437
|
+
|
|
438
|
+
return unhydratedContext;
|
|
417
439
|
}
|
|
418
440
|
|
|
419
441
|
public static readonly identifier = identifier;
|
|
420
442
|
public static readonly info = info;
|
|
421
443
|
public static readonly implicitlyConstructable: ImplicitlyConstructable =
|
|
422
444
|
implicitlyConstructable;
|
|
445
|
+
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
446
|
+
return lazyChildTypes.value;
|
|
447
|
+
}
|
|
423
448
|
|
|
424
449
|
// eslint-disable-next-line import/no-deprecated
|
|
425
450
|
public get [typeNameSymbol](): TName {
|
|
@@ -445,7 +470,7 @@ const targetToProxy: WeakMap<object, TreeNode> = new WeakMap();
|
|
|
445
470
|
*/
|
|
446
471
|
function assertUniqueKeys<
|
|
447
472
|
const Name extends number | string,
|
|
448
|
-
const Fields extends
|
|
473
|
+
const Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
449
474
|
>(schemaName: Name, fields: Fields): void {
|
|
450
475
|
// Verify that there are no duplicates among the explicitly specified stored keys.
|
|
451
476
|
const explicitStoredKeys = new Set<string>();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { RestrictiveStringRecord } from "../util/index.js";
|
|
7
7
|
import type {
|
|
8
8
|
TreeObjectNode,
|
|
9
9
|
InsertableObjectFromSchemaRecord,
|
|
@@ -20,10 +20,8 @@ import type { FieldKey } from "../core/index.js";
|
|
|
20
20
|
*/
|
|
21
21
|
export interface ObjectNodeSchema<
|
|
22
22
|
TName extends string = string,
|
|
23
|
-
T extends
|
|
24
|
-
|
|
25
|
-
ImplicitFieldSchema
|
|
26
|
-
>,
|
|
23
|
+
T extends
|
|
24
|
+
RestrictiveStringRecord<ImplicitFieldSchema> = RestrictiveStringRecord<ImplicitFieldSchema>,
|
|
27
25
|
ImplicitlyConstructable extends boolean = boolean,
|
|
28
26
|
> extends TreeNodeSchemaClass<
|
|
29
27
|
TName,
|
|
@@ -52,6 +50,11 @@ export interface ObjectNodeSchemaInternalData {
|
|
|
52
50
|
* Lookup the property keys from the stored keys.
|
|
53
51
|
*/
|
|
54
52
|
readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Stored keys which hold identifiers.
|
|
56
|
+
*/
|
|
57
|
+
readonly identifierFieldKeys: readonly FieldKey[];
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export const ObjectNodeSchema = {
|
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
FieldKinds,
|
|
18
18
|
type FlexTreeField,
|
|
19
|
-
type FlexTreeNode,
|
|
20
|
-
tryGetMapTreeNode,
|
|
21
19
|
isFlexTreeNode,
|
|
22
20
|
type FlexTreeRequiredField,
|
|
23
21
|
type FlexTreeOptionalField,
|
|
@@ -25,10 +23,10 @@ import {
|
|
|
25
23
|
import { type Mutable, fail, isReadonlyArray } from "../util/index.js";
|
|
26
24
|
import {
|
|
27
25
|
getKernel,
|
|
28
|
-
tryGetCachedTreeNode,
|
|
29
26
|
type TreeNode,
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
tryGetTreeNodeFromMapNode,
|
|
28
|
+
getOrCreateNodeFromInnerNode,
|
|
29
|
+
tryUnhydratedFlexTreeNode,
|
|
32
30
|
} from "./core/index.js";
|
|
33
31
|
|
|
34
32
|
/**
|
|
@@ -40,10 +38,10 @@ export function getTreeNodeForField(field: FlexTreeField): TreeNode | TreeValue
|
|
|
40
38
|
): TreeNode | TreeValue | undefined {
|
|
41
39
|
const maybeContent = flexField.content;
|
|
42
40
|
return isFlexTreeNode(maybeContent)
|
|
43
|
-
?
|
|
41
|
+
? getOrCreateNodeFromInnerNode(maybeContent)
|
|
44
42
|
: maybeContent;
|
|
45
43
|
}
|
|
46
|
-
switch (field.schema
|
|
44
|
+
switch (field.schema) {
|
|
47
45
|
case FieldKinds.required.identifier: {
|
|
48
46
|
const typedField = field as FlexTreeRequiredField;
|
|
49
47
|
return tryToUnboxLeaves(typedField);
|
|
@@ -62,22 +60,6 @@ export function getTreeNodeForField(field: FlexTreeField): TreeNode | TreeValue
|
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
export function getOrCreateNodeFromFlexTreeNode(flexNode: FlexTreeNode): TreeNode | TreeValue {
|
|
66
|
-
const cachedProxy = tryGetCachedTreeNode(flexNode);
|
|
67
|
-
if (cachedProxy !== undefined) {
|
|
68
|
-
return cachedProxy;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const classSchema = getSimpleNodeSchemaFromNode(flexNode);
|
|
72
|
-
const node = flexNode as unknown as InternalTreeNode;
|
|
73
|
-
// eslint-disable-next-line unicorn/prefer-ternary
|
|
74
|
-
if (typeof classSchema === "function") {
|
|
75
|
-
return new classSchema(node) as TreeNode;
|
|
76
|
-
} else {
|
|
77
|
-
return (classSchema as { create(data: FlexTreeNode): TreeValue }).create(flexNode);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
63
|
// #region Content insertion and proxy binding
|
|
82
64
|
|
|
83
65
|
/** The path of a proxy, relative to the root of the content tree that the proxy belongs to */
|
|
@@ -152,7 +134,7 @@ function walkMapTree(
|
|
|
152
134
|
path: UpPath,
|
|
153
135
|
onVisitTreeNode: (path: UpPath, treeNode: TreeNode) => void,
|
|
154
136
|
): void {
|
|
155
|
-
if (
|
|
137
|
+
if (tryUnhydratedFlexTreeNode(mapTree)?.parentField.parent.parent !== undefined) {
|
|
156
138
|
throw new UsageError(
|
|
157
139
|
"Attempted to insert a node which is already under a parent. If this is desired, remove the node from its parent before inserting it elsewhere.",
|
|
158
140
|
);
|
|
@@ -162,9 +144,9 @@ function walkMapTree(
|
|
|
162
144
|
const nexts: Next[] = [];
|
|
163
145
|
for (let next: Next | undefined = [path, mapTree]; next !== undefined; next = nexts.pop()) {
|
|
164
146
|
const [p, m] = next;
|
|
165
|
-
const mapTreeNode =
|
|
147
|
+
const mapTreeNode = tryUnhydratedFlexTreeNode(m);
|
|
166
148
|
if (mapTreeNode !== undefined) {
|
|
167
|
-
const treeNode =
|
|
149
|
+
const treeNode = tryGetTreeNodeFromMapNode(mapTreeNode);
|
|
168
150
|
if (treeNode !== undefined) {
|
|
169
151
|
onVisitTreeNode(p, treeNode);
|
|
170
152
|
}
|