@fluidframework/tree 2.0.0-rc.5.0.0 → 2.1.0-274160

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 (53) hide show
  1. package/.vscode/settings.json +16 -0
  2. package/api-report/tree.alpha.api.md +0 -12
  3. package/api-report/tree.beta.api.md +0 -12
  4. package/api-report/tree.public.api.md +0 -12
  5. package/dist/events/events.d.ts +1 -5
  6. package/dist/events/events.d.ts.map +1 -1
  7. package/dist/events/events.js +2 -21
  8. package/dist/events/events.js.map +1 -1
  9. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  10. package/dist/feature-libraries/flex-tree/lazyField.js +40 -2
  11. package/dist/feature-libraries/flex-tree/lazyField.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/schematizingTreeView.d.ts.map +1 -1
  17. package/dist/shared-tree/schematizingTreeView.js +9 -3
  18. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  19. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  20. package/dist/simple-tree/arrayNode.js +6 -3
  21. package/dist/simple-tree/arrayNode.js.map +1 -1
  22. package/dist/simple-tree/index.d.ts +2 -1
  23. package/dist/simple-tree/index.d.ts.map +1 -1
  24. package/dist/simple-tree/index.js +4 -1
  25. package/dist/simple-tree/index.js.map +1 -1
  26. package/lib/events/events.d.ts +1 -5
  27. package/lib/events/events.d.ts.map +1 -1
  28. package/lib/events/events.js +2 -21
  29. package/lib/events/events.js.map +1 -1
  30. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  31. package/lib/feature-libraries/flex-tree/lazyField.js +42 -4
  32. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  33. package/lib/packageVersion.d.ts +1 -1
  34. package/lib/packageVersion.d.ts.map +1 -1
  35. package/lib/packageVersion.js +1 -1
  36. package/lib/packageVersion.js.map +1 -1
  37. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  38. package/lib/shared-tree/schematizingTreeView.js +11 -5
  39. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  40. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  41. package/lib/simple-tree/arrayNode.js +6 -3
  42. package/lib/simple-tree/arrayNode.js.map +1 -1
  43. package/lib/simple-tree/index.d.ts +2 -1
  44. package/lib/simple-tree/index.d.ts.map +1 -1
  45. package/lib/simple-tree/index.js +2 -1
  46. package/lib/simple-tree/index.js.map +1 -1
  47. package/package.json +21 -21
  48. package/src/events/events.ts +3 -23
  49. package/src/feature-libraries/flex-tree/lazyField.ts +58 -7
  50. package/src/packageVersion.ts +1 -1
  51. package/src/shared-tree/schematizingTreeView.ts +18 -5
  52. package/src/simple-tree/arrayNode.ts +6 -3
  53. package/src/simple-tree/index.ts +6 -1
@@ -16,4 +16,20 @@
16
16
  // mocha test config isn't sufficient; it also needs to be enabled here.
17
17
  "mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
18
18
  "cSpell.words": ["deprioritized", "endregion", "insertable", "reentrantly", "unhydrated"],
19
+
20
+ // Enable biome as default formatter, and disable rules that disagree with it
21
+ "editor.defaultFormatter": "biomejs.biome",
22
+ "editor.insertSpaces": false,
23
+ // Also configure the formatter on a per-language basis for some common languages/file-types, to make sure it is applied
24
+ // even if someone's User Settings specify a different formatter at this level (which overrides the root-level
25
+ // 'editor.defaultFormatter').
26
+ "[json]": {
27
+ "editor.defaultFormatter": "biomejs.biome",
28
+ },
29
+ "[javascript]": {
30
+ "editor.defaultFormatter": "biomejs.biome",
31
+ },
32
+ "[typescript]": {
33
+ "editor.defaultFormatter": "biomejs.biome",
34
+ },
19
35
  }
@@ -4,18 +4,6 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import type { ErasedType } from '@fluidframework/core-interfaces';
8
- import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
9
- import type { IFluidHandle } from '@fluidframework/core-interfaces';
10
- import type { IFluidLoadable } from '@fluidframework/core-interfaces';
11
- import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
12
- import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
13
- import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
14
- import type { SharedObjectKind } from '@fluidframework/shared-object-base';
15
- import type { StableId } from '@fluidframework/id-compressor';
16
- import type { Static } from '@sinclair/typebox';
17
- import type { TSchema } from '@sinclair/typebox';
18
-
19
7
  // @public
20
8
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
21
9
 
@@ -4,18 +4,6 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import type { ErasedType } from '@fluidframework/core-interfaces';
8
- import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
9
- import type { IFluidHandle } from '@fluidframework/core-interfaces';
10
- import type { IFluidLoadable } from '@fluidframework/core-interfaces';
11
- import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
12
- import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
13
- import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
14
- import type { SharedObjectKind } from '@fluidframework/shared-object-base';
15
- import type { StableId } from '@fluidframework/id-compressor';
16
- import type { Static } from '@sinclair/typebox';
17
- import type { TSchema } from '@sinclair/typebox';
18
-
19
7
  // @public
20
8
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
21
9
 
@@ -4,18 +4,6 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import type { ErasedType } from '@fluidframework/core-interfaces';
8
- import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
9
- import type { IFluidHandle } from '@fluidframework/core-interfaces';
10
- import type { IFluidLoadable } from '@fluidframework/core-interfaces';
11
- import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
12
- import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
13
- import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
14
- import type { SharedObjectKind } from '@fluidframework/shared-object-base';
15
- import type { StableId } from '@fluidframework/id-compressor';
16
- import type { Static } from '@sinclair/typebox';
17
- import type { TSchema } from '@sinclair/typebox';
18
-
19
7
  // @public
20
8
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
21
9
 
@@ -78,7 +78,7 @@ export interface Listenable<TListeners extends object> {
78
78
  * @returns a {@link Off | function} which will deregister the listener when called.
79
79
  * This deregistration function is idempotent and therefore may be safely called more than once with no effect.
80
80
  * @remarks Do not register the exact same `listener` object for the same event more than once.
81
- * Doing so will result in an error.
81
+ * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.
82
82
  */
83
83
  on<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;
84
84
  }
@@ -187,10 +187,6 @@ export declare class EventEmitter<TListeners extends Listeners<TListeners>> impl
187
187
  * @param listener - the handler to run when the event is fired by the emitter
188
188
  * @returns a function which will deregister the listener when run.
189
189
  * This function will error if called more than once.
190
- * @privateRemarks
191
- * TODO:
192
- * invoking the returned callback can error even if its only called once if the same listener was provided to two calls to "on".
193
- * This behavior is not documented and its unclear if its a bug or not: see note on listeners.
194
190
  */
195
191
  on<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;
196
192
  hasListeners(eventName?: keyof TListeners): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAG9D;;GAEG;AAEH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,SAAS,CACxF,CAAC,EAAE,MAAM,CAAC,KACN,OAAO,GACT,CAAC,GACD,KAAK,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,SAAS,MAAM,UAAU,EAC9C,SAAS,EAAE,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,IAAI;IAIS,cAAc,CAAC,CAAC,SAAS,MAAM,UAAU,EACxD,SAAS,EAAE,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;CAG9B"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ComposableEventEmitter = exports.EventEmitter = exports.createEmitter = void 0;
8
- const internal_1 = require("@fluidframework/telemetry-utils/internal");
8
+ const index_js_1 = require("../util/index.js");
9
9
  /**
10
10
  * Create a {@link Listenable} that can be instructed to emit events via the {@link IEmitter} interface.
11
11
  *
@@ -90,10 +90,6 @@ class EventEmitter {
90
90
  * @param listener - the handler to run when the event is fired by the emitter
91
91
  * @returns a function which will deregister the listener when run.
92
92
  * This function will error if called more than once.
93
- * @privateRemarks
94
- * TODO:
95
- * invoking the returned callback can error even if its only called once if the same listener was provided to two calls to "on".
96
- * This behavior is not documented and its unclear if its a bug or not: see note on listeners.
97
93
  */
98
94
  on(eventName, listener) {
99
95
  const off = () => {
@@ -105,22 +101,7 @@ class EventEmitter {
105
101
  }
106
102
  }
107
103
  };
108
- const listeners = this.listeners.get(eventName);
109
- if (listeners === undefined) {
110
- const map = new Map([[off, listener]]);
111
- this.listeners.set(eventName, map);
112
- }
113
- else {
114
- // If the same listener function is already registered, error.
115
- // This policy may change in the future, but in the meantime this is a conservative choice that can accommodate multiple future eventing API/implementation options.
116
- // For example, adding an `Listenable.off()` method in the future could be problematic if we allowed registering the same function twice (should `off(f)` deregister _both_ `f`s or just one?).
117
- for (const l of listeners.values()) {
118
- if (Object.is(l, listener)) {
119
- throw new internal_1.UsageError("The same listener may not be registered more than once for the same event");
120
- }
121
- }
122
- listeners.set(off, listener);
123
- }
104
+ (0, index_js_1.getOrCreate)(this.listeners, eventName, () => new Map()).set(off, listener);
124
105
  return off;
125
106
  }
126
107
  hasListeners(eventName) {
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uEAAsE;AAuItE;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AAJD,sCAIC;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,YAAY;IAQxB,uJAAuJ;IACvJ,6FAA6F;IAC7F,YAAuC,WAA6C;QAA7C,gBAAW,GAAX,WAAW,CAAkC;QAPjE,cAAS,GAAG,IAAI,GAAG,EAGnC,CAAC;IAImF,CAAC;IAE9E,IAAI,CACb,SAAY,EACZ,GAAG,IAA+B;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAc,IAAI,CAAC,CAAC,yGAAyG;YAC3I,qHAAqH;YACrH,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;gBAC9C,6EAA6E;gBAC7E,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACxB,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAES,cAAc,CACvB,SAAY,EACZ,GAAG,IAA+B;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,SAAS,KAAK,SAAS,EAAE,C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AM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC;oBAC5B,MAAM,IAAI,qBAAU,CACnB,2EAA2E,CAC3E,CAAC;gBACH,CAAC;YACF,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,YAAY,CAAC,SAA4B;QAC/C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACD;AAhGD,oCAgGC;AAED;;GAEG;AACH,MAAa,sBACZ,SAAQ,YAAwB;IAGhC,YAAmB,WAA6C;QAC/D,KAAK,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC;IAEe,IAAI,CACnB,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAEe,cAAc,CAC7B,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;CACD;AArBD,wDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEvent } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection<T> = (T extends any ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener\n * @public\n */\nexport type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;\n\n/**\n * Used to specify the kinds of events emitted by a {@link Listenable}.\n *\n * @remarks\n * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that\n * type will be included.\n *\n * @example\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n * ```\n *\n * @public\n */\nexport type Listeners<T extends object> = {\n\t[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];\n};\n\n/**\n * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable\n * by an IEventProvider from `@fluidframework/core-interfaces`.\n * @param E - the `Events` type to transform\n * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`\n *\n * @example\n *\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n *\n * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {\n * // ...\n * }\n * ```\n */\nexport type TransformListeners<\n\tTListeners extends Listeners<TListeners>,\n\tTTarget extends IEvent = IEvent,\n> = {\n\t[P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;\n} extends Record<string | number | symbol, infer Z>\n\t? UnionToIntersection<Z> & TTarget\n\t: never;\n\n/**\n * An object which allows the registration of listeners so that subscribers can be notified when an event happens.\n * @param TListeners - All the {@link Listeners | events} that this subscribable supports\n *\n * @privateRemarks\n * `EventEmitter` can be used as a base class to implement this via extension.\n * ```ts\n * type MyEventEmitter = IEventEmitter<{\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }>\n * ```\n * {@link createEmitter} can help implement this interface via delegation.\n *\n * @sealed @public\n */\nexport interface Listenable<TListeners extends object> {\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a {@link Off | function} which will deregister the listener when called.\n\t * This deregistration function is idempotent and therefore may be safely called more than once with no effect.\n\t * @remarks Do not register the exact same `listener` object for the same event more than once.\n\t * Doing so will result in an error.\n\t */\n\ton<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;\n}\n\n/**\n * A function that, when called, will deregister an event listener subscription that was previously registered.\n * @remarks\n * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.\n * @public\n */\nexport type Off = () => void;\n\n/**\n * Interface for an event emitter that can emit typed events to subscribed listeners.\n * @internal\n */\nexport interface IEmitter<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t */\n\temit<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void;\n\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * It also collects the return values of all listeners into an array.\n\t *\n\t * Warning: This method should be used with caution. It deviates from the standard event-based integration pattern as creates substantial coupling between the emitter and its listeners.\n\t * For the majority of use-cases it is recommended to use the standard {@link IEmitter.emit} functionality.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t * @returns An array of the return values of each listener, preserving the order listeners were called.\n\t */\n\temitAndCollect<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[];\n}\n\n/**\n * Create a {@link Listenable} that can be instructed to emit events via the {@link IEmitter} interface.\n *\n * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.\n * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.\n * @internal\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n\n/**\n * Called when the last listener for `eventName` is removed.\n * Useful for determining when to clean up resources related to detecting when the event might occurs.\n * @internal\n */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\n * @internal\n */\nexport interface HasListeners<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * When no `eventName` is provided, returns true iff there are any listeners.\n\t *\n\t * When `eventName` is provided, returns true iff there are listeners for that event.\n\t *\n\t * @remarks\n\t * This can be used to know when its safe to cleanup data-structures which only exist to fire events for their listeners.\n\t */\n\thasListeners(eventName?: keyof Listeners<TListeners>): boolean;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class or compose over it.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \"loaded\": () => void;\n * }\n *\n * class MyClass extends EventEmitter<MyEvents> {\n * private load() {\n * this.emit(\"loaded\");\n * }\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyClass implements ISubscribable<MyEvents> {\n * private readonly events = EventEmitter.create<MyEvents>();\n *\n * private load() {\n * this.events.emit(\"loaded\");\n * }\n *\n * public on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * return this.events.on(eventName, listener);\n * }\n * }\n * ```\n */\nexport class EventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tMap<Off, (...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args; // TODO: Current TS (4.5.5) cannot spread `args` into `listener()`, but future versions (e.g. 4.8.4) can.\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const [off, listener] of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(off)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a function which will deregister the listener when run.\n\t * This function will error if called more than once.\n\t * @privateRemarks\n\t * TODO:\n\t * invoking the returned callback can error even if its only called once if the same listener was provided to two calls to \"on\".\n\t * This behavior is not documented and its unclear if its a bug or not: see note on listeners.\n\t */\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst off: Off = () => {\n\t\t\tconst currentListeners = this.listeners.get(eventName);\n\t\t\tif (currentListeners?.delete(off) === true) {\n\t\t\t\tif (currentListeners.size === 0) {\n\t\t\t\t\tthis.listeners.delete(eventName);\n\t\t\t\t\tthis.noListeners?.(eventName);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners === undefined) {\n\t\t\tconst map = new Map([[off, listener]]);\n\t\t\tthis.listeners.set(eventName, map);\n\t\t} else {\n\t\t\t// If the same listener function is already registered, error.\n\t\t\t// This policy may change in the future, but in the meantime this is a conservative choice that can accommodate multiple future eventing API/implementation options.\n\t\t\t// For example, adding an `Listenable.off()` method in the future could be problematic if we allowed registering the same function twice (should `off(f)` deregister _both_ `f`s or just one?).\n\t\t\tfor (const l of listeners.values()) {\n\t\t\t\tif (Object.is(l, listener)) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"The same listener may not be registered more than once for the same event\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tlisteners.set(off, listener);\n\t\t}\n\t\treturn off;\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size !== 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n */\nexport class ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends EventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAA+C;AAuI/C;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AA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;CACD;AArBD,wDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEvent } from \"@fluidframework/core-interfaces\";\nimport { getOrCreate } from \"../util/index.js\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection<T> = (T extends any ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener\n * @public\n */\nexport type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;\n\n/**\n * Used to specify the kinds of events emitted by a {@link Listenable}.\n *\n * @remarks\n * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that\n * type will be included.\n *\n * @example\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n * ```\n *\n * @public\n */\nexport type Listeners<T extends object> = {\n\t[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];\n};\n\n/**\n * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable\n * by an IEventProvider from `@fluidframework/core-interfaces`.\n * @param E - the `Events` type to transform\n * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`\n *\n * @example\n *\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n *\n * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {\n * // ...\n * }\n * ```\n */\nexport type TransformListeners<\n\tTListeners extends Listeners<TListeners>,\n\tTTarget extends IEvent = IEvent,\n> = {\n\t[P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;\n} extends Record<string | number | symbol, infer Z>\n\t? UnionToIntersection<Z> & TTarget\n\t: never;\n\n/**\n * An object which allows the registration of listeners so that subscribers can be notified when an event happens.\n * @param TListeners - All the {@link Listeners | events} that this subscribable supports\n *\n * @privateRemarks\n * `EventEmitter` can be used as a base class to implement this via extension.\n * ```ts\n * type MyEventEmitter = IEventEmitter<{\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }>\n * ```\n * {@link createEmitter} can help implement this interface via delegation.\n *\n * @sealed @public\n */\nexport interface Listenable<TListeners extends object> {\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a {@link Off | function} which will deregister the listener when called.\n\t * This deregistration function is idempotent and therefore may be safely called more than once with no effect.\n\t * @remarks Do not register the exact same `listener` object for the same event more than once.\n\t * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.\n\t */\n\ton<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;\n}\n\n/**\n * A function that, when called, will deregister an event listener subscription that was previously registered.\n * @remarks\n * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.\n * @public\n */\nexport type Off = () => void;\n\n/**\n * Interface for an event emitter that can emit typed events to subscribed listeners.\n * @internal\n */\nexport interface IEmitter<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t */\n\temit<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void;\n\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * It also collects the return values of all listeners into an array.\n\t *\n\t * Warning: This method should be used with caution. It deviates from the standard event-based integration pattern as creates substantial coupling between the emitter and its listeners.\n\t * For the majority of use-cases it is recommended to use the standard {@link IEmitter.emit} functionality.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t * @returns An array of the return values of each listener, preserving the order listeners were called.\n\t */\n\temitAndCollect<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[];\n}\n\n/**\n * Create a {@link Listenable} that can be instructed to emit events via the {@link IEmitter} interface.\n *\n * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.\n * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.\n * @internal\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n\n/**\n * Called when the last listener for `eventName` is removed.\n * Useful for determining when to clean up resources related to detecting when the event might occurs.\n * @internal\n */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\n * @internal\n */\nexport interface HasListeners<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * When no `eventName` is provided, returns true iff there are any listeners.\n\t *\n\t * When `eventName` is provided, returns true iff there are listeners for that event.\n\t *\n\t * @remarks\n\t * This can be used to know when its safe to cleanup data-structures which only exist to fire events for their listeners.\n\t */\n\thasListeners(eventName?: keyof Listeners<TListeners>): boolean;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class or compose over it.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \"loaded\": () => void;\n * }\n *\n * class MyClass extends EventEmitter<MyEvents> {\n * private load() {\n * this.emit(\"loaded\");\n * }\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyClass implements ISubscribable<MyEvents> {\n * private readonly events = EventEmitter.create<MyEvents>();\n *\n * private load() {\n * this.events.emit(\"loaded\");\n * }\n *\n * public on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * return this.events.on(eventName, listener);\n * }\n * }\n * ```\n */\nexport class EventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tMap<Off, (...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args; // TODO: Current TS (4.5.5) cannot spread `args` into `listener()`, but future versions (e.g. 4.8.4) can.\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const [off, listener] of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(off)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a function which will deregister the listener when run.\n\t * This function will error if called more than once.\n\t */\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst off: Off = () => {\n\t\t\tconst currentListeners = this.listeners.get(eventName);\n\t\t\tif (currentListeners?.delete(off) === true) {\n\t\t\t\tif (currentListeners.size === 0) {\n\t\t\t\t\tthis.listeners.delete(eventName);\n\t\t\t\t\tthis.noListeners?.(eventName);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tgetOrCreate(this.listeners, eventName, () => new Map()).set(off, listener);\n\t\treturn off;\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size !== 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n */\nexport class ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends EventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lazyField.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAEhB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAKzB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACN,UAAU,EAEV,KAAK,wBAAwB,EAE7B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM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AM,CACN;CAAG"}
@@ -18,10 +18,48 @@ const lazyNode_js_1 = require("./lazyNode.js");
18
18
  const unboxed_js_1 = require("./unboxed.js");
19
19
  const utilities_js_1 = require("./utilities.js");
20
20
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
21
+ /**
22
+ * Reuse fields.
23
+ * Since field currently own cursors and register themselves for disposal when the node hit end of life,
24
+ * not reusing them results in memory leaks every time the field is accessed.
25
+ * Since the fields stay alive until the node is end of life reusing them this way is safe.
26
+ *
27
+ * This ins't a perfect solution:
28
+ *
29
+ * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.
30
+ * - This does not cache the root.
31
+ * - Finding the parent anchor to do the caching on has significant cost.
32
+ *
33
+ * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.
34
+ */
35
+ const fieldCache = new WeakMap();
21
36
  function makeField(context, schema, cursor) {
22
37
  const fieldAnchor = cursor.buildFieldAnchor();
23
- const field = new (kindToClass.get(schema.kind) ?? (0, index_js_2.fail)("missing field implementation"))(context, schema, cursor, fieldAnchor);
24
- return field;
38
+ let usedAnchor = false;
39
+ const makeFlexTreeField = () => {
40
+ usedAnchor = true;
41
+ const field = new (kindToClass.get(schema.kind) ?? (0, index_js_2.fail)("missing field implementation"))(context, schema, cursor, fieldAnchor);
42
+ return field;
43
+ };
44
+ if (fieldAnchor.parent === undefined) {
45
+ return makeFlexTreeField();
46
+ }
47
+ // For the common case (all but roots), cache field associated with its node's anchor and field key.
48
+ const anchorNode = context.checkout.forest.anchors.locate(fieldAnchor.parent) ?? (0, index_js_2.fail)("missing anchor");
49
+ // Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.
50
+ const cacheKey = anchorNode.slots.get(flexTreeTypes_js_1.flexTreeSlot);
51
+ // If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.
52
+ if (cacheKey === undefined) {
53
+ return makeFlexTreeField();
54
+ }
55
+ const innerCache = (0, index_js_2.getOrCreate)(fieldCache, cacheKey, () => new Map());
56
+ const result = (0, index_js_2.getOrCreate)(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);
57
+ if (!usedAnchor) {
58
+ // The anchor must be disposed to avoid leaking. In the case of a cache hit,
59
+ // we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.
60
+ context.checkout.forest.anchors.forget(fieldAnchor.parent);
61
+ }
62
+ return result;
25
63
  }
26
64
  exports.makeField = makeField;
27
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"lazyField.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAY6B;AAC7B,kDAK6B;AAC7B,4CAA4C;AAC5C,kEAA0F;AAC1F,yDAKoC;AACpC,0DAA4D;AAK5D,yDAc4B;AAC5B,mDAOyB;AACzB,+CAAyC;AACzC,6CAA4C;AAC5C,iDAIwB;AACxB,uEAAsE;AAEtE,SAAgB,SAAS,CACxB,OAAgB,EAChB,MAAuB,EACvB,MAA+B;IAE/B,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAE9C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,8BAA8B,CAAC,CAAC,CACvF,OAAO,EACP,MAAM,EACN,MAAM,EACN,WAAW,CACX,CAAC;IACF,OAAO,KAAK,CAAC;AACd,CAAC;AAdD,8BAcC;AAED;;;GAGG;AACH,MAAsB,SACrB,SAAQ,0BAAuD;IAG/D,IAAW,CAAC,iCAAc,CAAC;QAC1B,OAAO,qCAAkB,CAAC,KAAK,CAAC;IACjC,CAAC;IASD,YACC,OAAgB,EAChB,MAAsC,EACtC,MAA+B,EAC/B,WAAwB;QAExB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE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,CAAC,6BAA6B,CAAC,CAAC;IACtF,OAAO,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC","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\tCursorLocationType,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\tisCursor,\n\titerateCursorField,\n\tkeyAsDetachedField,\n} from \"../../core/index.js\";\nimport {\n\tassertValidIndex,\n\tassertValidRangeIndices,\n\tdisposeSymbol,\n\tfail,\n} from \"../../util/index.js\";\n// TODO: stop depending on contextuallyTyped\nimport { applyTypesFromContext, cursorFromContextualData } from \"../contextuallyTyped.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport { cursorForMapTreeField } from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexAllowedTypes, FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxNodeUnion,\n\ttype FlexibleNodeContent,\n\ttype FlexibleNodeSubSequence,\n\tTreeStatus,\n\tflexTreeMarker,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { makeTree } from \"./lazyNode.js\";\nimport { unboxedUnion } from \"./unboxed.js\";\nimport {\n\tindexForAt,\n\ttreeStatusFromAnchorCache,\n\ttreeStatusFromDetachedField,\n} from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\n\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\tcontext,\n\t\tschema,\n\t\tcursor,\n\t\tfieldAnchor,\n\t);\n\treturn field;\n}\n\n/**\n * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to\n * the nodes of {@link EditableField} by means of the cursors.\n */\nexport abstract class LazyField<TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes>\n\textends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TSchema extends FlexFieldSchema>(\n\t\tschema: TSchema,\n\t): this is FlexTreeTypedField<TSchema> {\n\t\tassert(\n\t\t\tthis.context.schema.policy.fieldKinds.get(schema.kind.identifier) === schema.kind,\n\t\t\t0x77c /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic isSameAs(other: FlexTreeField): boolean {\n\t\tassert(\n\t\t\tother.context === this.context,\n\t\t\t0x77d /* Content from different flex trees should not be used together */,\n\t\t);\n\t\treturn this.key === other.key && this.parent === other.parent;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t) as unknown as FlexTreeTypedNodeUnion<TTypes>;\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic mapBoxed<U>(\n\t\tcallbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U,\n\t): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(\n\t\t\tthis[cursorSymbol],\n\t\t\t(cursor) => makeTree(this.context, cursor) as unknown as FlexTreeTypedNodeUnion<TTypes>,\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic treeStatus(): TreeStatus {\n\t\tif (this[isFreedSymbol]()) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tconst fieldAnchor = this[anchorSymbol];\n\t\tconst parentAnchor = fieldAnchor.parent;\n\t\t// If the parentAnchor is undefined it is a detached field.\n\t\tif (parentAnchor === undefined) {\n\t\t\treturn treeStatusFromDetachedField(keyAsDetachedField(fieldAnchor.fieldKey));\n\t\t}\n\t\tconst parentAnchorNode = this.context.checkout.forest.anchors.locate(parentAnchor);\n\n\t\t// As the \"parentAnchor === undefined\" case is handled above, parentAnchorNode should exist.\n\t\tassert(parentAnchorNode !== undefined, 0x77e /* parentAnchorNode must exist. */);\n\t\treturn treeStatusFromAnchorCache(parentAnchorNode);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (this.treeStatus() !== TreeStatus.InDocument) {\n\t\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t\t}\n\t\treturn this.getFieldPath();\n\t}\n}\n\nexport class LazySequence<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.sequence, TTypes>\n\timplements FlexTreeSequenceField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnboxNodeUnion<TTypes>[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic sequenceEditor(): SequenceFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.sequenceField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic insertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tassertValidIndex(index, this, true);\n\t\tconst content: ITreeCursorSynchronous = isCursor(value)\n\t\t\t? prepareFieldCursorForInsert(value)\n\t\t\t: cursorForMapTreeField(\n\t\t\t\t\tArray.from(value, (item) =>\n\t\t\t\t\t\tapplyTypesFromContext(this.context, this.schema.allowedTypeSet, item),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.insert(index, content);\n\t}\n\n\tpublic insertAtStart(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(0, value);\n\t}\n\n\tpublic insertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(this.length, value);\n\t}\n\n\tpublic removeAt(index: number): void {\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.remove(index, 1);\n\t}\n\n\tpublic moveToStart(sourceIndex: number): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToEnd(sourceIndex: number): void;\n\tpublic moveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\tpublic moveToEnd(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToIndex(index: number, sourceIndex: number): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceIndex, sourceIndex + 1, source);\n\t}\n\n\tpublic moveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceStart, sourceEnd, source);\n\t}\n\n\tprivate _moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tconst sourceField = source !== undefined ? (this.isSameAs(source) ? this : source) : this;\n\n\t\t// TODO: determine support for move across different sequence types\n\t\tassert(\n\t\t\tsourceField instanceof LazySequence,\n\t\t\t0x7b1 /* Unsupported sequence implementation. */,\n\t\t);\n\t\tassertValidRangeIndices(sourceStart, sourceEnd, sourceField);\n\t\tif (this.schema.types !== undefined && sourceField !== this) {\n\t\t\tfor (let i = sourceStart; i < sourceEnd; i++) {\n\t\t\t\tconst sourceNode =\n\t\t\t\t\tsourceField.boxedAt(sourceStart) ?? fail(\"impossible out of bounds index\");\n\t\t\t\tif (!this.schema.types.has(sourceNode.schema.name)) {\n\t\t\t\t\tthrow new Error(\"Type in source sequence is not allowed in destination.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst movedCount = sourceEnd - sourceStart;\n\t\tassertValidIndex(index, this, true);\n\t\tconst sourceFieldPath = sourceField.getFieldPath();\n\t\tconst destinationFieldPath = this.getFieldPath();\n\t\tthis.context.checkout.editor.move(\n\t\t\tsourceFieldPath,\n\t\t\tsourceStart,\n\t\t\tmovedCount,\n\t\t\tdestinationFieldPath,\n\t\t\tindex,\n\t\t);\n\t}\n}\n\nexport class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.required, TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tfail(\"cannot set content in readonly field\");\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyValueField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic override set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tconst content: ITreeCursorSynchronous[] = isCursor(newContent)\n\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.valueFieldEditor();\n\t\tassert(content.length === 1, 0x780 /* value field content should normalize to one item */);\n\t\tfieldEditor.set(content[0]);\n\t}\n\n\tpublic override get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyIdentifierField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n}\n\nexport class LazyOptionalField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.optional, TTypes>\n\timplements FlexTreeOptionalField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes> | undefined) {\n\t\tconst content: ITreeCursorSynchronous[] =\n\t\t\tnewContent === undefined\n\t\t\t\t? []\n\t\t\t\t: isCursor(newContent)\n\t\t\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.optionalEditor();\n\t\tassert(\n\t\t\tcontent.length <= 1,\n\t\t\t0x781 /* optional field content should normalize at most one item */,\n\t\t);\n\t\tfieldEditor.set(content.length === 0 ? undefined : content[0], this.length === 0);\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.boxedAt(0);\n\t}\n}\n\nexport class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<\n\ttypeof FieldKinds.forbidden,\n\tTTypes\n> {}\n\ntype Builder = new <TTypes extends FlexAllowedTypes>(\n\tcontext: Context,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any, TTypes>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => LazyField<any, TTypes>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyIdentifierField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n\n/**\n * Prepare a fields cursor (holding a sequence of nodes) for inserting.\n */\nfunction prepareFieldCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Fields, 0x8cb /* should be in fields mode */);\n\treturn cursor;\n}\n\n/**\n * Prepare a node cursor (holding a single node) for inserting.\n */\nfunction prepareNodeCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous[] {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x805 /* should be in nodes mode */);\n\treturn [cursor];\n}\n"]}
1
+ {"version":3,"file":"lazyField.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAY6B;AAC7B,kDAM6B;AAC7B,4CAA4C;AAC5C,kEAA0F;AAC1F,yDAKoC;AACpC,0DAA4D;AAK5D,yDAe4B;AAC5B,mDAOyB;AACzB,+CAA4D;AAC5D,6CAA4C;AAC5C,iDAIwB;AACxB,uEAAsE;AAEtE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAwD,IAAI,OAAO,EAAE,CAAC;AAEtF,SAAgB,SAAS,CACxB,OAAgB,EAChB,MAAuB,EACvB,MAA+B;IAE/B,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9C,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,MAAM,iBAAiB,GAAG,GAAkB,EAAE;QAC7C,UAAU,GAAG,IAAI,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,8BAA8B,CAAC,CAAC,CACvF,OAAO,EACP,MAAM,EACN,MAAM,EACN,WAAW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;IACtF,OAAO,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC","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\tCursorLocationType,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\tisCursor,\n\titerateCursorField,\n\tkeyAsDetachedField,\n} from \"../../core/index.js\";\nimport {\n\tassertValidIndex,\n\tassertValidRangeIndices,\n\tdisposeSymbol,\n\tfail,\n\tgetOrCreate,\n} from \"../../util/index.js\";\n// TODO: stop depending on contextuallyTyped\nimport { applyTypesFromContext, cursorFromContextualData } from \"../contextuallyTyped.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport { cursorForMapTreeField } from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexAllowedTypes, FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxNodeUnion,\n\ttype FlexibleNodeContent,\n\ttype FlexibleNodeSubSequence,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { unboxedUnion } from \"./unboxed.js\";\nimport {\n\tindexForAt,\n\ttreeStatusFromAnchorCache,\n\ttreeStatusFromDetachedField,\n} from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to\n * the nodes of {@link EditableField} by means of the cursors.\n */\nexport abstract class LazyField<TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes>\n\textends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TSchema extends FlexFieldSchema>(\n\t\tschema: TSchema,\n\t): this is FlexTreeTypedField<TSchema> {\n\t\tassert(\n\t\t\tthis.context.schema.policy.fieldKinds.get(schema.kind.identifier) === schema.kind,\n\t\t\t0x77c /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic isSameAs(other: FlexTreeField): boolean {\n\t\tassert(\n\t\t\tother.context === this.context,\n\t\t\t0x77d /* Content from different flex trees should not be used together */,\n\t\t);\n\t\treturn this.key === other.key && this.parent === other.parent;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t) as unknown as FlexTreeTypedNodeUnion<TTypes>;\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic mapBoxed<U>(\n\t\tcallbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U,\n\t): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(\n\t\t\tthis[cursorSymbol],\n\t\t\t(cursor) => makeTree(this.context, cursor) as unknown as FlexTreeTypedNodeUnion<TTypes>,\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic treeStatus(): TreeStatus {\n\t\tif (this[isFreedSymbol]()) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tconst fieldAnchor = this[anchorSymbol];\n\t\tconst parentAnchor = fieldAnchor.parent;\n\t\t// If the parentAnchor is undefined it is a detached field.\n\t\tif (parentAnchor === undefined) {\n\t\t\treturn treeStatusFromDetachedField(keyAsDetachedField(fieldAnchor.fieldKey));\n\t\t}\n\t\tconst parentAnchorNode = this.context.checkout.forest.anchors.locate(parentAnchor);\n\n\t\t// As the \"parentAnchor === undefined\" case is handled above, parentAnchorNode should exist.\n\t\tassert(parentAnchorNode !== undefined, 0x77e /* parentAnchorNode must exist. */);\n\t\treturn treeStatusFromAnchorCache(parentAnchorNode);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (this.treeStatus() !== TreeStatus.InDocument) {\n\t\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t\t}\n\t\treturn this.getFieldPath();\n\t}\n}\n\nexport class LazySequence<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.sequence, TTypes>\n\timplements FlexTreeSequenceField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnboxNodeUnion<TTypes>[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic sequenceEditor(): SequenceFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.sequenceField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic insertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tassertValidIndex(index, this, true);\n\t\tconst content: ITreeCursorSynchronous = isCursor(value)\n\t\t\t? prepareFieldCursorForInsert(value)\n\t\t\t: cursorForMapTreeField(\n\t\t\t\t\tArray.from(value, (item) =>\n\t\t\t\t\t\tapplyTypesFromContext(this.context, this.schema.allowedTypeSet, item),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.insert(index, content);\n\t}\n\n\tpublic insertAtStart(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(0, value);\n\t}\n\n\tpublic insertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(this.length, value);\n\t}\n\n\tpublic removeAt(index: number): void {\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.remove(index, 1);\n\t}\n\n\tpublic moveToStart(sourceIndex: number): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToEnd(sourceIndex: number): void;\n\tpublic moveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\tpublic moveToEnd(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToIndex(index: number, sourceIndex: number): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceIndex, sourceIndex + 1, source);\n\t}\n\n\tpublic moveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceStart, sourceEnd, source);\n\t}\n\n\tprivate _moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tconst sourceField = source !== undefined ? (this.isSameAs(source) ? this : source) : this;\n\n\t\t// TODO: determine support for move across different sequence types\n\t\tassert(\n\t\t\tsourceField instanceof LazySequence,\n\t\t\t0x7b1 /* Unsupported sequence implementation. */,\n\t\t);\n\t\tassertValidRangeIndices(sourceStart, sourceEnd, sourceField);\n\t\tif (this.schema.types !== undefined && sourceField !== this) {\n\t\t\tfor (let i = sourceStart; i < sourceEnd; i++) {\n\t\t\t\tconst sourceNode =\n\t\t\t\t\tsourceField.boxedAt(sourceStart) ?? fail(\"impossible out of bounds index\");\n\t\t\t\tif (!this.schema.types.has(sourceNode.schema.name)) {\n\t\t\t\t\tthrow new Error(\"Type in source sequence is not allowed in destination.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst movedCount = sourceEnd - sourceStart;\n\t\tassertValidIndex(index, this, true);\n\t\tconst sourceFieldPath = sourceField.getFieldPath();\n\t\tconst destinationFieldPath = this.getFieldPath();\n\t\tthis.context.checkout.editor.move(\n\t\t\tsourceFieldPath,\n\t\t\tsourceStart,\n\t\t\tmovedCount,\n\t\t\tdestinationFieldPath,\n\t\t\tindex,\n\t\t);\n\t}\n}\n\nexport class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.required, TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tfail(\"cannot set content in readonly field\");\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyValueField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic override set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tconst content: ITreeCursorSynchronous[] = isCursor(newContent)\n\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.valueFieldEditor();\n\t\tassert(content.length === 1, 0x780 /* value field content should normalize to one item */);\n\t\tfieldEditor.set(content[0]);\n\t}\n\n\tpublic override get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyIdentifierField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n}\n\nexport class LazyOptionalField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.optional, TTypes>\n\timplements FlexTreeOptionalField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes> | undefined) {\n\t\tconst content: ITreeCursorSynchronous[] =\n\t\t\tnewContent === undefined\n\t\t\t\t? []\n\t\t\t\t: isCursor(newContent)\n\t\t\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.optionalEditor();\n\t\tassert(\n\t\t\tcontent.length <= 1,\n\t\t\t0x781 /* optional field content should normalize at most one item */,\n\t\t);\n\t\tfieldEditor.set(content.length === 0 ? undefined : content[0], this.length === 0);\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.boxedAt(0);\n\t}\n}\n\nexport class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<\n\ttypeof FieldKinds.forbidden,\n\tTTypes\n> {}\n\ntype Builder = new <TTypes extends FlexAllowedTypes>(\n\tcontext: Context,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any, TTypes>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => LazyField<any, TTypes>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyIdentifierField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n\n/**\n * Prepare a fields cursor (holding a sequence of nodes) for inserting.\n */\nfunction prepareFieldCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Fields, 0x8cb /* should be in fields mode */);\n\treturn cursor;\n}\n\n/**\n * Prepare a node cursor (holding a single node) for inserting.\n */\nfunction prepareNodeCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous[] {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x805 /* should be in nodes mode */);\n\treturn [cursor];\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.0.0-rc.5.0.0";
8
+ export declare const pkgVersion = "2.1.0-274160";
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,mBAAmB,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,iBAAiB,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.0.0-rc.5.0.0";
11
+ exports.pkgVersion = "2.1.0-274160";
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,gBAAgB,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.0.0-rc.5.0.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,cAAc,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.1.0-274160\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schematizingTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,UAAU,EAGV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,oCAAoC,EAEzC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,QAAQ,EACb,KAAK,cAAc,EAOnB,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AASjC,OAAO,KAAK,EAAE,YAAY,EAAE,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SAAS,eAAe,EAC1D,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAC7B,SAAS,EAAE,MAAM,IAAI,EACrB,cAAc,EAAE,cAAc,GAC5B,oBAAoB,CAAC,KAAK,CAAC,CA2B7B"}
@@ -59,11 +59,17 @@ class SchematizingSimpleTreeView {
59
59
  throw new internal_2.UsageError("Tree cannot be initialized more than once.");
60
60
  }
61
61
  this.runSchemaEdit(() => {
62
+ const mapTree = (0, index_js_4.mapTreeFromNodeData)(content, this.rootFieldSchema.allowedTypes, this.nodeKeyManager, {
63
+ schema: this.checkout.storedSchema,
64
+ policy: {
65
+ ...index_js_3.defaultSchemaPolicy,
66
+ validateSchema: this.config.enableSchemaValidation,
67
+ },
68
+ });
69
+ (0, index_js_4.prepareContentForHydration)(mapTree, this.checkout.forest);
62
70
  (0, schematizeTree_js_1.initialize)(this.checkout, {
63
71
  schema: this.flexConfig.schema,
64
- initialTree: content === undefined
65
- ? undefined
66
- : (0, index_js_4.cursorFromUnhydratedRoot)(this.config.schema, content, this.nodeKeyManager),
72
+ initialTree: mapTree === undefined ? undefined : (0, index_js_3.cursorForMapTreeNode)(mapTree),
67
73
  });
68
74
  });
69
75
  }