@fluidframework/tree 2.32.0 → 2.33.0-333010

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.
Files changed (78) hide show
  1. package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
  2. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  3. package/dist/feature-libraries/flex-tree/context.js +4 -0
  4. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  5. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  6. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  7. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  8. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  9. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  10. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  11. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.d.ts.map +1 -1
  14. package/dist/packageVersion.js +1 -1
  15. package/dist/packageVersion.js.map +1 -1
  16. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  17. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  18. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  19. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  20. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  21. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  22. package/dist/simple-tree/core/treeNodeKernel.js +39 -24
  23. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  24. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  25. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  26. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  27. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  28. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  29. package/dist/simple-tree/objectNode.js +3 -0
  30. package/dist/simple-tree/objectNode.js.map +1 -1
  31. package/dist/tableSchema.d.ts +26 -12
  32. package/dist/tableSchema.d.ts.map +1 -1
  33. package/dist/tableSchema.js +17 -13
  34. package/dist/tableSchema.js.map +1 -1
  35. package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
  36. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  37. package/lib/feature-libraries/flex-tree/context.js +5 -1
  38. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  39. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  40. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  41. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  42. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  43. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  44. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  45. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  46. package/lib/packageVersion.d.ts +1 -1
  47. package/lib/packageVersion.d.ts.map +1 -1
  48. package/lib/packageVersion.js +1 -1
  49. package/lib/packageVersion.js.map +1 -1
  50. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  51. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  52. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  53. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  54. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  55. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  56. package/lib/simple-tree/core/treeNodeKernel.js +40 -25
  57. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  58. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  59. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  60. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
  61. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  62. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  63. package/lib/simple-tree/objectNode.js +4 -1
  64. package/lib/simple-tree/objectNode.js.map +1 -1
  65. package/lib/tableSchema.d.ts +26 -12
  66. package/lib/tableSchema.d.ts.map +1 -1
  67. package/lib/tableSchema.js +17 -13
  68. package/lib/tableSchema.js.map +1 -1
  69. package/package.json +20 -20
  70. package/src/feature-libraries/flex-tree/context.ts +11 -1
  71. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  72. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  73. package/src/packageVersion.ts +1 -1
  74. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  75. package/src/simple-tree/core/treeNodeKernel.ts +46 -28
  76. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  77. package/src/simple-tree/objectNode.ts +4 -2
  78. package/src/tableSchema.ts +80 -21
@@ -29,6 +29,10 @@ export interface FlexTreeContext {
29
29
  * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.
30
30
  */
31
31
  isHydrated(): this is FlexTreeHydratedContext;
32
+ /**
33
+ * If true, none of the nodes in this context can be used.
34
+ */
35
+ isDisposed(): boolean;
32
36
  }
33
37
  /**
34
38
  * A common context of a "forest" of FlexTrees.
@@ -71,6 +75,7 @@ export declare class Context implements FlexTreeHydratedContext, IDisposable {
71
75
  */
72
76
  constructor(schemaPolicy: SchemaPolicy, checkout: ITreeCheckout, nodeKeyManager: NodeIdentifierManager);
73
77
  isHydrated(): this is FlexTreeHydratedContext;
78
+ isDisposed(): boolean;
74
79
  get schema(): TreeStoredSchema;
75
80
  /**
76
81
  * Called before editing.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"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ED,IAAW,MAAM,IAAI,UAAU,CAAC,YAAY,CAAC,CAE5C;CACD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,qBAAqB,GACnC,OAAO,CAET"}
@@ -41,8 +41,12 @@ class Context {
41
41
  this.checkout.forest.anchors.slots.set(exports.ContextSlot, this);
42
42
  }
43
43
  isHydrated() {
44
+ (0, internal_1.debugAssert)(() => !this.disposed || "Disposed");
44
45
  return true;
45
46
  }
47
+ isDisposed() {
48
+ return this.disposed;
49
+ }
46
50
  get schema() {
47
51
  return this.checkout.storedSchema;
48
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAM6B;AAE7B,kDAAsE;AAKtE,iDAA2C;AA8C3C;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAA,qBAAU,GAAW,CAAC;AAEjD;;;;GAIG;AACH,MAAa,OAAO;IAOnB;;;;OAIG;IACH,YACiB,YAA0B,EAC1B,QAAuB,EACvB,cAAqC;QAFrC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAAe;QACvB,mBAAc,GAAd,cAAc,CAAuB;QAdtC,gBAAW,GAAoB,IAAI,GAAG,EAAE,CAAC;QACzC,gBAAW,GAAoB,IAAI,GAAG,EAAE,CAAC;QAGjD,aAAQ,GAAG,KAAK,CAAC;QAYxB,IAAI,CAAC,eAAe,GAAG;YACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;gBACnD,IAAI,CAAC,cAAc,EAAE,CAAC;YACvB,CAAC,CAAC;SACF,CAAC;QAEF,IAAA,iBAAM,EACL,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,C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AC;IAED;;;;;OAKG;IACI,KAAK;QACX,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,CAAC,wBAAa,CAAC,EAAE,CAAC;QACzB,CAAC;QACD,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAChF,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACjF,CAAC;IAED,IAAW,IAAI;QACd,IAAA,iBAAM,EAAC,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAA,8BAAmB,EAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,IAAA,wBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;CACD;AAzFD,0BAyFC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC7B,MAAoB,EACpB,QAAuB,EACvB,cAAqC;IAErC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAND,wCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ForestEvents,\n\ttype SchemaPolicy,\n\ttype TreeStoredSchema,\n\tanchorSlot,\n\tmoveToDetachedField,\n} from \"../../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { type IDisposable, disposeSymbol } from \"../../util/index.js\";\nimport type { NodeIdentifierManager } from \"../node-identifier/index.js\";\n\nimport type { FlexTreeField } from \"./flexTreeTypes.js\";\nimport type { LazyEntity } from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\nimport type { ITreeCheckout } from \"../../shared-tree/index.js\";\n\n/**\n * Context for FlexTrees.\n */\nexport interface FlexTreeContext {\n\t/**\n\t * Schema used within this context.\n\t * All data must conform to these schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\n\t/**\n\t * SchemaPolicy used within this context.\n\t */\n\treadonly schemaPolicy: SchemaPolicy;\n\n\t/**\n\t * If true, this context is the canonical context instance for a given view,\n\t * and its schema include all schema from the document.\n\t *\n\t * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.\n\t */\n\tisHydrated(): this is FlexTreeHydratedContext;\n}\n\n/**\n * A common context of a \"forest\" of FlexTrees.\n * It handles group operations like transforming cursors into anchors for edits.\n */\nexport interface FlexTreeHydratedContext extends FlexTreeContext {\n\treadonly events: Listenable<ForestEvents>;\n\t/**\n\t * Gets the root field of the tree.\n\t */\n\tget root(): FlexTreeField;\n\n\treadonly nodeKeyManager: NodeIdentifierManager;\n\n\t/**\n\t * The checkout object associated with this context.\n\t */\n\treadonly checkout: ITreeCheckout;\n}\n\n/**\n * Creating multiple flex tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.\n * This slot is used to detect if one already exists and error if creating a second.\n */\nexport const ContextSlot = anchorSlot<Context>();\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class Context implements FlexTreeHydratedContext, IDisposable {\n\tpublic readonly withCursors: Set<LazyEntity> = new Set();\n\tpublic readonly withAnchors: Set<LazyEntity> = new Set();\n\n\tprivate readonly eventUnregister: (() => void)[];\n\tprivate disposed = false;\n\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t * @param checkout - The checkout.\n\t * @param nodeKeyManager - An object which handles node key generation and conversion\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly checkout: ITreeCheckout,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t) {\n\t\tthis.eventUnregister = [\n\t\t\tthis.checkout.forest.events.on(\"beforeChange\", () => {\n\t\t\t\tthis.prepareForEdit();\n\t\t\t}),\n\t\t];\n\n\t\tassert(\n\t\t\t!this.checkout.forest.anchors.slots.has(ContextSlot),\n\t\t\t0x92b /* Cannot create second flex-tree from checkout */,\n\t\t);\n\t\tthis.checkout.forest.anchors.slots.set(ContextSlot, this);\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn true;\n\t}\n\n\tpublic get schema(): TreeStoredSchema {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\t/**\n\t * Called before editing.\n\t * Clears all cursors so editing can proceed.\n\t */\n\tprivate prepareForEdit(): void {\n\t\tassert(this.disposed === false, 0x802 /* use after dispose */);\n\t\tfor (const target of this.withCursors) {\n\t\t\ttarget.prepareForEdit();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x773 /* prepareForEdit should remove all cursors */);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tassert(this.disposed === false, 0x803 /* double dispose */);\n\t\tthis.disposed = true;\n\t\tthis.clear();\n\t\tfor (const unregister of this.eventUnregister) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.eventUnregister.length = 0;\n\n\t\tconst deleted = this.checkout.forest.anchors.slots.delete(ContextSlot);\n\t\tassert(deleted, 0x8c4 /* unexpected dispose */);\n\t}\n\n\t/**\n\t * Release any cursors and anchors held by tree entities created in this context.\n\t * Ensures the cashed references to those entities on the Anchors are also cleared.\n\t * The tree entities are invalid to use after this, but the context may still be used\n\t * to create new trees starting from the root.\n\t */\n\tpublic clear(): void {\n\t\tfor (const target of this.withAnchors) {\n\t\t\ttarget[disposeSymbol]();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x774 /* free should remove all cursors */);\n\t\tassert(this.withAnchors.size === 0, 0x775 /* free should remove all anchors */);\n\t}\n\n\tpublic get root(): FlexTreeField {\n\t\tassert(this.disposed === false, 0x804 /* use after dispose */);\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"root\");\n\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\tconst field = makeField(this, this.schema.rootFieldSchema.kind, cursor);\n\t\tcursor.free();\n\t\treturn field;\n\t}\n\n\tpublic get events(): Listenable<ForestEvents> {\n\t\treturn this.checkout.forest.events;\n\t}\n}\n\n/**\n * A simple API for a Forest to interact with the tree.\n *\n * @param forest - the Forest\n * @param editor - an editor that makes changes to the forest.\n * @param nodeKeyManager - an object which handles node key generation and conversion.\n * @returns {@link FlexTreeContext} which is used to manage the cursors and anchors within the FlexTrees:\n * This is necessary for supporting using this tree across edits to the forest, and not leaking memory.\n */\nexport function getTreeContext(\n\tschema: SchemaPolicy,\n\tcheckout: ITreeCheckout,\n\tnodeKeyManager: NodeIdentifierManager,\n): Context {\n\treturn new Context(schema, checkout, nodeKeyManager);\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0E;AAE1E,kDAM6B;AAE7B,kDAAsE;AAKtE,iDAA2C;AAmD3C;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAA,qBAAU,GAAW,CAAC;AAEjD;;;;GAIG;AACH,MAAa,OAAO;IAOnB;;;;OAIG;IACH,YACiB,YAA0B,EAC1B,QAAuB,EACvB,cAAqC;QAFrC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA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K,GAAG,IAAA,wBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;CACD;AA9FD,0BA8FC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC7B,MAAoB,EACpB,QAAuB,EACvB,cAAqC;IAErC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAND,wCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ForestEvents,\n\ttype SchemaPolicy,\n\ttype TreeStoredSchema,\n\tanchorSlot,\n\tmoveToDetachedField,\n} from \"../../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { type IDisposable, disposeSymbol } from \"../../util/index.js\";\nimport type { NodeIdentifierManager } from \"../node-identifier/index.js\";\n\nimport type { FlexTreeField } from \"./flexTreeTypes.js\";\nimport type { LazyEntity } from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\nimport type { ITreeCheckout } from \"../../shared-tree/index.js\";\n\n/**\n * Context for FlexTrees.\n */\nexport interface FlexTreeContext {\n\t/**\n\t * Schema used within this context.\n\t * All data must conform to these schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\n\t/**\n\t * SchemaPolicy used within this context.\n\t */\n\treadonly schemaPolicy: SchemaPolicy;\n\n\t/**\n\t * If true, this context is the canonical context instance for a given view,\n\t * and its schema include all schema from the document.\n\t *\n\t * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.\n\t */\n\tisHydrated(): this is FlexTreeHydratedContext;\n\n\t/**\n\t * If true, none of the nodes in this context can be used.\n\t */\n\tisDisposed(): boolean;\n}\n\n/**\n * A common context of a \"forest\" of FlexTrees.\n * It handles group operations like transforming cursors into anchors for edits.\n */\nexport interface FlexTreeHydratedContext extends FlexTreeContext {\n\treadonly events: Listenable<ForestEvents>;\n\t/**\n\t * Gets the root field of the tree.\n\t */\n\tget root(): FlexTreeField;\n\n\treadonly nodeKeyManager: NodeIdentifierManager;\n\n\t/**\n\t * The checkout object associated with this context.\n\t */\n\treadonly checkout: ITreeCheckout;\n}\n\n/**\n * Creating multiple flex tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.\n * This slot is used to detect if one already exists and error if creating a second.\n */\nexport const ContextSlot = anchorSlot<Context>();\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class Context implements FlexTreeHydratedContext, IDisposable {\n\tpublic readonly withCursors: Set<LazyEntity> = new Set();\n\tpublic readonly withAnchors: Set<LazyEntity> = new Set();\n\n\tprivate readonly eventUnregister: (() => void)[];\n\tprivate disposed = false;\n\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t * @param checkout - The checkout.\n\t * @param nodeKeyManager - An object which handles node key generation and conversion\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly checkout: ITreeCheckout,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t) {\n\t\tthis.eventUnregister = [\n\t\t\tthis.checkout.forest.events.on(\"beforeChange\", () => {\n\t\t\t\tthis.prepareForEdit();\n\t\t\t}),\n\t\t];\n\n\t\tassert(\n\t\t\t!this.checkout.forest.anchors.slots.has(ContextSlot),\n\t\t\t0x92b /* Cannot create second flex-tree from checkout */,\n\t\t);\n\t\tthis.checkout.forest.anchors.slots.set(ContextSlot, this);\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\tdebugAssert(() => !this.disposed || \"Disposed\");\n\t\treturn true;\n\t}\n\n\tpublic isDisposed(): boolean {\n\t\treturn this.disposed;\n\t}\n\n\tpublic get schema(): TreeStoredSchema {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\t/**\n\t * Called before editing.\n\t * Clears all cursors so editing can proceed.\n\t */\n\tprivate prepareForEdit(): void {\n\t\tassert(this.disposed === false, 0x802 /* use after dispose */);\n\t\tfor (const target of this.withCursors) {\n\t\t\ttarget.prepareForEdit();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x773 /* prepareForEdit should remove all cursors */);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tassert(this.disposed === false, 0x803 /* double dispose */);\n\t\tthis.disposed = true;\n\t\tthis.clear();\n\t\tfor (const unregister of this.eventUnregister) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.eventUnregister.length = 0;\n\n\t\tconst deleted = this.checkout.forest.anchors.slots.delete(ContextSlot);\n\t\tassert(deleted, 0x8c4 /* unexpected dispose */);\n\t}\n\n\t/**\n\t * Release any cursors and anchors held by tree entities created in this context.\n\t * Ensures the cashed references to those entities on the Anchors are also cleared.\n\t * The tree entities are invalid to use after this, but the context may still be used\n\t * to create new trees starting from the root.\n\t */\n\tpublic clear(): void {\n\t\tfor (const target of this.withAnchors) {\n\t\t\ttarget[disposeSymbol]();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x774 /* free should remove all cursors */);\n\t\tassert(this.withAnchors.size === 0, 0x775 /* free should remove all anchors */);\n\t}\n\n\tpublic get root(): FlexTreeField {\n\t\tassert(this.disposed === false, 0x804 /* use after dispose */);\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"root\");\n\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\tconst field = makeField(this, this.schema.rootFieldSchema.kind, cursor);\n\t\tcursor.free();\n\t\treturn field;\n\t}\n\n\tpublic get events(): Listenable<ForestEvents> {\n\t\treturn this.checkout.forest.events;\n\t}\n}\n\n/**\n * A simple API for a Forest to interact with the tree.\n *\n * @param forest - the Forest\n * @param editor - an editor that makes changes to the forest.\n * @param nodeKeyManager - an object which handles node key generation and conversion.\n * @returns {@link FlexTreeContext} which is used to manage the cursors and anchors within the FlexTrees:\n * This is necessary for supporting using this tree across edits to the forest, and not leaking memory.\n */\nexport function getTreeContext(\n\tschema: SchemaPolicy,\n\tcheckout: ITreeCheckout,\n\tnodeKeyManager: NodeIdentifierManager,\n): Context {\n\treturn new Context(schema, checkout, nodeKeyManager);\n}\n"]}
@@ -62,6 +62,14 @@ export declare enum TreeStatus {
62
62
  Removed = 1,
63
63
  /**
64
64
  * Is removed and cannot be added back to the original document tree.
65
+ * @remarks
66
+ * Nodes can enter this state for multiple reasons:
67
+ * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.
68
+ * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.
69
+ * @privateRemarks
70
+ * There was planned work (AB#17948) to make the first reason a node could become "Deleted" impossible,
71
+ * at least as an opt in feature,
72
+ * by lifetime extending all nodes which are still possible to reach automatically.
65
73
  */
66
74
  Deleted = 2,
67
75
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"flexTreeTypes.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC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
45
45
  TreeStatus[TreeStatus["Removed"] = 1] = "Removed";
46
46
  /**
47
47
  * Is removed and cannot be added back to the original document tree.
48
+ * @remarks
49
+ * Nodes can enter this state for multiple reasons:
50
+ * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.
51
+ * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.
52
+ * @privateRemarks
53
+ * There was planned work (AB#17948) to make the first reason a node could become "Deleted" impossible,
54
+ * at least as an opt in feature,
55
+ * by lifetime extending all nodes which are still possible to reach automatically.
48
56
  */
49
57
  TreeStatus[TreeStatus["Deleted"] = 2] = "Deleted";
50
58
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAU6B;AAW7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAgB,CAAC;AAEvD;;GAEG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAS,gBAAgB,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,sBAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAgB,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAFD,wCAEC;AAED;GACG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AA6BD;;;GAGG;AACH,IAAY,UAkCX;AAlCD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,yCAAO,CAAA;AACR,CAAC,EAlCW,UAAU,0BAAV,UAAU,QAkCrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NormalizedFieldUpPath,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nfunction isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * A common context of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t * @remarks\n\t * See also {@link Unhydrated}.\n\t *\n\t * Nodes in the new state have some limitations:\n\t *\n\t * - Events are not currently triggered for changes. Fixes for this are planned.\n\t *\n\t * - Reading identifiers from nodes which were left unspecified (defaulted) when creating the tree will error.\n\t * This is because allocating unique identifiers in a compressible manner requires knowing which tree the nodes will be inserted into.\n\t *\n\t * - Transactions do not work: transactions apply to a single {@link TreeView}, and `New` nodes are not part of one.\n\t *\n\t * - `Tree.shortId` (when the identifier was explicitly specified and thus works at all) will just return the full identifier as a string,\n\t * but might return a compressed form as a number once hydrated.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n * @remarks\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n\n\t/**\n\t * Returns an iterable of keys for non-empty fields.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TreeNodeSchemaIdentifier;\n\n\t/**\n\t * Get a cursor for the underlying data.\n\t * @remarks\n\t * This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.\n\t * Must not be held onto across edits or any other tree API use.\n\t */\n\tborrowCursor(): ITreeCursorSynchronous;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): NormalizedFieldUpPath;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: FieldKindIdentifier;\n}\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField extends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnknownUnboxed | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<Kind extends FlexFieldKind> =\n\tKind extends typeof FieldKinds.sequence\n\t\t? FlexTreeSequenceField\n\t\t: Kind extends typeof FieldKinds.required\n\t\t\t? FlexTreeRequiredField\n\t\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t\t? FlexTreeOptionalField\n\t\t\t\t: FlexTreeField;\n\n// #endregion\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n"]}
1
+ {"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAU6B;AAW7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAgB,CAAC;AAEvD;;GAEG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAS,gBAAgB,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,sBAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAgB,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAFD,wCAEC;AAED;GACG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AA6BD;;;GAGG;AACH,IAAY,UA0CX;AA1CD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;OAUG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,yCAAO,CAAA;AACR,CAAC,EA1CW,UAAU,0BAAV,UAAU,QA0CrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NormalizedFieldUpPath,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nfunction isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * A common context of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t * @remarks\n\t * Nodes can enter this state for multiple reasons:\n\t * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.\n\t * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.\n\t * @privateRemarks\n\t * There was planned work (AB#17948) to make the first reason a node could become \"Deleted\" impossible,\n\t * at least as an opt in feature,\n\t * by lifetime extending all nodes which are still possible to reach automatically.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t * @remarks\n\t * See also {@link Unhydrated}.\n\t *\n\t * Nodes in the new state have some limitations:\n\t *\n\t * - Events are not currently triggered for changes. Fixes for this are planned.\n\t *\n\t * - Reading identifiers from nodes which were left unspecified (defaulted) when creating the tree will error.\n\t * This is because allocating unique identifiers in a compressible manner requires knowing which tree the nodes will be inserted into.\n\t *\n\t * - Transactions do not work: transactions apply to a single {@link TreeView}, and `New` nodes are not part of one.\n\t *\n\t * - `Tree.shortId` (when the identifier was explicitly specified and thus works at all) will just return the full identifier as a string,\n\t * but might return a compressed form as a number once hydrated.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n * @remarks\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n\n\t/**\n\t * Returns an iterable of keys for non-empty fields.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TreeNodeSchemaIdentifier;\n\n\t/**\n\t * Get a cursor for the underlying data.\n\t * @remarks\n\t * This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.\n\t * Must not be held onto across edits or any other tree API use.\n\t */\n\tborrowCursor(): ITreeCursorSynchronous;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): NormalizedFieldUpPath;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: FieldKindIdentifier;\n}\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField extends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnknownUnboxed | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<Kind extends FlexFieldKind> =\n\tKind extends typeof FieldKinds.sequence\n\t\t? FlexTreeSequenceField\n\t\t: Kind extends typeof FieldKinds.required\n\t\t\t? FlexTreeRequiredField\n\t\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t\t? FlexTreeOptionalField\n\t\t\t\t: FlexTreeField;\n\n// #endregion\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nodeIdentifierManager.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/node-identifier/nodeIdentifierManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAKnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,2BAA2B,IAAI,mBAAmB,CAAC;IAEnD;;OAEG;IACH,sBAAsB,CAAC,UAAU,EAAE,oBAAoB,GAAG,mBAAmB,CAAC;IAE9E;;OAEG;IACH,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,GAAG,oBAAoB,CAAC;IAE/E;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;CAC/E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,YAAY,CAAC,EAAE,aAAa,GAAG,SAAS,GACtC,qBAAqB,CAyCvB;AAED,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,MAAM,GAChB,UAAU,IAAI,oBAAoB,CAEpC"}
1
+ {"version":3,"file":"nodeIdentifierManager.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/node-identifier/nodeIdentifierManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAKnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,2BAA2B,IAAI,mBAAmB,CAAC;IAEnD;;OAEG;IACH,sBAAsB,CAAC,UAAU,EAAE,oBAAoB,GAAG,mBAAmB,CAAC;IAE9E;;OAEG;IACH,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,GAAG,oBAAoB,CAAC;IAE/E;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;CAC/E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,YAAY,CAAC,EAAE,aAAa,GAAG,SAAS,GACtC,qBAAqB,CAEvB;AA0CD,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,MAAM,GAChB,UAAU,IAAI,oBAAoB,CAEpC"}
@@ -14,33 +14,37 @@ const index_js_1 = require("../../util/index.js");
14
14
  * If undefined, then attempts to generate or convert identifiers will throw an error.
15
15
  */
16
16
  function createNodeIdentifierManager(idCompressor) {
17
- return {
18
- generateLocalNodeIdentifier: () => {
19
- (0, internal_1.assert)(idCompressor !== undefined, 0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */);
20
- return (0, index_js_1.brand)(idCompressor.generateCompressedId());
21
- },
22
- localizeNodeIdentifier: (identifier) => {
23
- (0, internal_1.assert)(idCompressor !== undefined, 0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */);
24
- return (0, index_js_1.brand)(idCompressor.recompress(identifier));
25
- },
26
- stabilizeNodeIdentifier: (identifier) => {
27
- (0, internal_1.assert)(idCompressor !== undefined, 0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */);
28
- return (0, index_js_1.brand)(
29
- // TODO: The assert below is required for type safety but is maybe slow
30
- (0, internal_2.assertIsStableId)(idCompressor.decompress((0, index_js_1.extractFromOpaque)(identifier))));
31
- },
32
- tryLocalizeNodeIdentifier: (identifier) => {
33
- (0, internal_1.assert)(idCompressor !== undefined, 0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */);
34
- if (isStableNodeIdentifier(identifier)) {
35
- const compressedIdentifier = idCompressor.tryRecompress(identifier);
36
- if (compressedIdentifier !== undefined) {
37
- return (0, index_js_1.brand)(compressedIdentifier);
38
- }
39
- }
40
- },
41
- };
17
+ return new DefaultNodeIdentifierManager(idCompressor);
42
18
  }
43
19
  exports.createNodeIdentifierManager = createNodeIdentifierManager;
20
+ class DefaultNodeIdentifierManager {
21
+ constructor(idCompressor) {
22
+ this.idCompressor = idCompressor;
23
+ }
24
+ generateLocalNodeIdentifier() {
25
+ (0, internal_1.assert)(this.idCompressor !== undefined, 0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */);
26
+ return (0, index_js_1.brand)(this.idCompressor.generateCompressedId());
27
+ }
28
+ localizeNodeIdentifier(identifier) {
29
+ (0, internal_1.assert)(this.idCompressor !== undefined, 0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */);
30
+ return (0, index_js_1.brand)(this.idCompressor.recompress(identifier));
31
+ }
32
+ stabilizeNodeIdentifier(identifier) {
33
+ (0, internal_1.assert)(this.idCompressor !== undefined, 0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */);
34
+ return (0, index_js_1.brand)(
35
+ // TODO: The assert below is required for type safety but is maybe slow
36
+ (0, internal_2.assertIsStableId)(this.idCompressor.decompress((0, index_js_1.extractFromOpaque)(identifier))));
37
+ }
38
+ tryLocalizeNodeIdentifier(identifier) {
39
+ (0, internal_1.assert)(this.idCompressor !== undefined, 0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */);
40
+ if (isStableNodeIdentifier(identifier)) {
41
+ const compressedIdentifier = this.idCompressor.tryRecompress(identifier);
42
+ if (compressedIdentifier !== undefined) {
43
+ return (0, index_js_1.brand)(compressedIdentifier);
44
+ }
45
+ }
46
+ }
47
+ }
44
48
  function isStableNodeIdentifier(identifier) {
45
49
  return (0, internal_2.isStableId)(identifier);
46
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodeIdentifierManager.js","sourceRoot":"","sources":["../../../src/feature-libraries/node-identifier/nodeIdentifierManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,qEAAsF;AAEtF,kDAA+D;AA+B/D;;;;GAIG;AACH,SAAgB,2BAA2B,CAC1C,YAAwC;IAExC,OAAO;QACN,2BAA2B,EAAE,GAAG,EAAE;YACjC,IAAA,iBAAM,EACL,YAAY,KAAK,SAAS,EAC1B,KAAK,CAAC,+EAA+E,CACrF,CAAC;YACF,OAAO,IAAA,gBAAK,EAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,sBAAsB,EAAE,CAAC,UAAgC,EAAE,EAAE;YAC5D,IAAA,iBAAM,EACL,YAAY,KAAK,SAAS,EAC1B,KAAK,CAAC,wEAAwE,CAC9E,CAAC;YACF,OAAO,IAAA,gBAAK,EAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,uBAAuB,EAAE,CAAC,UAA+B,EAAE,EAAE;YAC5D,IAAA,iBAAM,EACL,YAAY,KAAK,SAAS,EAC1B,KAAK,CAAC,wEAAwE,CAC9E,CAAC;YACF,OAAO,IAAA,gBAAK;YACX,uEAAuE;YACvE,IAAA,2BAAgB,EAAC,YAAY,CAAC,UAAU,CAAC,IAAA,4BAAiB,EAAC,UAAU,CAAC,CAAC,CAAC,CACxE,CAAC;QACH,CAAC;QACD,yBAAyB,EAAE,CAAC,UAAkB,EAAE,EAAE;YACjD,IAAA,iBAAM,EACL,YAAY,KAAK,SAAS,EAC1B,KAAK,CAAC,wEAAwE,CAC9E,CAAC;YACF,IAAI,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,MAAM,oBAAoB,GAAG,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;gBACpE,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;oBACxC,OAAO,IAAA,gBAAK,EAAC,oBAAoB,CAAC,CAAC;gBACpC,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC;AA3CD,kEA2CC;AAED,SAAgB,sBAAsB,CACrC,UAAkB;IAElB,OAAO,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAJD,wDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { assertIsStableId, isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport { brand, extractFromOpaque } from \"../../util/index.js\";\n\nimport type { LocalNodeIdentifier, StableNodeIdentifier } from \"./nodeIdentifier.js\";\n\n/**\n * An object which handles the generation of node identifiers as well as conversion between their two types ({@link StableNodeIdentifier} and {@link LocalNodeIdentifier}).\n */\nexport interface NodeIdentifierManager {\n\t/**\n\t * Generate a {@link StableNodeIdentifier}.\n\t */\n\tgenerateLocalNodeIdentifier(): LocalNodeIdentifier;\n\n\t/**\n\t * Convert the given {@link StableNodeIdentifier} into its {@link LocalNodeIdentifier} form.\n\t */\n\tlocalizeNodeIdentifier(identifier: StableNodeIdentifier): LocalNodeIdentifier;\n\n\t/**\n\t * Convert the given {@link LocalNodeIdentifier} into its {@link StableNodeIdentifier} form.\n\t */\n\tstabilizeNodeIdentifier(identifier: LocalNodeIdentifier): StableNodeIdentifier;\n\n\t/**\n\t * Attempts to recompress a {@link StableNodeIdentifier}.\n\t * @param identifier - The identifier that is attempted to recompress.\n\t * @returns The `{@link LocalNodeIdentifier}` associated with `identifier` or undefined if the identifier was not generated by any session known to this compressor.\n\t */\n\ttryLocalizeNodeIdentifier(identifier: string): LocalNodeIdentifier | undefined;\n}\n\n/**\n * Creates a {@link NodeIdentifierManager} from the given {@link IIdCompressor}.\n * @param idCompressor - the compressor to use for identifier generation, compression, and decompression.\n * If undefined, then attempts to generate or convert identifiers will throw an error.\n */\nexport function createNodeIdentifierManager(\n\tidCompressor?: IIdCompressor | undefined,\n): NodeIdentifierManager {\n\treturn {\n\t\tgenerateLocalNodeIdentifier: () => {\n\t\t\tassert(\n\t\t\t\tidCompressor !== undefined,\n\t\t\t\t0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */,\n\t\t\t);\n\t\t\treturn brand(idCompressor.generateCompressedId());\n\t\t},\n\n\t\tlocalizeNodeIdentifier: (identifier: StableNodeIdentifier) => {\n\t\t\tassert(\n\t\t\t\tidCompressor !== undefined,\n\t\t\t\t0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t\t);\n\t\t\treturn brand(idCompressor.recompress(identifier));\n\t\t},\n\n\t\tstabilizeNodeIdentifier: (identifier: LocalNodeIdentifier) => {\n\t\t\tassert(\n\t\t\t\tidCompressor !== undefined,\n\t\t\t\t0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t\t);\n\t\t\treturn brand(\n\t\t\t\t// TODO: The assert below is required for type safety but is maybe slow\n\t\t\t\tassertIsStableId(idCompressor.decompress(extractFromOpaque(identifier))),\n\t\t\t);\n\t\t},\n\t\ttryLocalizeNodeIdentifier: (identifier: string) => {\n\t\t\tassert(\n\t\t\t\tidCompressor !== undefined,\n\t\t\t\t0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t\t);\n\t\t\tif (isStableNodeIdentifier(identifier)) {\n\t\t\t\tconst compressedIdentifier = idCompressor.tryRecompress(identifier);\n\t\t\t\tif (compressedIdentifier !== undefined) {\n\t\t\t\t\treturn brand(compressedIdentifier);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function isStableNodeIdentifier(\n\tidentifier: string,\n): identifier is StableNodeIdentifier {\n\treturn isStableId(identifier);\n}\n"]}
1
+ {"version":3,"file":"nodeIdentifierManager.js","sourceRoot":"","sources":["../../../src/feature-libraries/node-identifier/nodeI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AAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACzE,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;gBACxC,OAAO,IAAA,gBAAK,EAAC,oBAAoB,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED,SAAgB,sBAAsB,CACrC,UAAkB;IAElB,OAAO,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAJD,wDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { assertIsStableId, isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport { brand, extractFromOpaque } from \"../../util/index.js\";\n\nimport type { LocalNodeIdentifier, StableNodeIdentifier } from \"./nodeIdentifier.js\";\n\n/**\n * An object which handles the generation of node identifiers as well as conversion between their two types ({@link StableNodeIdentifier} and {@link LocalNodeIdentifier}).\n */\nexport interface NodeIdentifierManager {\n\t/**\n\t * Generate a {@link StableNodeIdentifier}.\n\t */\n\tgenerateLocalNodeIdentifier(): LocalNodeIdentifier;\n\n\t/**\n\t * Convert the given {@link StableNodeIdentifier} into its {@link LocalNodeIdentifier} form.\n\t */\n\tlocalizeNodeIdentifier(identifier: StableNodeIdentifier): LocalNodeIdentifier;\n\n\t/**\n\t * Convert the given {@link LocalNodeIdentifier} into its {@link StableNodeIdentifier} form.\n\t */\n\tstabilizeNodeIdentifier(identifier: LocalNodeIdentifier): StableNodeIdentifier;\n\n\t/**\n\t * Attempts to recompress a {@link StableNodeIdentifier}.\n\t * @param identifier - The identifier that is attempted to recompress.\n\t * @returns The `{@link LocalNodeIdentifier}` associated with `identifier` or undefined if the identifier was not generated by any session known to this compressor.\n\t */\n\ttryLocalizeNodeIdentifier(identifier: string): LocalNodeIdentifier | undefined;\n}\n\n/**\n * Creates a {@link NodeIdentifierManager} from the given {@link IIdCompressor}.\n * @param idCompressor - the compressor to use for identifier generation, compression, and decompression.\n * If undefined, then attempts to generate or convert identifiers will throw an error.\n */\nexport function createNodeIdentifierManager(\n\tidCompressor?: IIdCompressor | undefined,\n): NodeIdentifierManager {\n\treturn new DefaultNodeIdentifierManager(idCompressor);\n}\n\nclass DefaultNodeIdentifierManager implements NodeIdentifierManager {\n\tpublic constructor(private readonly idCompressor: IIdCompressor | undefined) {}\n\tpublic generateLocalNodeIdentifier(): LocalNodeIdentifier {\n\t\tassert(\n\t\t\tthis.idCompressor !== undefined,\n\t\t\t0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */,\n\t\t);\n\t\treturn brand(this.idCompressor.generateCompressedId());\n\t}\n\tpublic localizeNodeIdentifier(identifier: StableNodeIdentifier): LocalNodeIdentifier {\n\t\tassert(\n\t\t\tthis.idCompressor !== undefined,\n\t\t\t0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t);\n\t\treturn brand(this.idCompressor.recompress(identifier));\n\t}\n\tpublic stabilizeNodeIdentifier(identifier: LocalNodeIdentifier): StableNodeIdentifier {\n\t\tassert(\n\t\t\tthis.idCompressor !== undefined,\n\t\t\t0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t);\n\t\treturn brand(\n\t\t\t// TODO: The assert below is required for type safety but is maybe slow\n\t\t\tassertIsStableId(this.idCompressor.decompress(extractFromOpaque(identifier))),\n\t\t);\n\t}\n\tpublic tryLocalizeNodeIdentifier(identifier: string): LocalNodeIdentifier | undefined {\n\t\tassert(\n\t\t\tthis.idCompressor !== undefined,\n\t\t\t0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */,\n\t\t);\n\t\tif (isStableNodeIdentifier(identifier)) {\n\t\t\tconst compressedIdentifier = this.idCompressor.tryRecompress(identifier);\n\t\t\tif (compressedIdentifier !== undefined) {\n\t\t\t\treturn brand(compressedIdentifier);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function isStableNodeIdentifier(\n\tidentifier: string,\n): identifier is StableNodeIdentifier {\n\treturn isStableId(identifier);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/tree";
8
- export declare const pkgVersion = "2.32.0";
8
+ export declare const pkgVersion = "2.33.0-333010";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,WAAW,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/tree";
11
- exports.pkgVersion = "2.32.0";
11
+ exports.pkgVersion = "2.33.0-333010";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.32.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.33.0-333010\";\n"]}
@@ -30,6 +30,7 @@ export declare class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout =
30
30
  * Get a typed view of the tree content using the flex-tree API.
31
31
  */
32
32
  readonly flexTree: FlexTreeField;
33
+ private disposed;
33
34
  constructor(
34
35
  /**
35
36
  * Access non-view schema specific aspects of this branch.
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutFlexTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/checkoutFlexTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAE1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1E;;GAEG;AACH,qBAAa,oBAAoB,CAAC,GAAG,CAAC,SAAS,SAAS,aAAa,GAAG,aAAa;IAenF;;;;;OAKG;aACa,QAAQ,EAAE,SAAS;aACnB,MAAM,EAAE,gBAAgB;aACxB,cAAc,EAAE,qBAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAvB5B;;;;;OAKG;IACH,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,SAAgB,QAAQ,EAAE,aA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,CAAC,IAAI,IAAI;IAY9B;;;OAGG;IACI,IAAI,IAAI,oBAAoB,CAAC,aAAa,GAAG,iBAAiB,CAAC;CAKtE;AAQD;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,uBAAuB,GAC9B,oBAAoB,CAItB"}
@@ -25,11 +25,14 @@ class CheckoutFlexTreeView {
25
25
  this.schema = schema;
26
26
  this.nodeKeyManager = nodeKeyManager;
27
27
  this.onDispose = onDispose;
28
+ this.disposed = false;
28
29
  this.context = (0, index_js_1.getTreeContext)(schema, this.checkout, nodeKeyManager);
29
30
  contextToTreeViewMap.set(this.context, this);
30
31
  this.flexTree = this.context.root;
31
32
  }
32
33
  [index_js_3.disposeSymbol]() {
34
+ (0, internal_1.assert)(!this.disposed, "Double disposed");
35
+ this.disposed = true;
33
36
  for (const anchorNode of this.checkout.forest.anchors) {
34
37
  (0, index_js_2.tryDisposeTreeNode)(anchorNode);
35
38
  }
@@ -41,6 +44,7 @@ class CheckoutFlexTreeView {
41
44
  * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.
42
45
  */
43
46
  fork() {
47
+ (0, internal_1.assert)(!this.disposed, "disposed");
44
48
  const branch = this.checkout.branch();
45
49
  return new CheckoutFlexTreeView(branch, this.schema, this.nodeKeyManager);
46
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutFlexTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/checkoutFlexTreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,4DAOuC;AACvC,sDAA6D;AAC7D,+CAAiD;AAIjD;;GAEG;AACH,MAAa,oBAAoB;IAchC;IACC;;;;;OAKG;IACa,QAAmB,EACnB,MAAwB,EACxB,cAAqC,EACpC,SAAsB;QAHvB,aAAQ,GAAR,QAAQ,CAAW;QACnB,WAAM,GAAN,MAAM,CAAkB;QACxB,mBAAc,GAAd,cAAc,CAAuB;QACpC,cAAS,GAAT,SAAS,CAAa;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAA,yBAAc,EAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACrE,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IACnC,CAAC;IAEM,CAAC,wBAAa,CAAC;QACrB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,IAAA,6BAAkB,EAAC,UAAU,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,wBAAa,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,IAAI;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3E,CAAC;CACD;AAhDD,oDAgDC;AAED;;;GAGG;AACH,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAiD,CAAC;AAE1F;;;GAGG;AACH,SAAgB,uBAAuB,CACtC,OAAgC;IAEhC,MAAM,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAA,iBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC;AACb,CAAC;AAND,0DAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype Context,\n\ttype FlexTreeField,\n\ttype NodeIdentifierManager,\n\tgetTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FullSchemaPolicy,\n} from \"../feature-libraries/index.js\";\nimport { tryDisposeTreeNode } from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport type { ITreeCheckout, ITreeCheckoutFork } from \"./treeCheckout.js\";\n\n/**\n * An editable view of a (version control style) branch of a shared tree.\n */\nexport class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout = ITreeCheckout> {\n\t/**\n\t * Context for controlling the FlexTree nodes produced from {@link FlexTreeView.flexTree}.\n\t *\n\t * @remarks\n\t * This is an owning reference: disposing of this view disposes its context.\n\t */\n\tpublic readonly context: Context;\n\n\t/**\n\t * Get a typed view of the tree content using the flex-tree API.\n\t */\n\tpublic readonly flexTree: FlexTreeField;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Access non-view schema specific aspects of this branch.\n\t\t *\n\t\t * @remarks\n\t\t * This is a non-owning reference: disposing of this view does not impact the branch.\n\t\t */\n\t\tpublic readonly checkout: TCheckout,\n\t\tpublic readonly schema: FullSchemaPolicy,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t\tprivate readonly onDispose?: () => void,\n\t) {\n\t\tthis.context = getTreeContext(schema, this.checkout, nodeKeyManager);\n\t\tcontextToTreeViewMap.set(this.context, this);\n\t\tthis.flexTree = this.context.root;\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tfor (const anchorNode of this.checkout.forest.anchors) {\n\t\t\ttryDisposeTreeNode(anchorNode);\n\t\t}\n\n\t\tthis.context[disposeSymbol]();\n\t\tthis.onDispose?.();\n\t}\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tpublic fork(): CheckoutFlexTreeView<ITreeCheckout & ITreeCheckoutFork> {\n\t\tconst branch = this.checkout.branch();\n\t\treturn new CheckoutFlexTreeView(branch, this.schema, this.nodeKeyManager);\n\t}\n}\n\n/**\n * Maps the context of every {@link CheckoutFlexTreeView} to the view.\n * In practice, this allows the view or checkout to be obtained from a flex node by first getting the context from the flex node and then using this map.\n */\nconst contextToTreeViewMap = new WeakMap<FlexTreeHydratedContext, CheckoutFlexTreeView>();\n\n/**\n * Retrieve the {@link CheckoutFlexTreeView | view} for the given {@link FlexTreeHydratedContext | context}.\n * @remarks Every {@link CheckoutFlexTreeView} is associated with its context upon creation.\n */\nexport function getCheckoutFlexTreeView(\n\tcontext: FlexTreeHydratedContext,\n): CheckoutFlexTreeView {\n\tconst view = contextToTreeViewMap.get(context);\n\tassert(view !== undefined, 0xa41 /* Expected view to be registered for context */);\n\treturn view;\n}\n"]}
1
+ {"version":3,"file":"checkoutFlexTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/checkoutFlexTreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,4DAOuC;AACvC,sDAA6D;AAC7D,+CAAiD;AAIjD;;GAEG;AACH,MAAa,oBAAoB;IAgBhC;IACC;;;;;OAKG;IACa,QAAmB,EACnB,MAAwB,EACxB,cAAqC,EACpC,SAAsB;QAHvB,aAAQ,GAAR,QAAQ,CAAW;QACnB,WAAM,GAAN,MAAM,CAAkB;QACxB,mBAAc,GAAd,cAAc,CAAuB;QACpC,cAAS,GAAT,SAAS,CAAa;QAZhC,aAAQ,GAAG,KAAK,CAAC;QAcxB,IAAI,CAAC,OAAO,GAAG,IAAA,yBAAc,EAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACrE,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IACnC,CAAC;IAEM,CAAC,wBAAa,CAAC;QACrB,IAAA,iBAAM,EAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,IAAA,6BAAkB,EAAC,UAAU,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,wBAAa,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,IAAI;QACV,IAAA,iBAAM,EAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3E,CAAC;CACD;AAtDD,oDAsDC;AAED;;;GAGG;AACH,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAiD,CAAC;AAE1F;;;GAGG;AACH,SAAgB,uBAAuB,CACtC,OAAgC;IAEhC,MAAM,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAA,iBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC;AACb,CAAC;AAND,0DAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype Context,\n\ttype FlexTreeField,\n\ttype NodeIdentifierManager,\n\tgetTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FullSchemaPolicy,\n} from \"../feature-libraries/index.js\";\nimport { tryDisposeTreeNode } from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport type { ITreeCheckout, ITreeCheckoutFork } from \"./treeCheckout.js\";\n\n/**\n * An editable view of a (version control style) branch of a shared tree.\n */\nexport class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout = ITreeCheckout> {\n\t/**\n\t * Context for controlling the FlexTree nodes produced from {@link FlexTreeView.flexTree}.\n\t *\n\t * @remarks\n\t * This is an owning reference: disposing of this view disposes its context.\n\t */\n\tpublic readonly context: Context;\n\n\t/**\n\t * Get a typed view of the tree content using the flex-tree API.\n\t */\n\tpublic readonly flexTree: FlexTreeField;\n\n\tprivate disposed = false;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Access non-view schema specific aspects of this branch.\n\t\t *\n\t\t * @remarks\n\t\t * This is a non-owning reference: disposing of this view does not impact the branch.\n\t\t */\n\t\tpublic readonly checkout: TCheckout,\n\t\tpublic readonly schema: FullSchemaPolicy,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t\tprivate readonly onDispose?: () => void,\n\t) {\n\t\tthis.context = getTreeContext(schema, this.checkout, nodeKeyManager);\n\t\tcontextToTreeViewMap.set(this.context, this);\n\t\tthis.flexTree = this.context.root;\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tassert(!this.disposed, \"Double disposed\");\n\t\tthis.disposed = true;\n\n\t\tfor (const anchorNode of this.checkout.forest.anchors) {\n\t\t\ttryDisposeTreeNode(anchorNode);\n\t\t}\n\n\t\tthis.context[disposeSymbol]();\n\t\tthis.onDispose?.();\n\t}\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tpublic fork(): CheckoutFlexTreeView<ITreeCheckout & ITreeCheckoutFork> {\n\t\tassert(!this.disposed, \"disposed\");\n\t\tconst branch = this.checkout.branch();\n\t\treturn new CheckoutFlexTreeView(branch, this.schema, this.nodeKeyManager);\n\t}\n}\n\n/**\n * Maps the context of every {@link CheckoutFlexTreeView} to the view.\n * In practice, this allows the view or checkout to be obtained from a flex node by first getting the context from the flex node and then using this map.\n */\nconst contextToTreeViewMap = new WeakMap<FlexTreeHydratedContext, CheckoutFlexTreeView>();\n\n/**\n * Retrieve the {@link CheckoutFlexTreeView | view} for the given {@link FlexTreeHydratedContext | context}.\n * @remarks Every {@link CheckoutFlexTreeView} is associated with its context upon creation.\n */\nexport function getCheckoutFlexTreeView(\n\tcontext: FlexTreeHydratedContext,\n): CheckoutFlexTreeView {\n\tconst view = contextToTreeViewMap.get(context);\n\tassert(view !== undefined, 0xa41 /* Expected view to be registered for context */);\n\treturn view;\n}\n"]}
@@ -89,8 +89,10 @@ export declare class TreeNodeKernel {
89
89
  *
90
90
  * For hydrated nodes it returns a FlexTreeNode backed by the forest.
91
91
  * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
92
+ *
93
+ * If `allowDeleted` is false, this will throw a UsageError if the node is deleted.
92
94
  */
93
- getOrCreateInnerNode(allowFreed?: boolean): InnerNode;
95
+ getOrCreateInnerNode(allowDeleted?: boolean): InnerNode;
94
96
  /**
95
97
  * Creates an anchor node and associates it with the given proxy.
96
98
  * @privateRemarks
@@ -138,6 +140,9 @@ export declare const unhydratedFlexTreeNodeToTreeNode: Pick<WeakMap<UnhydratedFl
138
140
  * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.
139
141
  */
140
142
  export declare const proxySlot: import("../../core/index.js").AnchorSlot<TreeNode>;
143
+ /**
144
+ * Dispose a TreeNode (if any) for an existing anchor without disposing the anchor.
145
+ */
141
146
  export declare function tryDisposeTreeNode(anchorNode: AnchorNode): void;
142
147
  /**
143
148
  * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.
@@ -154,8 +159,10 @@ export declare function getSimpleContextFromInnerNode(innerNode: InnerNode): Con
154
159
  *
155
160
  * For hydrated nodes it returns a FlexTreeNode backed by the forest.
156
161
  * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
162
+ *
163
+ * If `allowDeleted` is false, this will throw a UsageError if the node is deleted.
157
164
  */
158
- export declare function getOrCreateInnerNode(treeNode: TreeNode, allowFreed?: boolean): InnerNode;
165
+ export declare function getOrCreateInnerNode(treeNode: TreeNode, allowDeleted?: boolean): InnerNode;
159
166
  /**
160
167
  * Gets a tree node from an anchor node
161
168
  */
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAoB,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKN,UAAU,EAEV,KAAK,YAAY,EACjB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,EAAqB,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAIxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,cAAc,CAG/E;AA0BD;;;;GAIG;AACH,qBAAa,cAAc;;aAoCT,IAAI,EAAE,QAAQ;aACd,MAAM,EAAE,cAAc;IAEtC,OAAO,CAA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AEG;AACH,eAAO,MAAM,gCAAgC,wDAI3C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,oDAAyB,CAAC;AAEhD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAO/D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAGrF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAS3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,UAAQ,GAAG,SAAS,CAGxF;AAoBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAQ/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAQlF"}
@@ -18,6 +18,7 @@ var _TreeNodeKernel_hydrationState, _TreeNodeKernel_unhydratedEvents;
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.createTreeNodeFromInner = exports.treeNodeFromAnchor = exports.getOrCreateInnerNode = exports.getSimpleContextFromInnerNode = exports.getSimpleNodeSchemaFromInnerNode = exports.tryDisposeTreeNode = exports.proxySlot = exports.unhydratedFlexTreeNodeToTreeNode = exports.TreeNodeKernel = exports.tryGetTreeNodeSchema = exports.isTreeNode = exports.getKernel = void 0;
20
20
  const internal_1 = require("@fluidframework/core-utils/internal");
21
+ const internal_2 = require("@fluidframework/telemetry-utils/internal");
21
22
  const client_utils_1 = require("@fluid-internal/client-utils");
22
23
  const index_js_1 = require("../../core/index.js");
23
24
  const index_js_2 = require("../../feature-libraries/index.js");
@@ -232,33 +233,41 @@ class TreeNodeKernel {
232
233
  *
233
234
  * For hydrated nodes it returns a FlexTreeNode backed by the forest.
234
235
  * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
236
+ *
237
+ * If `allowDeleted` is false, this will throw a UsageError if the node is deleted.
235
238
  */
236
- getOrCreateInnerNode(allowFreed = false) {
239
+ getOrCreateInnerNode(allowDeleted = false) {
237
240
  if (!isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
241
+ (0, internal_1.debugAssert)(() => __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode?.context.isDisposed() === false ||
242
+ "Unhydrated node should never be disposed");
238
243
  return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode; // Unhydrated case
239
244
  }
240
- if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode !== undefined) {
241
- return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode; // Cooked case
242
- }
243
- // Marinated case -> cooked
244
- const anchorNode = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode;
245
- // The proxy is bound to an anchor node, but it may or may not have an actual flex node yet
246
- const flexNode = anchorNode.slots.get(index_js_2.flexTreeSlot);
247
- if (flexNode !== undefined) {
248
- // If the flex node already exists, use it...
249
- __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = flexNode;
245
+ if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode === undefined) {
246
+ // Marinated case -> cooked
247
+ const anchorNode = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode;
248
+ // The proxy is bound to an anchor node, but it may or may not have an actual flex node yet
249
+ const flexNode = anchorNode.slots.get(index_js_2.flexTreeSlot);
250
+ if (flexNode !== undefined) {
251
+ // If the flex node already exists, use it...
252
+ __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = flexNode;
253
+ }
254
+ else {
255
+ // ...otherwise, the flex node must be created
256
+ const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb41 /* missing context */);
257
+ const cursor = context.checkout.forest.allocateCursor("getFlexNode");
258
+ context.checkout.forest.moveCursorToPath(anchorNode, cursor);
259
+ __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = (0, lazyNode_js_1.makeTree)(context, cursor);
260
+ cursor.free();
261
+ // Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode
262
+ anchorForgetters?.get(this.node)?.();
263
+ if (!allowDeleted) {
264
+ (0, index_js_2.assertFlexTreeEntityNotFreed)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
265
+ }
266
+ }
250
267
  }
251
- else {
252
- // ...otherwise, the flex node must be created
253
- const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb41 /* missing context */);
254
- const cursor = context.checkout.forest.allocateCursor("getFlexNode");
255
- context.checkout.forest.moveCursorToPath(anchorNode, cursor);
256
- __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = (0, lazyNode_js_1.makeTree)(context, cursor);
257
- cursor.free();
258
- // Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode
259
- anchorForgetters?.get(this.node)?.();
260
- if (!allowFreed) {
261
- (0, index_js_2.assertFlexTreeEntityNotFreed)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
268
+ if (!allowDeleted) {
269
+ if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode.context.isDisposed()) {
270
+ throw new internal_2.UsageError("Cannot access a Deleted node.");
262
271
  }
263
272
  }
264
273
  return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode;
@@ -327,11 +336,15 @@ exports.unhydratedFlexTreeNodeToTreeNode = unhydratedFlexTreeNodeToTreeNodeInter
327
336
  * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.
328
337
  */
329
338
  exports.proxySlot = (0, index_js_1.anchorSlot)();
339
+ /**
340
+ * Dispose a TreeNode (if any) for an existing anchor without disposing the anchor.
341
+ */
330
342
  function tryDisposeTreeNode(anchorNode) {
331
343
  const treeNode = anchorNode.slots.get(exports.proxySlot);
332
344
  if (treeNode !== undefined) {
333
345
  const kernel = getKernel(treeNode);
334
346
  kernel.dispose();
347
+ anchorNode.slots.delete(exports.proxySlot);
335
348
  }
336
349
  }
337
350
  exports.tryDisposeTreeNode = tryDisposeTreeNode;
@@ -362,10 +375,12 @@ exports.getSimpleContextFromInnerNode = getSimpleContextFromInnerNode;
362
375
  *
363
376
  * For hydrated nodes it returns a FlexTreeNode backed by the forest.
364
377
  * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
378
+ *
379
+ * If `allowDeleted` is false, this will throw a UsageError if the node is deleted.
365
380
  */
366
- function getOrCreateInnerNode(treeNode, allowFreed = false) {
381
+ function getOrCreateInnerNode(treeNode, allowDeleted = false) {
367
382
  const kernel = getKernel(treeNode);
368
- return kernel.getOrCreateInnerNode(allowFreed);
383
+ return kernel.getOrCreateInnerNode(allowDeleted);
369
384
  }
370
385
  exports.getOrCreateInnerNode = getOrCreateInnerNode;
371
386
  /**