@fluidframework/tree 2.0.2 → 2.1.0-276326
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/settings.json +16 -0
- package/README.md +6 -9
- package/api-report/tree.alpha.api.md +0 -15
- package/api-report/tree.beta.api.md +0 -12
- package/api-report/tree.public.api.md +0 -12
- package/dist/core/tree/anchorSet.js +2 -2
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
- 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/lazyField.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +4 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +4 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- 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/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/schematizingTreeView.d.ts +4 -6
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +16 -12
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +0 -10
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeView.d.ts +13 -6
- package/dist/shared-tree/treeView.d.ts.map +1 -1
- package/dist/shared-tree/treeView.js +0 -2
- package/dist/shared-tree/treeView.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +4 -0
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +13 -16
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/schemaFactory.js +2 -24
- package/dist/simple-tree/schemaFactory.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +0 -15
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +1 -35
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/tree.d.ts +0 -29
- package/dist/simple-tree/tree.d.ts.map +1 -1
- package/dist/simple-tree/tree.js +1 -24
- package/dist/simple-tree/tree.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -1
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/brandedMap.d.ts +9 -2
- package/dist/util/brandedMap.d.ts.map +1 -1
- package/dist/util/brandedMap.js +3 -4
- package/dist/util/brandedMap.js.map +1 -1
- package/lib/core/tree/anchorSet.js +2 -2
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
- 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/lazyField.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +4 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +4 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- 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/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -6
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +19 -15
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +0 -10
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeView.d.ts +13 -6
- package/lib/shared-tree/treeView.d.ts.map +1 -1
- package/lib/shared-tree/treeView.js +0 -2
- package/lib/shared-tree/treeView.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -3
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +4 -0
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +14 -17
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/schemaFactory.js +3 -25
- package/lib/simple-tree/schemaFactory.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +0 -15
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +0 -33
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/tree.d.ts +0 -29
- package/lib/simple-tree/tree.d.ts.map +1 -1
- package/lib/simple-tree/tree.js +0 -22
- package/lib/simple-tree/tree.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -1
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/brandedMap.d.ts +9 -2
- package/lib/util/brandedMap.d.ts.map +1 -1
- package/lib/util/brandedMap.js +3 -4
- package/lib/util/brandedMap.js.map +1 -1
- package/package.json +23 -23
- package/src/core/tree/anchorSet.ts +3 -3
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +5 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +8 -5
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +5 -0
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +4 -0
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +6 -1
- package/src/shared-tree/schematizingTreeView.ts +32 -26
- package/src/shared-tree/sharedTree.ts +0 -18
- package/src/shared-tree/treeApi.ts +2 -2
- package/src/shared-tree/treeView.ts +14 -8
- package/src/simple-tree/index.ts +7 -3
- package/src/simple-tree/objectNode.ts +6 -0
- package/src/simple-tree/proxies.ts +22 -20
- package/src/simple-tree/schemaFactory.ts +5 -41
- package/src/simple-tree/toFlexSchema.ts +0 -47
- package/src/simple-tree/tree.ts +0 -37
- package/src/treeFactory.ts +1 -1
- package/src/util/brandedMap.ts +18 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../src/simple-tree/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAGtE,4DAauC;AACvC,6CAKsB;AACtB,uDAAgD;AAChD,qDAe0B;AAC1B,iDAAqD;AACrD,yCAAiF;AACjF,+CAA0F;AAC1F,uDAAkD;AA+ElD;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAA,qCAAoB,EAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAC1B,UAAwB,EACxB,yBAAkC;IAElC,kGAAkG;IAClG,kGAAkG;IAClG,sEAAsE;IACtE,EAAE;IACF,sGAAsG;IACtG,wFAAwF;IAExF,kGAAkG;IAClG,uDAAuD;IACvD,MAAM,OAAO,GAA2B;QACvC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;YACzB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAE1C,IAA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B,CAAC,MAAsB;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,yBAAQ,CAAC,MAAM,CAAC;AACxC,CAAC;AAFD,gDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey, TreeNodeSchemaIdentifier } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeNode,\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexObjectNodeSchema,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\tgetOrCreateMapTreeNode,\n\tgetSchemaAndPolicy,\n\tisMapTreeNode,\n\ttype MapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype InsertableContent,\n\tgetProxyForField,\n\tmarkContentType,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nimport { getFlexNode } from \"./proxyBinding.js\";\nimport {\n\tNodeKind,\n\ttype ImplicitFieldSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\ttypeNameSymbol,\n\ttype ImplicitAllowedTypes,\n\tFieldKind,\n} from \"./schemaTypes.js\";\nimport { mapTreeFromNodeData } from \"./toMapTree.js\";\nimport { type InternalTreeNode, type TreeNode, TreeNodeValid } from \"./types.js\";\nimport { type RestrictiveReadonlyRecord, fail, type FlattenKeys } from \"../util/index.js\";\nimport { getFlexSchema } from \"./toFlexSchema.js\";\n\n/**\n * Helper used to produce types for object nodes.\n * @public\n */\nexport type ObjectFromSchemaRecord<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> = {\n\t-readonly [Property in keyof T]: TreeFieldFromImplicitField<T[Property]>;\n};\n\n/**\n * A {@link TreeNode} which modules a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema}), and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName>;\n\n/**\n * Type utility for determining whether or not an implicit field schema has a default value.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<\n\tFieldKind.Optional | FieldKind.Identifier\n>\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @privateRemarks TODO: consider separating these cases into different types.\n *\n * @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> = FlattenKeys<\n\t{\n\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property]>;\n\t} & {\n\t\t// Field does not have a known default, make it required:\n\t\treadonly [Property in keyof T as FieldHasDefault<T[Property]> extends false\n\t\t\t? Property\n\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property]>;\n\t}\n>;\n\n/**\n * Maps from simple field keys (\"view\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given view key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\ntype SimpleKeyMap = ReadonlyMap<string | symbol, { storedKey: FieldKey; schema: FieldSchema }>;\n\n/**\n * Caches the mappings from view keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [viewKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(viewKey, fieldSchema);\n\t\tkeyMap.set(viewKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tflexKeyMap: SimpleKeyMap,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, viewKey, proxy): unknown {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getFlexNode(proxy);\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getProxyForField(field);\n\t\t\t\t}\n\n\t\t\t\t// Check if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.\n\t\t\t\t// 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.\n\t\t\t\t// 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.\n\t\t\t\tif (fieldInfo.schema.kind === FieldKind.Identifier && isMapTreeNode(flexNode)) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"An automatically generated node identifier may not be queried until the node is inserted into the tree\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, viewKey, proxy);\n\t\t},\n\t\tset(target, viewKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.set(target, viewKey, value) : false;\n\t\t\t}\n\n\t\t\tconst flexNode = getFlexNode(proxy);\n\t\t\tif (isMapTreeNode(flexNode)) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`An object cannot be mutated before being inserted into the tree`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tsetField(flexNode.getBoxed(fieldInfo.storedKey), fieldInfo.schema, value);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, viewKey) => {\n\t\t\treturn (\n\t\t\t\tflexKeyMap.has(viewKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, viewKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, viewKey) => {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, viewKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(\"missing proxy\");\n\t\t\tconst field = getFlexNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getProxyForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tswitch (field.schema.kind) {\n\t\tcase FieldKinds.required:\n\t\tcase FieldKinds.optional: {\n\t\t\tconst typedField = field as\n\t\t\t\t| FlexTreeRequiredField<FlexAllowedTypes>\n\t\t\t\t| FlexTreeOptionalField<FlexAllowedTypes>;\n\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tvalue,\n\t\t\t\tsimpleFieldSchema.allowedTypes,\n\t\t\t\tfield.context.nodeKeyManager,\n\t\t\t\tgetSchemaAndPolicy(field),\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, field.context.checkout.forest);\n\t\t\ttypedField.content = mapTree !== undefined ? cursorForMapTreeNode(mapTree) : undefined;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid FieldKind\");\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable> {\n\t// Ensure no collisions between final set of view keys, and final set of stored keys (including those\n\t// implicitly derived from view keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache view key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet flexSchema: FlexObjectNodeSchema;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<string, FieldSchema> = new Map(\n\t\t\t[...flexKeyMap].map(([key, value]) => [key as string, value.schema]),\n\t\t);\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): MapTreeNode {\n\t\t\treturn getOrCreateMapTreeNode(\n\t\t\t\tflexSchema,\n\t\t\t\tmapTreeFromNodeData(\n\t\t\t\t\tcopyContent(flexSchema.name, input as object),\n\t\t\t\t\tthis as unknown as ImplicitAllowedTypes,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tprotected static override constructorCached: typeof TreeNodeValid | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): void {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\thandler = createProxyHandler(flexKeyMap, customizable);\n\t\t\tflexSchema = getFlexSchema(this as unknown as TreeNodeSchema) as FlexObjectNodeSchema;\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t}\n\n\treturn CustomObjectNode as typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of view keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from view keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from view keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [viewKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(viewKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\nfunction copyContent<T extends object>(typeName: TreeNodeSchemaIdentifier, content: T): T {\n\tconst copy = { ...content };\n\tmarkContentType(typeName, copy);\n\treturn copy;\n}\n\n/**\n * A schema for {@link TreeObjectNode}s.\n * @privateRemarks\n * This is a candidate for being promoted to the public package API.\n */\nexport interface ObjectNodeSchema<\n\tTName extends string = string,\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema> = RestrictiveReadonlyRecord<\n\t\tstring,\n\t\tImplicitFieldSchema\n\t>,\n\tImplicitlyConstructable extends boolean = boolean,\n> extends TreeNodeSchemaClass<\n\t\tTName,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, TName>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\treadonly fields: ReadonlyMap<string, FieldSchema>;\n}\n\nexport const ObjectNodeSchema = {\n\t// instanceof-based narrowing support for Javascript and TypeScript 5.3 or newer.\n\t[Symbol.hasInstance](value: TreeNodeSchema): value is ObjectNodeSchema {\n\t\treturn isObjectNodeSchema(value);\n\t},\n} as const;\n\nexport function isObjectNodeSchema(schema: TreeNodeSchema): schema is ObjectNodeSchema {\n\treturn schema.kind === NodeKind.Object;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../src/simple-tree/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAGtE,4DAauC;AACvC,6CAKsB;AACtB,uDAAgD;AAChD,qDAe0B;AAC1B,iDAAqD;AACrD,yCAAiF;AACjF,+CAA0F;AAC1F,uDAAkD;AA+ElD;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAA,qCAAoB,EAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAC1B,UAAwB,EACxB,yBAAkC;IAElC,kGAAkG;I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WAAW,CAAmB,QAAkC,EAAE,OAAU;IACpF,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAC5B,IAAA,4BAAe,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACb,CAAC;AAyBY,QAAA,gBAAgB,GAAG;IAC/B,iFAAiF;IACjF,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAqB;QACzC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACQ,CAAC;AAEX,SAAgB,kBAAkB,CAAC,MAAsB;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,yBAAQ,CAAC,MAAM,CAAC;AACxC,CAAC;AAFD,gDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey, TreeNodeSchemaIdentifier } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeNode,\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexObjectNodeSchema,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\tgetOrCreateMapTreeNode,\n\tgetSchemaAndPolicy,\n\tisMapTreeNode,\n\ttype MapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype InsertableContent,\n\tgetProxyForField,\n\tmarkContentType,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nimport { getFlexNode } from \"./proxyBinding.js\";\nimport {\n\tNodeKind,\n\ttype ImplicitFieldSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tnormalizeFieldSchema,\n\ttypeNameSymbol,\n\ttype ImplicitAllowedTypes,\n\tFieldKind,\n} from \"./schemaTypes.js\";\nimport { mapTreeFromNodeData } from \"./toMapTree.js\";\nimport { type InternalTreeNode, type TreeNode, TreeNodeValid } from \"./types.js\";\nimport { type RestrictiveReadonlyRecord, fail, type FlattenKeys } from \"../util/index.js\";\nimport { getFlexSchema } from \"./toFlexSchema.js\";\n\n/**\n * Helper used to produce types for object nodes.\n * @public\n */\nexport type ObjectFromSchemaRecord<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> = {\n\t-readonly [Property in keyof T]: TreeFieldFromImplicitField<T[Property]>;\n};\n\n/**\n * A {@link TreeNode} which modules a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema}), and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName>;\n\n/**\n * Type utility for determining whether or not an implicit field schema has a default value.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<\n\tFieldKind.Optional | FieldKind.Identifier\n>\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @privateRemarks TODO: consider separating these cases into different types.\n *\n * @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> = FlattenKeys<\n\t{\n\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property]>;\n\t} & {\n\t\t// Field does not have a known default, make it required:\n\t\treadonly [Property in keyof T as FieldHasDefault<T[Property]> extends false\n\t\t\t? Property\n\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property]>;\n\t}\n>;\n\n/**\n * Maps from simple field keys (\"view\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given view key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\ntype SimpleKeyMap = ReadonlyMap<string | symbol, { storedKey: FieldKey; schema: FieldSchema }>;\n\n/**\n * Caches the mappings from view keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [viewKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(viewKey, fieldSchema);\n\t\tkeyMap.set(viewKey, { storedKey, schema: normalizeFieldSchema(fieldSchema) });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tflexKeyMap: SimpleKeyMap,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, viewKey, proxy): unknown {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getFlexNode(proxy);\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn getProxyForField(field);\n\t\t\t\t}\n\n\t\t\t\t// Check if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.\n\t\t\t\t// 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.\n\t\t\t\t// 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.\n\t\t\t\tif (fieldInfo.schema.kind === FieldKind.Identifier && isMapTreeNode(flexNode)) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"An automatically generated node identifier may not be queried until the node is inserted into the tree\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, viewKey, proxy);\n\t\t},\n\t\tset(target, viewKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.set(target, viewKey, value) : false;\n\t\t\t}\n\n\t\t\tconst flexNode = getFlexNode(proxy);\n\t\t\tif (isMapTreeNode(flexNode)) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`An object cannot be mutated before being inserted into the tree`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tsetField(flexNode.getBoxed(fieldInfo.storedKey), fieldInfo.schema, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, viewKey): boolean {\n\t\t\t// TODO: supporting delete when it makes sense (custom local fields, and optional field) could be added as a feature in the future.\n\t\t\tthrow new UsageError(\n\t\t\t\t`Object nodes do not support the delete operator. Optional fields can be assigned to undefined instead.`,\n\t\t\t);\n\t\t},\n\t\thas: (target, viewKey) => {\n\t\t\treturn (\n\t\t\t\tflexKeyMap.has(viewKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, viewKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, viewKey) => {\n\t\t\tconst fieldInfo = flexKeyMap.get(viewKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, viewKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(\"missing proxy\");\n\t\t\tconst field = getFlexNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : getProxyForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n): void {\n\tswitch (field.schema.kind) {\n\t\tcase FieldKinds.required:\n\t\tcase FieldKinds.optional: {\n\t\t\tconst typedField = field as\n\t\t\t\t| FlexTreeRequiredField<FlexAllowedTypes>\n\t\t\t\t| FlexTreeOptionalField<FlexAllowedTypes>;\n\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tvalue,\n\t\t\t\tsimpleFieldSchema.allowedTypes,\n\t\t\t\tfield.context.nodeKeyManager,\n\t\t\t\tgetSchemaAndPolicy(field),\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, field.context.checkout.forest);\n\t\t\ttypedField.content = mapTree !== undefined ? cursorForMapTreeNode(mapTree) : undefined;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid FieldKind\");\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable> {\n\t// Ensure no collisions between final set of view keys, and final set of stored keys (including those\n\t// implicitly derived from view keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache view key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\tlet flexSchema: FlexObjectNodeSchema;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<string, FieldSchema> = new Map(\n\t\t\t[...flexKeyMap].map(([key, value]) => [key as string, value.schema]),\n\t\t);\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): MapTreeNode {\n\t\t\treturn getOrCreateMapTreeNode(\n\t\t\t\tflexSchema,\n\t\t\t\tmapTreeFromNodeData(\n\t\t\t\t\tcopyContent(flexSchema.name, input as object),\n\t\t\t\t\tthis as unknown as ImplicitAllowedTypes,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tprotected static override constructorCached: typeof TreeNodeValid | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup<T2>(this: typeof TreeNodeValid<T2>): void {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\thandler = createProxyHandler(flexKeyMap, customizable);\n\t\t\tflexSchema = getFlexSchema(this as unknown as TreeNodeSchema) as FlexObjectNodeSchema;\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t}\n\n\treturn CustomObjectNode as typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of view keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from view keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from view keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [viewKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(viewKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\nfunction copyContent<T extends object>(typeName: TreeNodeSchemaIdentifier, content: T): T {\n\tconst copy = { ...content };\n\tmarkContentType(typeName, copy);\n\treturn copy;\n}\n\n/**\n * A schema for {@link TreeObjectNode}s.\n * @privateRemarks\n * This is a candidate for being promoted to the public package API.\n */\nexport interface ObjectNodeSchema<\n\tTName extends string = string,\n\tT extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema> = RestrictiveReadonlyRecord<\n\t\tstring,\n\t\tImplicitFieldSchema\n\t>,\n\tImplicitlyConstructable extends boolean = boolean,\n> extends TreeNodeSchemaClass<\n\t\tTName,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, TName>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\treadonly fields: ReadonlyMap<string, FieldSchema>;\n}\n\nexport const ObjectNodeSchema = {\n\t// instanceof-based narrowing support for Javascript and TypeScript 5.3 or newer.\n\t[Symbol.hasInstance](value: TreeNodeSchema): value is ObjectNodeSchema {\n\t\treturn isObjectNodeSchema(value);\n\t},\n} as const;\n\nexport function isObjectNodeSchema(schema: TreeNodeSchema): schema is ObjectNodeSchema {\n\treturn schema.kind === NodeKind.Object;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxies.d.ts","sourceRoot":"","sources":["../../src/simple-tree/proxies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAEN,KAAK,mBAAmB,EACxB,KA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AC,EAAE,iBAAiB;CACzC,CAAC;AAEL;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC;AAEtE;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEtF"}
|
|
@@ -33,23 +33,20 @@ exports.isTreeNode = isTreeNode;
|
|
|
33
33
|
* Retrieve the associated proxy for the given field.
|
|
34
34
|
* */
|
|
35
35
|
function getProxyForField(field) {
|
|
36
|
+
function tryToUnboxLeaves(flexField) {
|
|
37
|
+
const maybeUnboxedContent = flexField.content;
|
|
38
|
+
return (0, index_js_2.isFlexTreeNode)(maybeUnboxedContent)
|
|
39
|
+
? getOrCreateNodeProxy(maybeUnboxedContent)
|
|
40
|
+
: maybeUnboxedContent;
|
|
41
|
+
}
|
|
36
42
|
switch (field.schema.kind) {
|
|
37
43
|
case index_js_2.FieldKinds.required: {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
// as simple as calling '.content' since this skips the node and returns the FieldNode's
|
|
41
|
-
// inner field.
|
|
42
|
-
return getOrCreateNodeProxy(asValue.boxedContent);
|
|
44
|
+
const typedField = field;
|
|
45
|
+
return tryToUnboxLeaves(typedField);
|
|
43
46
|
}
|
|
44
47
|
case index_js_2.FieldKinds.optional: {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
// as simple as calling '.content' since this skips the node and returns the FieldNode's
|
|
48
|
-
// inner field.
|
|
49
|
-
const maybeContent = asValue.boxedContent;
|
|
50
|
-
// Normally, empty fields are unreachable due to the behavior of 'tryGetField'. However, the
|
|
51
|
-
// root field is a special case where the field is always present (even if empty).
|
|
52
|
-
return maybeContent === undefined ? undefined : getOrCreateNodeProxy(maybeContent);
|
|
48
|
+
const typedField = field;
|
|
49
|
+
return tryToUnboxLeaves(typedField);
|
|
53
50
|
}
|
|
54
51
|
// TODO: Remove if/when 'FieldNode' is removed.
|
|
55
52
|
case index_js_2.FieldKinds.sequence: {
|
|
@@ -58,9 +55,9 @@ function getProxyForField(field) {
|
|
|
58
55
|
(0, index_js_3.fail)("'sequence' field is unexpected.");
|
|
59
56
|
}
|
|
60
57
|
case index_js_2.FieldKinds.identifier: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// Identifier fields are just value fields that hold strings
|
|
59
|
+
return field
|
|
60
|
+
.content;
|
|
64
61
|
}
|
|
65
62
|
default:
|
|
66
63
|
(0, index_js_3.fail)("invalid field kind");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../../src/simple-tree/proxies.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,+CAO0B;AAE1B,4DAUuC;AACvC,+CAAuE;AAEvE,uDAA6E;AAC7E,yDAA4D;AAI5D;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,IAAA,gCAAc,EAAC,SAAS,CAAC,KAAK,SAAS,CAAC;AAChD,CAAC;AAFD,gCAEC;AAED;;KAEK;AACL,SAAgB,gBAAgB,CAAC,KAAoB;IACpD,QAAQ,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3B,KAAK,qBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC1B,MAAM,OAAO,GAAG,KAAwE,CAAC;YAEzF,yFAAyF;YACzF,8FAA8F;YAC9F,qBAAqB;YACrB,OAAO,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,qBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC1B,MAAM,OAAO,GAAG,KAAwE,CAAC;YAEzF,yFAAyF;YACzF,8FAA8F;YAC9F,qBAAqB;YAErB,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;YAE1C,6FAA6F;YAC7F,kFAAkF;YAClF,OAA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AAC,WAAW,GAAG,QAAQ,CAAC;YAChE,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;gBAClE,MAAM,UAAU,GAAG,IAAA,6BAAW,EAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gBAC5D,WAAW,CAAC,aAAa,CAAC;oBACzB,EAAE,CACD,SAAY,EACZ,QAA+B;wBAE/B,QAAQ,SAAS,EAAE,CAAC;4BACnB,KAAK,aAAa,CAAC,CAAC,CAAC;gCACpB,OAAO,UAAU,CAAC,EAAE,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC;4BAC7D,CAAC;4BACD,KAAK,aAAa,CAAC,CAAC,CAAC;gCACpB,OAAO,UAAU,CAAC,EAAE,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;4BAC5D,CAAC;4BACD;gCACC,IAAA,eAAI,EAAC,+BAA+B,CAAC,CAAC;wBACxC,CAAC;oBACF,CAAC;iBACD,CAAC,CAAC;YACJ,CAAC;YACD,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC5B,GAAG,EAAE,CAAC;YACP,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AA2BD;;GAEG;AACH,SAAgB,eAAe,CAAC,QAAkC,EAAE,IAAY;IAC/E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,yBAAc,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC;AAFD,0CAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype IForestSubscription,\n\ttype MapTree,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../core/index.js\";\n\nimport {\n\tFieldKinds,\n\ttype FlexFieldSchema,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeTypedField,\n\ttype MapTreeNode,\n\ttryGetMapTreeNode,\n\ttypeNameSymbol,\n} from \"../feature-libraries/index.js\";\nimport { type Mutable, fail, isReadonlyArray } from \"../util/index.js\";\n\nimport { anchorProxy, tryGetFlexNode, tryGetProxy } from \"./proxyBinding.js\";\nimport { tryGetSimpleNodeSchema } from \"./schemaCaching.js\";\nimport type { TreeNode, Unhydrated } from \"./types.js\";\nimport type { Off } from \"../events/index.js\";\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn tryGetFlexNode(candidate) !== undefined;\n}\n\n/**\n * Retrieve the associated proxy for the given field.\n * */\nexport function getProxyForField(field: FlexTreeField): TreeNode | TreeValue | undefined {\n\tswitch (field.schema.kind) {\n\t\tcase FieldKinds.required: {\n\t\t\tconst asValue = field as FlexTreeTypedField<FlexFieldSchema<typeof FieldKinds.required>>;\n\n\t\t\t// TODO: Ideally, we would return leaves without first boxing them. However, this is not\n\t\t\t// as simple as calling '.content' since this skips the node and returns the FieldNode's\n\t\t\t// inner field.\n\t\t\treturn getOrCreateNodeProxy(asValue.boxedContent);\n\t\t}\n\t\tcase FieldKinds.optional: {\n\t\t\tconst asValue = field as FlexTreeTypedField<FlexFieldSchema<typeof FieldKinds.optional>>;\n\n\t\t\t// TODO: Ideally, we would return leaves without first boxing them. However, this is not\n\t\t\t// as simple as calling '.content' since this skips the node and returns the FieldNode's\n\t\t\t// inner field.\n\n\t\t\tconst maybeContent = asValue.boxedContent;\n\n\t\t\t// Normally, empty fields are unreachable due to the behavior of 'tryGetField'. However, the\n\t\t\t// root field is a special case where the field is always present (even if empty).\n\t\t\treturn maybeContent === undefined ? undefined : getOrCreateNodeProxy(maybeContent);\n\t\t}\n\t\t// TODO: Remove if/when 'FieldNode' is removed.\n\t\tcase FieldKinds.sequence: {\n\t\t\t// 'getProxyForNode' handles FieldNodes by unconditionally creating a array node proxy, making\n\t\t\t// this case unreachable as long as users follow the 'array recipe'.\n\t\t\tfail(\"'sequence' field is unexpected.\");\n\t\t}\n\t\tcase FieldKinds.identifier: {\n\t\t\tconst identifier = field.boxedAt(0);\n\t\t\tassert(identifier !== undefined, 0x91a /* identifier must exist */);\n\t\t\treturn getOrCreateNodeProxy(identifier);\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid field kind\");\n\t}\n}\n\nexport function getOrCreateNodeProxy(flexNode: FlexTreeNode): TreeNode | TreeValue {\n\tconst cachedProxy = tryGetProxy(flexNode);\n\tif (cachedProxy !== undefined) {\n\t\treturn cachedProxy;\n\t}\n\n\tconst schema = flexNode.schema;\n\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\tassert(classSchema !== undefined, 0x91b /* node without schema */);\n\tif (typeof classSchema === \"function\") {\n\t\tconst simpleSchema = classSchema as unknown as new (dummy: FlexTreeNode) => TreeNode;\n\t\treturn new simpleSchema(flexNode);\n\t} else {\n\t\treturn (classSchema as { create(data: FlexTreeNode): TreeNode }).create(flexNode);\n\t}\n}\n\n// #region Content insertion and proxy binding\n\n/** The path of a proxy, relative to the root of the content tree that the proxy belongs to */\ninterface RelativeProxyPath {\n\treadonly path: UpPath;\n\treadonly mapTreeNode: MapTreeNode;\n\treadonly proxy: TreeNode;\n}\n\n/** All {@link RelativeProxyPath}s that are under the given root path */\ninterface RootedProxyPaths {\n\treadonly rootPath: UpPath;\n\treadonly proxyPaths: RelativeProxyPath[];\n}\n\n/**\n * Records any proxies in the given content tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.\n * @remarks If the content tree contains any proxies, this function must be called just prior to inserting the content into the tree.\n * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.\n * The insertion of `content` must occur or else this function will cause memory leaks.\n * @param content - the tree of content to be inserted, of which any of its object/map/array nodes might be a proxy\n * @param anchors - the {@link AnchorSet} for the tree\n * @returns The content after having all proxies replaced inline with plain javascript objects.\n * See {@link extractFactoryContent} for more details.\n */\nexport function prepareContentForHydration(\n\tcontent: MapTree | readonly MapTree[] | undefined,\n\tforest: IForestSubscription,\n): void {\n\tif (isReadonlyArray(content)) {\n\t\treturn prepareArrayContentForHydration(content, forest);\n\t}\n\n\tif (content !== undefined) {\n\t\tconst proxies: RootedProxyPaths = {\n\t\t\trootPath: { parent: undefined, parentField: EmptyKey, parentIndex: 0 },\n\t\t\tproxyPaths: [],\n\t\t};\n\n\t\twalkMapTree(content, proxies.rootPath, (p, mapTreeNode, proxy) => {\n\t\t\tproxies.proxyPaths.push({ path: p, mapTreeNode, proxy });\n\t\t});\n\n\t\tbindProxies([proxies], forest);\n\t}\n}\n\nfunction prepareArrayContentForHydration(\n\tcontent: readonly MapTree[],\n\tforest: IForestSubscription,\n): void {\n\tconst proxies: RootedProxyPaths[] = [];\n\tfor (let i = 0; i < content.length; i++) {\n\t\tproxies.push({\n\t\t\trootPath: {\n\t\t\t\tparent: undefined,\n\t\t\t\tparentField: EmptyKey,\n\t\t\t\tparentIndex: 0,\n\t\t\t},\n\t\t\tproxyPaths: [],\n\t\t});\n\t\twalkMapTree(content[i], proxies[i].rootPath, (p, mapTreeNode, proxy) => {\n\t\t\tproxies[i].proxyPaths.push({ path: p, mapTreeNode, proxy });\n\t\t});\n\t}\n\n\tbindProxies(proxies, forest);\n}\n\nfunction walkMapTree(\n\tmapTree: MapTree,\n\tpath: UpPath,\n\tonVisitTreeNode: (path: UpPath, mapTreeNode: MapTreeNode, treeNode: TreeNode) => void,\n): void {\n\tconst mapTreeNode = tryGetMapTreeNode(mapTree);\n\tif (mapTreeNode !== undefined) {\n\t\tconst treeNode = tryGetProxy(mapTreeNode);\n\t\tif (treeNode !== undefined) {\n\t\t\tonVisitTreeNode(path, mapTreeNode, treeNode);\n\t\t}\n\t}\n\n\tfor (const [key, field] of mapTree.fields) {\n\t\tfor (let i = 0; i < field.length; i++) {\n\t\t\twalkMapTree(\n\t\t\t\tfield[i],\n\t\t\t\t{\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: key,\n\t\t\t\t\tparentIndex: i,\n\t\t\t\t},\n\t\t\t\tonVisitTreeNode,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction bindProxies(proxies: RootedProxyPaths[], forest: IForestSubscription): void {\n\t// Only subscribe to the event if there is at least one proxy tree to hydrate - this is not the case when inserting an empty array [].\n\tif (proxies.length > 0) {\n\t\t// Creating a new array emits one event per element in the array, so listen to the event once for each element\n\t\tlet i = 0;\n\t\tconst off = forest.on(\"afterRootFieldCreated\", (fieldKey) => {\n\t\t\t(proxies[i].rootPath as Mutable<UpPath>).parentField = fieldKey;\n\t\t\tfor (const { path, mapTreeNode, proxy } of proxies[i].proxyPaths) {\n\t\t\t\tconst anchorNode = anchorProxy(forest.anchors, path, proxy);\n\t\t\t\tmapTreeNode.forwardEvents({\n\t\t\t\t\ton<K extends keyof FlexTreeNodeEvents>(\n\t\t\t\t\t\teventName: K,\n\t\t\t\t\t\tlistener: FlexTreeNodeEvents[K],\n\t\t\t\t\t): Off {\n\t\t\t\t\t\tswitch (eventName) {\n\t\t\t\t\t\t\tcase \"nodeChanged\": {\n\t\t\t\t\t\t\t\treturn anchorNode.on(\"childrenChangedAfterBatch\", listener);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"treeChanged\": {\n\t\t\t\t\t\t\t\treturn anchorNode.on(\"subtreeChangedAfterBatch\", listener);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tfail(\"Unexpected event subscription\");\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (++i === proxies.length) {\n\t\t\t\toff();\n\t\t\t}\n\t\t});\n\t}\n}\n\n// #endregion Content insertion and proxy binding\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| ReadonlyMap<string, InsertableContent>\n\t| readonly InsertableContent[]\n\t| {\n\t\t\treadonly [P in string]?: InsertableContent;\n\t };\n\n/**\n * Content which can be inserted into a tree.\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n\n/**\n * Brand `copy` with the type (under {@link typeNameSymbol}) to avoid ambiguity when inferring types from this data.\n */\nexport function markContentType(typeName: TreeNodeSchemaIdentifier, copy: object): void {\n\tObject.defineProperty(copy, typeNameSymbol, { value: typeName });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../../src/simple-tree/proxies.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,+CAO0B;AAE1B,4DAWuC;AACvC,+CAAuE;AAEvE,uDAA6E;AAC7E,yDAA4D;AAI5D;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,IAAA,gCAAc,EAAC,SAAS,CAAC,KAAK,SAAS,CAAC;AAChD,CAAC;AAFD,gCAEC;AAED;;KAEK;AACL,SAAgB,gBAAgB,CAAC,KAAoB;IACpD,SAAS,gBAAgB,CACxB,SAEC;QAED,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC;QAC9C,OAAO,IAAA,yBAAc,EAAC,mBAA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/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype IForestSubscription,\n\ttype MapTree,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../core/index.js\";\n\nimport {\n\tFieldKinds,\n\ttype FlexFieldSchema,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeTypedField,\n\ttype MapTreeNode,\n\ttryGetMapTreeNode,\n\ttypeNameSymbol,\n\tisFlexTreeNode,\n} from \"../feature-libraries/index.js\";\nimport { type Mutable, fail, isReadonlyArray } from \"../util/index.js\";\n\nimport { anchorProxy, tryGetFlexNode, tryGetProxy } from \"./proxyBinding.js\";\nimport { tryGetSimpleNodeSchema } from \"./schemaCaching.js\";\nimport type { TreeNode, Unhydrated } from \"./types.js\";\nimport type { Off } from \"../events/index.js\";\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn tryGetFlexNode(candidate) !== undefined;\n}\n\n/**\n * Retrieve the associated proxy for the given field.\n * */\nexport function getProxyForField(field: FlexTreeField): TreeNode | TreeValue | undefined {\n\tfunction tryToUnboxLeaves(\n\t\tflexField: FlexTreeTypedField<\n\t\t\tFlexFieldSchema<typeof FieldKinds.required | typeof FieldKinds.optional>\n\t\t>,\n\t): TreeNode | TreeValue | undefined {\n\t\tconst maybeUnboxedContent = flexField.content;\n\t\treturn isFlexTreeNode(maybeUnboxedContent)\n\t\t\t? getOrCreateNodeProxy(maybeUnboxedContent)\n\t\t\t: maybeUnboxedContent;\n\t}\n\tswitch (field.schema.kind) {\n\t\tcase FieldKinds.required: {\n\t\t\tconst typedField = field as FlexTreeTypedField<\n\t\t\t\tFlexFieldSchema<typeof FieldKinds.required>\n\t\t\t>;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\tcase FieldKinds.optional: {\n\t\t\tconst typedField = field as FlexTreeTypedField<\n\t\t\t\tFlexFieldSchema<typeof FieldKinds.optional>\n\t\t\t>;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\t// TODO: Remove if/when 'FieldNode' is removed.\n\t\tcase FieldKinds.sequence: {\n\t\t\t// 'getProxyForNode' handles FieldNodes by unconditionally creating a array node proxy, making\n\t\t\t// this case unreachable as long as users follow the 'array recipe'.\n\t\t\tfail(\"'sequence' field is unexpected.\");\n\t\t}\n\t\tcase FieldKinds.identifier: {\n\t\t\t// Identifier fields are just value fields that hold strings\n\t\t\treturn (field as FlexTreeTypedField<FlexFieldSchema<typeof FieldKinds.required>>)\n\t\t\t\t.content as string;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(\"invalid field kind\");\n\t}\n}\n\nexport function getOrCreateNodeProxy(flexNode: FlexTreeNode): TreeNode | TreeValue {\n\tconst cachedProxy = tryGetProxy(flexNode);\n\tif (cachedProxy !== undefined) {\n\t\treturn cachedProxy;\n\t}\n\n\tconst schema = flexNode.schema;\n\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\tassert(classSchema !== undefined, 0x91b /* node without schema */);\n\tif (typeof classSchema === \"function\") {\n\t\tconst simpleSchema = classSchema as unknown as new (dummy: FlexTreeNode) => TreeNode;\n\t\treturn new simpleSchema(flexNode);\n\t} else {\n\t\treturn (classSchema as { create(data: FlexTreeNode): TreeNode }).create(flexNode);\n\t}\n}\n\n// #region Content insertion and proxy binding\n\n/** The path of a proxy, relative to the root of the content tree that the proxy belongs to */\ninterface RelativeProxyPath {\n\treadonly path: UpPath;\n\treadonly mapTreeNode: MapTreeNode;\n\treadonly proxy: TreeNode;\n}\n\n/** All {@link RelativeProxyPath}s that are under the given root path */\ninterface RootedProxyPaths {\n\treadonly rootPath: UpPath;\n\treadonly proxyPaths: RelativeProxyPath[];\n}\n\n/**\n * Records any proxies in the given content tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.\n * @remarks If the content tree contains any proxies, this function must be called just prior to inserting the content into the tree.\n * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.\n * The insertion of `content` must occur or else this function will cause memory leaks.\n * @param content - the tree of content to be inserted, of which any of its object/map/array nodes might be a proxy\n * @param anchors - the {@link AnchorSet} for the tree\n * @returns The content after having all proxies replaced inline with plain javascript objects.\n * See {@link extractFactoryContent} for more details.\n */\nexport function prepareContentForHydration(\n\tcontent: MapTree | readonly MapTree[] | undefined,\n\tforest: IForestSubscription,\n): void {\n\tif (isReadonlyArray(content)) {\n\t\treturn prepareArrayContentForHydration(content, forest);\n\t}\n\n\tif (content !== undefined) {\n\t\tconst proxies: RootedProxyPaths = {\n\t\t\trootPath: { parent: undefined, parentField: EmptyKey, parentIndex: 0 },\n\t\t\tproxyPaths: [],\n\t\t};\n\n\t\twalkMapTree(content, proxies.rootPath, (p, mapTreeNode, proxy) => {\n\t\t\tproxies.proxyPaths.push({ path: p, mapTreeNode, proxy });\n\t\t});\n\n\t\tbindProxies([proxies], forest);\n\t}\n}\n\nfunction prepareArrayContentForHydration(\n\tcontent: readonly MapTree[],\n\tforest: IForestSubscription,\n): void {\n\tconst proxies: RootedProxyPaths[] = [];\n\tfor (let i = 0; i < content.length; i++) {\n\t\tproxies.push({\n\t\t\trootPath: {\n\t\t\t\tparent: undefined,\n\t\t\t\tparentField: EmptyKey,\n\t\t\t\tparentIndex: 0,\n\t\t\t},\n\t\t\tproxyPaths: [],\n\t\t});\n\t\twalkMapTree(content[i], proxies[i].rootPath, (p, mapTreeNode, proxy) => {\n\t\t\tproxies[i].proxyPaths.push({ path: p, mapTreeNode, proxy });\n\t\t});\n\t}\n\n\tbindProxies(proxies, forest);\n}\n\nfunction walkMapTree(\n\tmapTree: MapTree,\n\tpath: UpPath,\n\tonVisitTreeNode: (path: UpPath, mapTreeNode: MapTreeNode, treeNode: TreeNode) => void,\n): void {\n\tconst mapTreeNode = tryGetMapTreeNode(mapTree);\n\tif (mapTreeNode !== undefined) {\n\t\tconst treeNode = tryGetProxy(mapTreeNode);\n\t\tif (treeNode !== undefined) {\n\t\t\tonVisitTreeNode(path, mapTreeNode, treeNode);\n\t\t}\n\t}\n\n\tfor (const [key, field] of mapTree.fields) {\n\t\tfor (let i = 0; i < field.length; i++) {\n\t\t\twalkMapTree(\n\t\t\t\tfield[i],\n\t\t\t\t{\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: key,\n\t\t\t\t\tparentIndex: i,\n\t\t\t\t},\n\t\t\t\tonVisitTreeNode,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction bindProxies(proxies: RootedProxyPaths[], forest: IForestSubscription): void {\n\t// Only subscribe to the event if there is at least one proxy tree to hydrate - this is not the case when inserting an empty array [].\n\tif (proxies.length > 0) {\n\t\t// Creating a new array emits one event per element in the array, so listen to the event once for each element\n\t\tlet i = 0;\n\t\tconst off = forest.on(\"afterRootFieldCreated\", (fieldKey) => {\n\t\t\t(proxies[i].rootPath as Mutable<UpPath>).parentField = fieldKey;\n\t\t\tfor (const { path, mapTreeNode, proxy } of proxies[i].proxyPaths) {\n\t\t\t\tconst anchorNode = anchorProxy(forest.anchors, path, proxy);\n\t\t\t\tmapTreeNode.forwardEvents({\n\t\t\t\t\ton<K extends keyof FlexTreeNodeEvents>(\n\t\t\t\t\t\teventName: K,\n\t\t\t\t\t\tlistener: FlexTreeNodeEvents[K],\n\t\t\t\t\t): Off {\n\t\t\t\t\t\tswitch (eventName) {\n\t\t\t\t\t\t\tcase \"nodeChanged\": {\n\t\t\t\t\t\t\t\treturn anchorNode.on(\"childrenChangedAfterBatch\", listener);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"treeChanged\": {\n\t\t\t\t\t\t\t\treturn anchorNode.on(\"subtreeChangedAfterBatch\", listener);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tfail(\"Unexpected event subscription\");\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (++i === proxies.length) {\n\t\t\t\toff();\n\t\t\t}\n\t\t});\n\t}\n}\n\n// #endregion Content insertion and proxy binding\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| ReadonlyMap<string, InsertableContent>\n\t| readonly InsertableContent[]\n\t| {\n\t\t\treadonly [P in string]?: InsertableContent;\n\t };\n\n/**\n * Content which can be inserted into a tree.\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n\n/**\n * Brand `copy` with the type (under {@link typeNameSymbol}) to avoid ambiguity when inferring types from this data.\n */\nexport function markContentType(typeName: TreeNodeSchemaIdentifier, copy: object): void {\n\tObject.defineProperty(copy, typeNameSymbol, { value: typeName });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactory.d.ts","sourceRoot":"","sources":["../../src/simple-tree/schemaFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"schemaFactory.d.ts","sourceRoot":"","sources":["../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AAC,MAAM,CAAC,CAS7E;IAED;;;;;;;;;;OAUG;IAEI,eAAe,CACrB,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,UAAU,CAAC,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,EACjF,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAelB;;;;;;OAMG;IAEI,cAAc,CACpB,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,UAAU,CAAC,oBAAoB,CAAC,EAC/C,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QAa1B;;;;;;;;;;WAUG;6BACkB,SAAS,iDAAiD,CAAC,CAAC,CAAC;;IAOrF;;;;;;OAMG;IAEI,YAAY,CAAC,IAAI,SAAS,KAAK,EAAE,KAAK,CAAC,CAAC,SAAS,UAAU,CAAC,oBAAoB,CAAC,EACvF,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC;QAcb;;;;;;;;;;WAUG;6BACkB,SACpB;YAAC,MAAM;YAAE,iDAAiD,CAAC,CAAC;SAAC,CAC7D;;CAMJ;AAED,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACpD,cAAc,EAAE,CAAC,EACjB,YAAY,EAAE,cAAc,GAAG,SAAS,cAAc,EAAE,GACtD,GAAG,CAAC,IAAI,MAAM,GAAG,CAkBnB"}
|
|
@@ -304,18 +304,7 @@ class SchemaFactory {
|
|
|
304
304
|
*/
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
306
306
|
arrayRecursive(name, allowedTypes) {
|
|
307
|
-
|
|
308
|
-
constructor(data) {
|
|
309
|
-
if ((0, index_js_1.isFlexTreeNode)(data)) {
|
|
310
|
-
// TODO: use something other than `any`
|
|
311
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
|
-
super(data);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
super(data);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
307
|
+
const RecursiveArray = this.namedArray(name, allowedTypes, true, false);
|
|
319
308
|
return RecursiveArray;
|
|
320
309
|
}
|
|
321
310
|
/**
|
|
@@ -327,18 +316,7 @@ class SchemaFactory {
|
|
|
327
316
|
*/
|
|
328
317
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
329
318
|
mapRecursive(name, allowedTypes) {
|
|
330
|
-
|
|
331
|
-
constructor(data) {
|
|
332
|
-
if ((0, index_js_1.isFlexTreeNode)(data)) {
|
|
333
|
-
// TODO: use something other than `any`
|
|
334
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
335
|
-
super(data);
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
super(new Map(data));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
319
|
+
const MapSchema = this.namedMap(name, allowedTypes, true, false);
|
|
342
320
|
return MapSchema;
|
|
343
321
|
}
|
|
344
322
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactory.js","sourceRoot":"","sources":["../../src/simple-tree/schemaFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAO9E,4DAMuC;AACvC,+CAI0B;AAE1B,2DAM6B;AAC7B,qDAc0B;AAC1B,iDAAiE;AACjE,qEAAuE;AACvE,mDAIyB;AACzB,6CAA2D;AAiB3D,2EAAsE;AACtE;;GAEG;AACH,SAAgB,eAAe,CAAC,KAAgB;IAC/C,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,SAAS;YACb,OAAO,iCAAa,CAAC;QACtB,KAAK,QAAQ;YACZ,OAAO,gCAAY,CAAC;QACrB,KAAK,QAAQ;YACZ,OAAO,gCAAY,CAAC;QACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,IAAI,KAAK,KAAK,IAAI,EAAE,CA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cAAc,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACP,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAU,EAAE;YAC5C,8DAA8D;YAC9D,IAAA,iBAAM,EAAC,CAAC,IAAA,iBAAM,EAAC,CAAC,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YACtD,OAAO,CAAC,CAAC,UAAU,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,mCAAmC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,8FAA8F;QAC9F,iDAAiD;QACjD,iIAAiI;QACjI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,cAAc,IAAI,KAAK,GAAG,CAAC;AACtC,CAAC;AArBD,wCAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n// Include this unused import to avoid TypeScript generating an inline import for IFluidHandle in the d.ts file\n// which degrades the API-Extractor report quality since API-Extractor can not tell the inline import is the same as the non-inline one.\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { IFluidHandle as _dummyImport } from \"@fluidframework/core-interfaces\";\n\nimport type { TreeValue } from \"../core/index.js\";\nimport {\n\ttype FlexTreeNode,\n\ttype NodeKeyManager,\n\ttype Unenforced,\n\tisFlexTreeNode,\n\tisLazy,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype RestrictiveReadonlyRecord,\n\tgetOrCreate,\n\tisReadonlyArray,\n} from \"../util/index.js\";\n\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"./leafNodeSchema.js\";\nimport {\n\tFieldKind,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n\tgetDefaultProvider,\n} from \"./schemaTypes.js\";\nimport { type TreeArrayNode, arraySchema } from \"./arrayNode.js\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype InsertableObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tobjectSchema,\n} from \"./objectNode.js\";\nimport { type TreeMapNode, mapSchema } from \"./mapNode.js\";\nimport type {\n\tFieldSchemaUnsafe,\n\t// Adding these unused imports makes the generated d.ts file produced by TypeScript stop breaking API-Extractor's rollup generation.\n\t// Without this import, TypeScript generates inline `import(\"../..\")` statements in the d.ts file,\n\t// which API-Extractor leaves as is when generating the rollup, leaving them pointing at the wrong directory.\n\t// API-Extractor issue: https://github.com/microsoft/rushstack/issues/4507\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tFieldHasDefaultUnsafe,\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tTreeObjectNodeUnsafe,\n} from \"./typesUnsafe.js\";\nimport { createFieldSchemaUnsafe } from \"./schemaFactoryRecursive.js\";\n/**\n * Gets the leaf domain schema compatible with a given {@link TreeValue}.\n */\nexport function schemaFromValue(value: TreeValue): TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"object\": {\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tassert(isFluidHandle(value), 0x87e /* invalid TreeValue */);\n\t\t\treturn handleSchema;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(value);\n\t}\n}\n\n/**\n * The name of a schema produced by {@link SchemaFactory}, including its optional scope prefix.\n *\n * @public\n */\nexport type ScopedSchemaName<\n\tTScope extends string | undefined,\n\tTName extends number | string,\n> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;\n// > = `${TScope extends undefined ? \"\" : `${TScope}.`}${TName}`;\n\n// TODO:\n// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.\n// API-Extractor requires such links to be qualified with the class, so it can't work.\n// Since linking the overload set as a whole also doesn't work, these have been made non-links for now.\n/**\n * Creates various types of {@link TreeNodeSchema|schema} for {@link TreeNode}s.\n *\n * @typeParam TScope - Scope added as a prefix to the name of every schema produced by this factory.\n * @typeParam TName - Type of names used to identify each schema produced in this factory.\n * Typically this is just `string` but it is also possible to use `string` or `number` based enums if you prefer to identify your types that way.\n *\n * @remarks\n * All schema produced by this factory get a {@link TreeNodeSchemaCore.identifier|unique identifier} by combining the {@link SchemaFactory.scope} with the schema's `Name`.\n * The `Name` part may be explicitly provided as a parameter, or inferred as a structural combination of the provided types.\n * The APIs which use this second approach, structural naming, also deduplicate all equivalent calls.\n * Therefor two calls to `array(allowedTypes)` with the same allowedTypes will return the same {@link TreeNodeSchema} instance.\n * On the other hand, two calls to `array(name, allowedTypes)` will always return different {@link TreeNodeSchema} instances\n * and it is an error to use both in the same tree (since their identifiers are not unique).\n *\n * Note:\n * POJO stands for Plain Old JavaScript Object.\n * This means an object that works like a `{}` style object literal.\n * In this case it means the prototype is `Object.prototype` and acts like a set of key value pairs (data, not methods).\n * The usage below generalizes this to include array and map like objects as well.\n *\n * There are two ways to use these APIs:\n * | | Customizable | POJO Emulation |\n * | ------------------- | ------------ |--------------- |\n * | Declaration | `class X extends schemaFactory.object(\"x\", {}) {}` | `const X = schemaFactory.object(\"x\", {}); type X = NodeFromSchema<typeof X>; `\n * | Allows adding \"local\" (non-persisted) members | Yes. Members (including methods) can be added to class. | No. Attempting to set non-field members will error. |\n * | Prototype | The user defined class | `Object.prototype`, `Map.prototype` or `Array.prototype` depending on node kind |\n * | Structurally named Schema | Not Supported | Supported |\n * | Explicitly named Objects | Supported | Supported |\n * | Explicitly named Maps and Arrays | Supported: Both declaration approaches can be used | Not Supported |\n * | node.js assert.deepEqual | Compares like class instances: equal to other nodes of the same type with the same content, including custom local fields. | Compares like plain objects: equal to plain JavaScript objects with the same fields, and other nodes with the same fields, even if the types are different. |\n * | IntelliSense | Shows and links to user defined class by name: `X` | Shows internal type generation logic: `object & TreeNode & ObjectFromSchemaRecord<{}> & WithType<\"test.x\">` |\n * | Recursion | Supported with special declaration patterns. | Unsupported: Generated d.ts files replace recursive references with `any`, breaking use of recursive schema across compilation boundaries |\n *\n * Note that while \"POJO Emulation\" nodes act a lot like POJO objects, they are not true POJO objects:\n *\n * - Adding new arbitrary fields will error, as well some cases of invalid edits.\n *\n * - They are implemented using proxies.\n *\n * - They have state that is not exposed via enumerable own properties, including a {@link TreeNodeSchema}.\n * This makes libraries like node.js `assert.deepEqual` fail to detect differences in type.\n *\n * - Assigning members has side effects (in this case editing the persisted/shared tree).\n *\n * - Not all operations implied by the prototype will work correctly: stick to the APIs explicitly declared in the TypeScript types.\n *\n * @privateRemarks\n * It's perfectly possible to make `POJO Emulation` mode (or even just hiding the prototype) selectable even when using the custom user class declaration syntax.\n * When doing this, it's still possible to make `instanceof` perform correctly.\n * Allowing (or banning) custom/out-of-schema properties on the class is also possible in both modes: it could be orthogonal.\n * Also for consistency, if keeping the current approach to detecting `POJO Emulation` mode it might make sense to make explicitly named Maps and Arrays do the detection the same as how object does it.\n *\n * @sealed @public\n */\nexport class SchemaFactory<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> {\n\tprivate readonly structuralTypes: Map<string, TreeNodeSchema> = new Map();\n\n\t/**\n\t * @param scope - Prefix appended to the identifiers of all {@link TreeNodeSchema} produced by this builder.\n\t * Use of [Reverse domain name notation](https://en.wikipedia.org/wiki/Reverse_domain_name_notation) or a UUIDv4 is recommended to avoid collisions.\n\t * You may opt out of using a scope by passing `undefined`, but note that this increases the risk of collisions.\n\t */\n\tpublic constructor(public readonly scope: TScope) {}\n\n\tprivate scoped<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly string = stringSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly number = numberSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\tpublic readonly boolean = booleanSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\tpublic readonly null = nullSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\tpublic readonly handle = handleSchema;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t */\n\tpublic object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\treturn objectSchema(this.scoped(name), fields, true);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @remarks\n\t * The unique identifier for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyMap = factory.map(factory.number);\n\t * type MyMap = NodeFromSchema<typeof MyMap>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myMap: factory.map(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * See note on array.\n\t */\n\tpublic map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, `Map<${string}>`>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic map<Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\tpublic map<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tstring,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tthis.namedMap(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as TreeNodeSchema,\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tstring,\n\t\t\t\tNodeKind.Map,\n\t\t\t\tTreeMapNode<T>,\n\t\t\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\t\t\ttrue,\n\t\t\t\tT\n\t\t\t>;\n\t\t}\n\t\treturn this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeMapNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t */\n\tprivate namedMap<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped(name),\n\t\t\tallowedTypes,\n\t\t\timplicitlyConstructable,\n\t\t\t// The current policy is customizable nodes don't get fake prototypes.\n\t\t\t!customizable,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @remarks\n\t * The identifier for this Array is defined as a function of the provided types.\n\t * It is still scoped to this SchemaFactory, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named arrays, other types in this schema builder should avoid names of the form `Array<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyArray = factory.array(factory.number);\n\t * type MyArray = NodeFromSchema<typeof MyArray>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myArray: factory.array(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural arrays by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its the type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls o this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic array<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, `Array<${string}>`>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, `Array<${string}>`>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.array(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic array<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\tpublic array<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, string>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Array\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedArray(fullName, nameOrAllowedTypes as T, false, true),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tScopedSchemaName<TScope, string>,\n\t\t\t\tNodeKind.Array,\n\t\t\t\tTreeArrayNode<T>,\n\t\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\t\ttrue,\n\t\t\t\tT\n\t\t\t>;\n\t\t}\n\t\treturn this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedArray<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\t\treturn arraySchema(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);\n\t}\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t */\n\tpublic optional<const T extends ImplicitAllowedTypes>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Optional, T> {\n\t\tconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {\n\t\t\treturn undefined;\n\t\t});\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t}\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t */\n\tpublic required<const T extends ImplicitAllowedTypes>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Required, T> {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Optional, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Required, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * A special field which holds a unique identifier for an object node.\n\t * @remarks\n\t * The value of this field, a \"node identifier\", uniquely identifies a node among all other nodes in the tree.\n\t * Node identifiers are strings, and can therefore be used as lookup keys in maps or written to a database.\n\t * When the node is constructed, the identifier field does not need to be populated.\n\t * The SharedTree will provide an identifier for the node automatically.\n\t * An identifier provided automatically by the SharedTree has the following properties:\n\t * - It is a UUID.\n\t * - It is compressed to a space-efficient representation when stored in the document.\n\t * - A compressed form of the identifier can be accessed at runtime via the `Tree.shortId()` API.\n\t * - It will error if read (and will not be present in the object's iterable properties) before the node has been inserted into the tree.\n\t *\n\t * However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).\n\t * In that case, it is up to the user to ensure that the identifier is unique within the current tree - no other node should have the same identifier at the same time.\n\t * If the identifier is not unique, it may be read, but may cause libraries or features which operate over node identifiers to misbehave.\n\t * User-supplied identifiers may be read immediately, even before insertion into the tree.\n\t *\n\t * A node may have more than one identifier field (though note that this precludes the use of the `Tree.shortId()` API).\n\t */\n\tpublic get identifier(): FieldSchema<FieldKind.Identifier, typeof this.string> {\n\t\tconst defaultIdentifierProvider: DefaultProvider = getDefaultProvider(\n\t\t\t(nodeKeyManager: NodeKeyManager) => {\n\t\t\t\treturn nodeKeyManager.stabilizeNodeKey(nodeKeyManager.generateLocalNodeKey());\n\t\t\t},\n\t\t);\n\t\treturn createFieldSchema(FieldKind.Identifier, this.string, {\n\t\t\tdefaultProvider: defaultIdentifierProvider,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactory.object} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.object} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t *\n\t * Additionally `ImplicitlyConstructable` is disabled (forcing use of constructor) to avoid\n\t * `error TS2589: Type instantiation is excessively deep and possibly infinite.`\n\t * which otherwise gets reported at sometimes incorrect source locations that vary based on incremental builds.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>,\n\t>(name: Name, t: T) {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.array` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.array` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t>(name: Name, allowedTypes: T) {\n\t\tclass RecursiveArray extends this.namedArray(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t) {\n\t\t\tpublic constructor(\n\t\t\t\tdata:\n\t\t\t\t\t| Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T & ImplicitAllowedTypes>>\n\t\t\t\t\t| FlexTreeNode,\n\t\t\t) {\n\t\t\t\tif (isFlexTreeNode(data)) {\n\t\t\t\t\t// TODO: use something other than `any`\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tsuper(data as any);\n\t\t\t\t} else {\n\t\t\t\t\tsuper(data);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn RecursiveArray as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.map` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.map` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t) {\n\t\tclass MapSchema extends this.namedMap(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t) {\n\t\t\tpublic constructor(\n\t\t\t\tdata:\n\t\t\t\t\t| Iterable<\n\t\t\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypes<T & ImplicitAllowedTypes>]\n\t\t\t\t\t >\n\t\t\t\t\t| FlexTreeNode,\n\t\t\t) {\n\t\t\t\tif (isFlexTreeNode(data)) {\n\t\t\t\t\t// TODO: use something other than `any`\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tsuper(data as any);\n\t\t\t\t} else {\n\t\t\t\t\tsuper(new Map(data));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn MapSchema as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: TreeNodeSchema | readonly TreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (!isReadonlyArray(allowedTypes)) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(!isLazy(t), 0x83d /* invalid type provided */);\n\t\t\treturn t.identifier;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result are also needed so that a single type name \"Any\" would not collide with the \"any\" case above.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schemaFactory.js","sourceRoot":"","sources":["../../src/simple-tree/schemaFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAO9E,4DAA6F;AAC7F,+CAI0B;AAE1B,2DAM6B;AAC7B,qDAc0B;AAC1B,iDAAiE;AACjE,qEAAuE;AACvE,mDAIyB;AACzB,6CAA2D;AAiB3D,2EAAsE;AACtE;;GAEG;AACH,SAAgB,eAAe,CAAC,KAAgB;IAC/C,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,SAAS;YACb,OAAO,iCAAa,CAAC;QACtB,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AAmC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,8FAA8F;QAC9F,iDAAiD;QACjD,iIAAiI;QACjI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,cAAc,IAAI,KAAK,GAAG,CAAC;AACtC,CAAC;AArBD,wCAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n// Include this unused import to avoid TypeScript generating an inline import for IFluidHandle in the d.ts file\n// which degrades the API-Extractor report quality since API-Extractor can not tell the inline import is the same as the non-inline one.\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { IFluidHandle as _dummyImport } from \"@fluidframework/core-interfaces\";\n\nimport type { TreeValue } from \"../core/index.js\";\nimport { type NodeKeyManager, type Unenforced, isLazy } from \"../feature-libraries/index.js\";\nimport {\n\ttype RestrictiveReadonlyRecord,\n\tgetOrCreate,\n\tisReadonlyArray,\n} from \"../util/index.js\";\n\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"./leafNodeSchema.js\";\nimport {\n\tFieldKind,\n\ttype FieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n\tgetDefaultProvider,\n} from \"./schemaTypes.js\";\nimport { type TreeArrayNode, arraySchema } from \"./arrayNode.js\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype InsertableObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tobjectSchema,\n} from \"./objectNode.js\";\nimport { type TreeMapNode, mapSchema } from \"./mapNode.js\";\nimport type {\n\tFieldSchemaUnsafe,\n\t// Adding these unused imports makes the generated d.ts file produced by TypeScript stop breaking API-Extractor's rollup generation.\n\t// Without this import, TypeScript generates inline `import(\"../..\")` statements in the d.ts file,\n\t// which API-Extractor leaves as is when generating the rollup, leaving them pointing at the wrong directory.\n\t// API-Extractor issue: https://github.com/microsoft/rushstack/issues/4507\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tFieldHasDefaultUnsafe,\n\t// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tTreeObjectNodeUnsafe,\n} from \"./typesUnsafe.js\";\nimport { createFieldSchemaUnsafe } from \"./schemaFactoryRecursive.js\";\n/**\n * Gets the leaf domain schema compatible with a given {@link TreeValue}.\n */\nexport function schemaFromValue(value: TreeValue): TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"object\": {\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tassert(isFluidHandle(value), 0x87e /* invalid TreeValue */);\n\t\t\treturn handleSchema;\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(value);\n\t}\n}\n\n/**\n * The name of a schema produced by {@link SchemaFactory}, including its optional scope prefix.\n *\n * @public\n */\nexport type ScopedSchemaName<\n\tTScope extends string | undefined,\n\tTName extends number | string,\n> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;\n// > = `${TScope extends undefined ? \"\" : `${TScope}.`}${TName}`;\n\n// TODO:\n// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.\n// API-Extractor requires such links to be qualified with the class, so it can't work.\n// Since linking the overload set as a whole also doesn't work, these have been made non-links for now.\n/**\n * Creates various types of {@link TreeNodeSchema|schema} for {@link TreeNode}s.\n *\n * @typeParam TScope - Scope added as a prefix to the name of every schema produced by this factory.\n * @typeParam TName - Type of names used to identify each schema produced in this factory.\n * Typically this is just `string` but it is also possible to use `string` or `number` based enums if you prefer to identify your types that way.\n *\n * @remarks\n * All schema produced by this factory get a {@link TreeNodeSchemaCore.identifier|unique identifier} by combining the {@link SchemaFactory.scope} with the schema's `Name`.\n * The `Name` part may be explicitly provided as a parameter, or inferred as a structural combination of the provided types.\n * The APIs which use this second approach, structural naming, also deduplicate all equivalent calls.\n * Therefor two calls to `array(allowedTypes)` with the same allowedTypes will return the same {@link TreeNodeSchema} instance.\n * On the other hand, two calls to `array(name, allowedTypes)` will always return different {@link TreeNodeSchema} instances\n * and it is an error to use both in the same tree (since their identifiers are not unique).\n *\n * Note:\n * POJO stands for Plain Old JavaScript Object.\n * This means an object that works like a `{}` style object literal.\n * In this case it means the prototype is `Object.prototype` and acts like a set of key value pairs (data, not methods).\n * The usage below generalizes this to include array and map like objects as well.\n *\n * There are two ways to use these APIs:\n * | | Customizable | POJO Emulation |\n * | ------------------- | ------------ |--------------- |\n * | Declaration | `class X extends schemaFactory.object(\"x\", {}) {}` | `const X = schemaFactory.object(\"x\", {}); type X = NodeFromSchema<typeof X>; `\n * | Allows adding \"local\" (non-persisted) members | Yes. Members (including methods) can be added to class. | No. Attempting to set non-field members will error. |\n * | Prototype | The user defined class | `Object.prototype`, `Map.prototype` or `Array.prototype` depending on node kind |\n * | Structurally named Schema | Not Supported | Supported |\n * | Explicitly named Objects | Supported | Supported |\n * | Explicitly named Maps and Arrays | Supported: Both declaration approaches can be used | Not Supported |\n * | node.js assert.deepEqual | Compares like class instances: equal to other nodes of the same type with the same content, including custom local fields. | Compares like plain objects: equal to plain JavaScript objects with the same fields, and other nodes with the same fields, even if the types are different. |\n * | IntelliSense | Shows and links to user defined class by name: `X` | Shows internal type generation logic: `object & TreeNode & ObjectFromSchemaRecord<{}> & WithType<\"test.x\">` |\n * | Recursion | Supported with special declaration patterns. | Unsupported: Generated d.ts files replace recursive references with `any`, breaking use of recursive schema across compilation boundaries |\n *\n * Note that while \"POJO Emulation\" nodes act a lot like POJO objects, they are not true POJO objects:\n *\n * - Adding new arbitrary fields will error, as well some cases of invalid edits.\n *\n * - They are implemented using proxies.\n *\n * - They have state that is not exposed via enumerable own properties, including a {@link TreeNodeSchema}.\n * This makes libraries like node.js `assert.deepEqual` fail to detect differences in type.\n *\n * - Assigning members has side effects (in this case editing the persisted/shared tree).\n *\n * - Not all operations implied by the prototype will work correctly: stick to the APIs explicitly declared in the TypeScript types.\n *\n * @privateRemarks\n * It's perfectly possible to make `POJO Emulation` mode (or even just hiding the prototype) selectable even when using the custom user class declaration syntax.\n * When doing this, it's still possible to make `instanceof` perform correctly.\n * Allowing (or banning) custom/out-of-schema properties on the class is also possible in both modes: it could be orthogonal.\n * Also for consistency, if keeping the current approach to detecting `POJO Emulation` mode it might make sense to make explicitly named Maps and Arrays do the detection the same as how object does it.\n *\n * @sealed @public\n */\nexport class SchemaFactory<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> {\n\tprivate readonly structuralTypes: Map<string, TreeNodeSchema> = new Map();\n\n\t/**\n\t * @param scope - Prefix appended to the identifiers of all {@link TreeNodeSchema} produced by this builder.\n\t * Use of [Reverse domain name notation](https://en.wikipedia.org/wiki/Reverse_domain_name_notation) or a UUIDv4 is recommended to avoid collisions.\n\t * You may opt out of using a scope by passing `undefined`, but note that this increases the risk of collisions.\n\t */\n\tpublic constructor(public readonly scope: TScope) {}\n\n\tprivate scoped<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `string`.\n\t *\n\t * @remarks\n\t * Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.\n\t *\n\t * These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.\n\t * JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly string = stringSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a JavaScript `number`.\n\t *\n\t * @remarks\n\t * The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:\n\t * - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).\n\t * - `-0` may be converted to `0` in some cases.\n\t *\n\t * These limitations match the limitations of JSON.\n\t * @privateRemarks\n\t * TODO:\n\t * We should be much more clear about what happens if you use problematic values.\n\t * We should validate and/or normalize them when inserting content.\n\t */\n\tpublic readonly number = numberSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding a boolean.\n\t */\n\tpublic readonly boolean = booleanSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for JavaScript `null`.\n\t *\n\t * @remarks\n\t * There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.\n\t * This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.\n\t * Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.\n\t */\n\tpublic readonly null = nullSchema;\n\n\t/**\n\t * {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.\n\t */\n\tpublic readonly handle = handleSchema;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t */\n\tpublic object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\treturn objectSchema(this.scoped(name), fields, true);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @remarks\n\t * The unique identifier for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyMap = factory.map(factory.number);\n\t * type MyMap = NodeFromSchema<typeof MyMap>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myMap: factory.map(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * See note on array.\n\t */\n\tpublic map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, `Map<${string}>`>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic map<Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\tpublic map<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tstring,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tthis.namedMap(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as TreeNodeSchema,\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tstring,\n\t\t\t\tNodeKind.Map,\n\t\t\t\tTreeMapNode<T>,\n\t\t\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\t\t\ttrue,\n\t\t\t\tT\n\t\t\t>;\n\t\t}\n\t\treturn this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeMapNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t */\n\tprivate namedMap<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\t\treturn mapSchema(\n\t\t\tthis.scoped(name),\n\t\t\tallowedTypes,\n\t\t\timplicitlyConstructable,\n\t\t\t// The current policy is customizable nodes don't get fake prototypes.\n\t\t\t!customizable,\n\t\t);\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @remarks\n\t * The identifier for this Array is defined as a function of the provided types.\n\t * It is still scoped to this SchemaFactory, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named arrays, other types in this schema builder should avoid names of the form `Array<${string}>`.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyArray = factory.array(factory.number);\n\t * type MyArray = NodeFromSchema<typeof MyArray>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", {myArray: factory.array(factory.number)});\n\t * ```\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural arrays by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its the type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls o this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic array<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, `Array<${string}>`>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, `Array<${string}>`>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.array(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic array<const Name extends TName, const T extends ImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t>;\n\n\tpublic array<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): TreeNodeSchema<\n\t\tScopedSchemaName<TScope, string>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Array\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedArray(fullName, nameOrAllowedTypes as T, false, true),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\tScopedSchemaName<TScope, string>,\n\t\t\t\tNodeKind.Array,\n\t\t\t\tTreeArrayNode<T>,\n\t\t\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\t\t\ttrue,\n\t\t\t\tT\n\t\t\t>;\n\t\t}\n\t\treturn this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true);\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `array` which takes a name instead.\n\t * This is only public to work around a compiler limitation.\n\t */\n\tprivate namedArray<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\tImplicitlyConstructable,\n\t\tT\n\t> {\n\t\treturn arraySchema(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);\n\t}\n\n\t/**\n\t * Make a field optional instead of the default, which is required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t */\n\tpublic optional<const T extends ImplicitAllowedTypes>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Optional, T> {\n\t\tconst defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {\n\t\t\treturn undefined;\n\t\t});\n\t\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\t\tdefaultProvider: defaultOptionalProvider,\n\t\t\t...props,\n\t\t});\n\t}\n\n\t/**\n\t * Make a field explicitly required.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @remarks\n\t * Fields are required by default, but this API can be used to make the required nature explicit in the schema,\n\t * and allows associating custom {@link FieldProps | properties} with the field.\n\t */\n\tpublic required<const T extends ImplicitAllowedTypes>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchema<FieldKind.Required, T> {\n\t\treturn createFieldSchema(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.optional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic optionalRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Optional, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Optional, t, props);\n\t}\n\n\t/**\n\t * {@link SchemaFactory.required} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic requiredRecursive<const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tt: T,\n\t\tprops?: Omit<FieldProps, \"defaultProvider\">,\n\t): FieldSchemaUnsafe<FieldKind.Required, T> {\n\t\treturn createFieldSchemaUnsafe(FieldKind.Required, t, props);\n\t}\n\n\t/**\n\t * A special field which holds a unique identifier for an object node.\n\t * @remarks\n\t * The value of this field, a \"node identifier\", uniquely identifies a node among all other nodes in the tree.\n\t * Node identifiers are strings, and can therefore be used as lookup keys in maps or written to a database.\n\t * When the node is constructed, the identifier field does not need to be populated.\n\t * The SharedTree will provide an identifier for the node automatically.\n\t * An identifier provided automatically by the SharedTree has the following properties:\n\t * - It is a UUID.\n\t * - It is compressed to a space-efficient representation when stored in the document.\n\t * - A compressed form of the identifier can be accessed at runtime via the `Tree.shortId()` API.\n\t * - It will error if read (and will not be present in the object's iterable properties) before the node has been inserted into the tree.\n\t *\n\t * However, a user may alternatively supply their own string as the identifier if desired (for example, if importing identifiers from another system).\n\t * In that case, it is up to the user to ensure that the identifier is unique within the current tree - no other node should have the same identifier at the same time.\n\t * If the identifier is not unique, it may be read, but may cause libraries or features which operate over node identifiers to misbehave.\n\t * User-supplied identifiers may be read immediately, even before insertion into the tree.\n\t *\n\t * A node may have more than one identifier field (though note that this precludes the use of the `Tree.shortId()` API).\n\t */\n\tpublic get identifier(): FieldSchema<FieldKind.Identifier, typeof this.string> {\n\t\tconst defaultIdentifierProvider: DefaultProvider = getDefaultProvider(\n\t\t\t(nodeKeyManager: NodeKeyManager) => {\n\t\t\t\treturn nodeKeyManager.stabilizeNodeKey(nodeKeyManager.generateLocalNodeKey());\n\t\t\t},\n\t\t);\n\t\treturn createFieldSchema(FieldKind.Identifier, this.string, {\n\t\t\tdefaultProvider: defaultIdentifierProvider,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactory.object} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaFactory.object} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t *\n\t * Additionally `ImplicitlyConstructable` is disabled (forcing use of constructor) to avoid\n\t * `error TS2589: Type instantiation is excessively deep and possibly infinite.`\n\t * which otherwise gets reported at sometimes incorrect source locations that vary based on incremental builds.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>,\n\t>(name: Name, t: T) {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveReadonlyRecord<string, ImplicitFieldSchema>,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.array` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.array` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t>(name: Name, allowedTypes: T) {\n\t\tconst RecursiveArray = this.namedArray(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t);\n\n\t\treturn RecursiveArray as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n\n\t/**\n\t * `SchemaFactory.map` except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.map` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t) {\n\t\tconst MapSchema = this.namedMap(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\ttrue,\n\t\t\tfalse,\n\t\t);\n\n\t\treturn MapSchema as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>>,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * Iterator for the iterable of content for this node.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Wrapping the constructor parameter for recursive arrays and maps in an inlined object type avoids (for unknown reasons)\n\t\t\t\t * the following compile error when declaring the recursive schema:\n\t\t\t\t * `Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.`\n\t\t\t\t * To benefit from this without impacting the API, the definition of `Iterable` has been inlined as such an object.\n\t\t\t\t *\n\t\t\t\t * If this workaround is kept, ideally this comment would be deduplicated with the other instance of it.\n\t\t\t\t * Unfortunately attempts to do this failed to avoid the compile error this was introduced to solve.\n\t\t\t\t */\n\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT\n\t\t>;\n\t}\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: TreeNodeSchema | readonly TreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (!isReadonlyArray(allowedTypes)) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(!isLazy(t), 0x83d /* invalid type provided */);\n\t\t\treturn t.identifier;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result are also needed so that a single type name \"Any\" would not collide with the \"any\" case above.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n"]}
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ITreeCursorSynchronous, TreeNodeSchemaIdentifier, SchemaAndPolicy } from "../core/index.js";
|
|
6
6
|
import { type FlexAllowedTypes, FlexFieldSchema, type FlexTreeNodeSchema, type FlexTreeSchema, type NodeKeyManager } from "../feature-libraries/index.js";
|
|
7
|
-
import type { TreeContent } from "../shared-tree/index.js";
|
|
8
7
|
import { type ImplicitAllowedTypes, type ImplicitFieldSchema, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeNodeSchema } from "./schemaTypes.js";
|
|
9
|
-
import { TreeConfiguration, type TreeViewConfiguration } from "./tree.js";
|
|
10
8
|
/**
|
|
11
9
|
* Returns a cursor (in nodes mode) for the root node.
|
|
12
10
|
*
|
|
@@ -16,19 +14,6 @@ import { TreeConfiguration, type TreeViewConfiguration } from "./tree.js";
|
|
|
16
14
|
* For now though, this is the only case that's needed, and we do have the data to make it work, so this is fine.
|
|
17
15
|
*/
|
|
18
16
|
export declare function cursorFromUnhydratedRoot(schema: ImplicitFieldSchema, tree: InsertableTreeNodeFromImplicitAllowedTypes, nodeKeyManager: NodeKeyManager, schemaValidationPolicy?: SchemaAndPolicy | undefined): ITreeCursorSynchronous;
|
|
19
|
-
/**
|
|
20
|
-
* Generates a configuration object (schema + initial tree) for a FlexTree.
|
|
21
|
-
* @param config - Configuration for how to {@link ITree.schematize|schematize} a tree.
|
|
22
|
-
* @param nodeKeyManager - See {@link NodeKeyManager}.
|
|
23
|
-
* @param schemaValidationPolicy - Stored schema and policy for the tree. If the policy specifies
|
|
24
|
-
* `{@link SchemaPolicy.validateSchema} === true`, new content inserted into the tree will be validated using this
|
|
25
|
-
* object.
|
|
26
|
-
* @returns A configuration object for a FlexTree.
|
|
27
|
-
*
|
|
28
|
-
* @privateremarks
|
|
29
|
-
* I wrote these docs without a ton of context, they can probably be improved.
|
|
30
|
-
*/
|
|
31
|
-
export declare function toFlexConfig(config: TreeViewConfiguration | TreeConfiguration, nodeKeyManager: NodeKeyManager, schemaValidationPolicy?: SchemaAndPolicy | undefined): TreeContent;
|
|
32
17
|
interface SchemaInfo {
|
|
33
18
|
toFlex: () => FlexTreeNodeSchema;
|
|
34
19
|
original: TreeNodeSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toFlexSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"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