@fluidframework/tree 2.2.0 → 2.3.0-288113

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 (144) hide show
  1. package/api-report/tree.alpha.api.md +39 -3
  2. package/api-report/tree.beta.api.md +8 -3
  3. package/api-report/tree.public.api.md +8 -3
  4. package/dist/beta.d.ts +1 -0
  5. package/dist/core/tree/anchorSet.d.ts +4 -6
  6. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  7. package/dist/core/tree/anchorSet.js +11 -1
  8. package/dist/core/tree/anchorSet.js.map +1 -1
  9. package/dist/events/events.d.ts +7 -1
  10. package/dist/events/events.d.ts.map +1 -1
  11. package/dist/events/events.js +5 -2
  12. package/dist/events/events.js.map +1 -1
  13. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  14. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  15. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -12
  16. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  17. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +4 -95
  18. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  19. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +1 -30
  20. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  21. package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
  22. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  23. package/dist/feature-libraries/flex-tree/index.js +1 -3
  24. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  25. package/dist/feature-libraries/flex-tree/lazyField.d.ts +0 -1
  26. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  27. package/dist/feature-libraries/flex-tree/lazyField.js +0 -3
  28. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  29. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -10
  30. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  31. package/dist/feature-libraries/flex-tree/lazyNode.js +2 -87
  32. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  33. package/dist/feature-libraries/index.d.ts +1 -1
  34. package/dist/feature-libraries/index.d.ts.map +1 -1
  35. package/dist/feature-libraries/index.js +2 -4
  36. package/dist/feature-libraries/index.js.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +36 -31
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.d.ts.map +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/public.d.ts +1 -0
  46. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
  47. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  48. package/dist/simple-tree/api/treeNodeApi.js +30 -2
  49. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  50. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  51. package/dist/simple-tree/arrayNode.js +5 -19
  52. package/dist/simple-tree/arrayNode.js.map +1 -1
  53. package/dist/simple-tree/core/index.d.ts +1 -1
  54. package/dist/simple-tree/core/index.d.ts.map +1 -1
  55. package/dist/simple-tree/core/index.js.map +1 -1
  56. package/dist/simple-tree/core/treeNodeKernel.d.ts +18 -5
  57. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  58. package/dist/simple-tree/core/treeNodeKernel.js +57 -21
  59. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  60. package/dist/simple-tree/core/types.d.ts +28 -10
  61. package/dist/simple-tree/core/types.d.ts.map +1 -1
  62. package/dist/simple-tree/core/types.js.map +1 -1
  63. package/dist/simple-tree/index.d.ts +1 -1
  64. package/dist/simple-tree/index.d.ts.map +1 -1
  65. package/dist/simple-tree/index.js.map +1 -1
  66. package/lib/beta.d.ts +1 -0
  67. package/lib/core/tree/anchorSet.d.ts +4 -6
  68. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  69. package/lib/core/tree/anchorSet.js +11 -1
  70. package/lib/core/tree/anchorSet.js.map +1 -1
  71. package/lib/events/events.d.ts +7 -1
  72. package/lib/events/events.d.ts.map +1 -1
  73. package/lib/events/events.js +5 -2
  74. package/lib/events/events.js.map +1 -1
  75. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  76. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  77. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +0 -12
  78. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  79. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +4 -95
  80. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  81. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -29
  82. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  83. package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
  84. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  85. package/lib/feature-libraries/flex-tree/index.js +1 -1
  86. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  87. package/lib/feature-libraries/flex-tree/lazyField.d.ts +0 -1
  88. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  89. package/lib/feature-libraries/flex-tree/lazyField.js +0 -3
  90. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  91. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -10
  92. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  93. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -86
  94. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  95. package/lib/feature-libraries/index.d.ts +1 -1
  96. package/lib/feature-libraries/index.d.ts.map +1 -1
  97. package/lib/feature-libraries/index.js +1 -1
  98. package/lib/feature-libraries/index.js.map +1 -1
  99. package/lib/index.d.ts +2 -2
  100. package/lib/index.d.ts.map +1 -1
  101. package/lib/index.js +4 -0
  102. package/lib/index.js.map +1 -1
  103. package/lib/packageVersion.d.ts +1 -1
  104. package/lib/packageVersion.d.ts.map +1 -1
  105. package/lib/packageVersion.js +1 -1
  106. package/lib/packageVersion.js.map +1 -1
  107. package/lib/public.d.ts +1 -0
  108. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
  109. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  110. package/lib/simple-tree/api/treeNodeApi.js +30 -2
  111. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  112. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  113. package/lib/simple-tree/arrayNode.js +5 -19
  114. package/lib/simple-tree/arrayNode.js.map +1 -1
  115. package/lib/simple-tree/core/index.d.ts +1 -1
  116. package/lib/simple-tree/core/index.d.ts.map +1 -1
  117. package/lib/simple-tree/core/index.js.map +1 -1
  118. package/lib/simple-tree/core/treeNodeKernel.d.ts +18 -5
  119. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  120. package/lib/simple-tree/core/treeNodeKernel.js +58 -22
  121. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  122. package/lib/simple-tree/core/types.d.ts +28 -10
  123. package/lib/simple-tree/core/types.d.ts.map +1 -1
  124. package/lib/simple-tree/core/types.js.map +1 -1
  125. package/lib/simple-tree/index.d.ts +1 -1
  126. package/lib/simple-tree/index.d.ts.map +1 -1
  127. package/lib/simple-tree/index.js.map +1 -1
  128. package/package.json +22 -32
  129. package/src/core/tree/anchorSet.ts +20 -9
  130. package/src/events/events.ts +10 -2
  131. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +0 -21
  132. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +3 -170
  133. package/src/feature-libraries/flex-tree/index.ts +1 -17
  134. package/src/feature-libraries/flex-tree/lazyField.ts +0 -6
  135. package/src/feature-libraries/flex-tree/lazyNode.ts +3 -154
  136. package/src/feature-libraries/index.ts +0 -14
  137. package/src/index.ts +8 -0
  138. package/src/packageVersion.ts +1 -1
  139. package/src/simple-tree/api/treeNodeApi.ts +37 -5
  140. package/src/simple-tree/arrayNode.ts +3 -12
  141. package/src/simple-tree/core/index.ts +1 -0
  142. package/src/simple-tree/core/treeNodeKernel.ts +88 -29
  143. package/src/simple-tree/core/types.ts +35 -9
  144. package/src/simple-tree/index.ts +1 -0
@@ -94,6 +94,7 @@ export interface Listenable<TListeners extends object> {
94
94
  export type Off = () => void;
95
95
  /**
96
96
  * Interface for an event emitter that can emit typed events to subscribed listeners.
97
+ * @sealed @alpha
97
98
  */
98
99
  export interface IEmitter<TListeners extends Listeners<TListeners>> {
99
100
  /**
@@ -119,14 +120,18 @@ export interface IEmitter<TListeners extends Listeners<TListeners>> {
119
120
  *
120
121
  * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.
121
122
  * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.
123
+ * @alpha
122
124
  */
123
125
  export declare function createEmitter<TListeners extends object>(noListeners?: NoListenersCallback<TListeners>): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners>;
124
126
  /**
125
127
  * Called when the last listener for `eventName` is removed.
126
128
  * Useful for determining when to clean up resources related to detecting when the event might occurs.
129
+ * @alpha
127
130
  */
128
131
  export type NoListenersCallback<TListeners extends object> = (eventName: keyof Listeners<TListeners>) => void;
129
132
  /**
133
+ * Allows querying if an object has listeners.
134
+ * @sealed @alpha
130
135
  */
131
136
  export interface HasListeners<TListeners extends Listeners<TListeners>> {
132
137
  /**
@@ -162,7 +167,7 @@ export interface HasListeners<TListeners extends Listeners<TListeners>> {
162
167
  *
163
168
  * ```typescript
164
169
  * class MyClass implements ISubscribable<MyEvents> {
165
- * private readonly events = EventEmitter.create<MyEvents>();
170
+ * private readonly events = createEmitter<MyEvents>();
166
171
  *
167
172
  * private load() {
168
173
  * this.events.emit("loaded");
@@ -173,6 +178,7 @@ export interface HasListeners<TListeners extends Listeners<TListeners>> {
173
178
  * }
174
179
  * }
175
180
  * ```
181
+ * @alpha
176
182
  */
177
183
  export declare class EventEmitter<TListeners extends Listeners<TListeners>> implements Listenable<TListeners>, HasListeners<TListeners> {
178
184
  private readonly noListeners?;
@@ -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;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,SAAS,CACtF,CAAC,EAAE,MAAM,CAAC,KACN,OAAO,GACT,CAAC,GACD,KAAK,CAAC;AAET;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,SAAS,IAAI,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE9F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;KACxC,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CACrF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,kBAAkB,CAC7B,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,EACxC,OAAO,SAAS,MAAM,GAAG,MAAM,IAC5B;KACF,CAAC,IAAI,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,C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AAE,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;IAa9B;;;;;;OAMG;IACI,EAAE,CAAC,CAAC,SAAS,MAAM,SAAS,CAAC,UAAU,CAAC,EAC9C,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,GAAG;IAeC,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,UAAU,GAAG,OAAO;CAM1D;AAED;;GAEG;AACH,qBAAa,sBAAsB,CAAC,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,CAC3E,SAAQ,YAAY,CAAC,UAAU,CAC/B,YAAW,QAAQ,CAAC,UAAU,CAAC;gBAEZ,WAAW,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC;IAIhD,IAAI,CAAC,CAAC,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"}
@@ -11,6 +11,7 @@ const index_js_1 = require("../util/index.js");
11
11
  *
12
12
  * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.
13
13
  * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.
14
+ * @alpha
14
15
  */
15
16
  function createEmitter(noListeners) {
16
17
  return new ComposableEventEmitter(noListeners);
@@ -39,7 +40,7 @@ exports.createEmitter = createEmitter;
39
40
  *
40
41
  * ```typescript
41
42
  * class MyClass implements ISubscribable<MyEvents> {
42
- * private readonly events = EventEmitter.create<MyEvents>();
43
+ * private readonly events = createEmitter<MyEvents>();
43
44
  *
44
45
  * private load() {
45
46
  * this.events.emit("loaded");
@@ -50,6 +51,7 @@ exports.createEmitter = createEmitter;
50
51
  * }
51
52
  * }
52
53
  * ```
54
+ * @alpha
53
55
  */
54
56
  class EventEmitter {
55
57
  // Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.
@@ -61,7 +63,8 @@ class EventEmitter {
61
63
  emit(eventName, ...args) {
62
64
  const listeners = this.listeners.get(eventName);
63
65
  if (listeners !== undefined) {
64
- const argArray = args; // TODO: Current TS (4.5.5) cannot spread `args` into `listener()`, but future versions (e.g. 4.8.4) can.
66
+ // Current TS (5.4.5) cannot spread `args` into `listener()`, but assigning to an array first makes it work.
67
+ const argArray = args;
65
68
  // This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.
66
69
  for (const [off, listener] of [...listeners]) {
67
70
  // If listener has been unsubscribed while invoking other listeners, skip it.
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAA+C;AAwI/C;;;;;GAKG;AACH,SAAgB,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AAJD,sCAIC;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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CAAC;QACF,CAAC,CAAC;QAEF,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3E,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;AA5ED,oCA4EC;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 { getOrCreate } from \"../util/index.js\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n */\nexport type UnionToIntersection<T> = (T extends T ? (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 */\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 */\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 */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\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
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAA+C;AAyI/C;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AAJD,sCAIC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;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,4GAA4G;YAC5G,MAAM,QAAQ,GAAc,IAAI,CAAC;YAEjC,qHAAqH;YACrH,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GAA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EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3E,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;AA9ED,oCA8EC;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 { getOrCreate } from \"../util/index.js\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n */\nexport type UnionToIntersection<T> = (T extends T ? (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 * @sealed @alpha\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 * @alpha\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 * @alpha\n */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\n * Allows querying if an object has listeners.\n * @sealed @alpha\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 = createEmitter<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 * @alpha\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\t// Current TS (5.4.5) cannot spread `args` into `listener()`, but assigning to an array first makes it work.\n\t\t\tconst argArray: unknown[] = args;\n\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"]}
@@ -102,13 +102,11 @@ export declare class EagerMapTreeMapNode<TSchema extends FlexMapNodeSchema> exte
102
102
  FieldKey,
103
103
  FlexTreeUnboxField<TSchema["info"], "notEmpty">
104
104
  ]>;
105
- forEach(callbackFn: (value: FlexTreeUnboxField<TSchema["info"], "notEmpty">, key: FieldKey, map: FlexTreeMapNode<TSchema>) => void, thisArg?: unknown): void;
106
105
  getBoxed(key: string): FlexTreeTypedField<TSchema["info"]>;
107
106
  [Symbol.iterator](): IterableIterator<[
108
107
  FieldKey,
109
108
  FlexTreeUnboxField<TSchema["info"], "notEmpty">
110
109
  ]>;
111
- boxedIterator(): IterableIterator<FlexTreeTypedField<TSchema["info"]>>;
112
110
  }
113
111
  /**
114
112
  * A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.
@@ -1 +1 @@
1
- {"version":3,"file":"mapTreeNode.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-map-tree/mapTreeNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEb,KAAK,OAAO,EACZ,KAAK,wBAAwB,EAE7B,KAAK,KAAK,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,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G,WAAW,GAAG,SAAS,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,gBAAgB,GACvB,gBAAgB,CAAC,kBAAkB,CAAC,CAEtC;AA8HD,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAM7D"}
@@ -141,21 +141,12 @@ class EagerMapTreeMapNode extends EagerMapTreeNode {
141
141
  unboxedField(this.tryGetField(key) ?? (0, index_js_2.fail)("Unexpected empty map field"), key, this.mapTree, this),
142
142
  ]);
143
143
  }
144
- forEach(callbackFn, thisArg) {
145
- const fn = thisArg !== undefined ? callbackFn.bind(thisArg) : callbackFn;
146
- for (const [key, value] of this.entries()) {
147
- fn(value, key, this);
148
- }
149
- }
150
144
  getBoxed(key) {
151
145
  return super.getBoxed(key);
152
146
  }
153
147
  [Symbol.iterator]() {
154
148
  return this.entries();
155
149
  }
156
- boxedIterator() {
157
- return super.boxedIterator();
158
- }
159
150
  }
160
151
  exports.EagerMapTreeMapNode = EagerMapTreeMapNode;
161
152
  class EagerMapTreeLeafNode extends EagerMapTreeNode {
@@ -349,9 +340,6 @@ class EagerMapTreeSequenceField extends EagerMapTreeField {
349
340
  map(callbackfn) {
350
341
  return Array.from(this, callbackfn);
351
342
  }
352
- mapBoxed(callbackfn) {
353
- return Array.from(this.boxedIterator(), callbackfn);
354
- }
355
343
  *[Symbol.iterator]() {
356
344
  for (const [i, mapTree] of this.mapTrees.entries()) {
357
345
  yield unboxedUnion(this.schema, mapTree, { parent: this, index: i });
@@ -1 +1 @@
1
- {"version":3,"file":"mapTreeNode.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-map-tree/mapTreeNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAAkE;AAClE,kDAU6B;AAC7B,kDAA4E;AAC5E,oDAgB+B;AAC/B,uDAUkC;AAClC,kEAA+F;AAE/F,yDAAuF;AACvF,uEA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,IAAA,cAAG,GAAE,EAAE;gBAChD,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,CAAC;aACR,CAAC;YACH,CAAC,CAAC,SAAS,CACwB,CAAC;IACvC,CAAC;IAED,OAAO,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,WAAW,CAAqC,CAAC;AAC3F,CAAC;AAED,4CAA4C;AAE5C,SAAgB,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,qBAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype MapTree,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, fail, getOrCreate, mapIterable } from \"../../util/index.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeLeafNode,\n\ttype FlexTreeMapNode,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNode,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxField,\n\ttype FlexTreeUnboxNodeUnion,\n\tflexTreeMarker,\n\tindexForAt,\n} from \"../flex-tree/index.js\";\nimport {\n\ttype FlexAllowedTypes,\n\tFlexFieldSchema,\n\ttype FlexMapNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype LeafNodeSchema,\n\tisLazy,\n\tschemaIsLeaf,\n\tschemaIsMap,\n\tschemaIsObjectNode,\n} from \"../typed-schema/index.js\";\nimport { type FlexImplicitAllowedTypes, normalizeAllowedTypes } from \"../schemaBuilderBase.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport { FieldKinds, type SequenceFieldEditBuilder } from \"../default-schema/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n// #region Nodes\n\n/**\n * A readonly {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Reading data from the MapTreeNode will read the corresponding data from the {@link MapTree}.\n * Create a `MapTreeNode` by calling {@link getOrCreateMapTreeNode}.\n */\nexport interface MapTreeNode extends FlexTreeNode {\n\treadonly mapTree: MapTree;\n}\n\n/**\n * Checks if the given {@link FlexTreeNode} is a {@link MapTreeNode}.\n */\nexport function isMapTreeNode(flexNode: FlexTreeNode): flexNode is MapTreeNode {\n\treturn flexNode instanceof EagerMapTreeNode;\n}\n\n/**\n * Checks if the given {@link FlexTreeField} is a {@link MapTreeSequenceField}.\n */\nexport function isMapTreeSequenceField<T extends FlexAllowedTypes>(\n\tfield: FlexTreeSequenceField<T> | FlexTreeField,\n): field is MapTreeSequenceField<T> {\n\treturn field instanceof EagerMapTreeSequenceField;\n}\n\n/**\n * An unhydrated {@link FlexTreeSequenceField}, which has additional editing capabilities.\n * @remarks When doing a removal edit, a {@link MapTreeSequenceField}'s `editor` returns ownership of the removed {@link ExclusiveMapTree}s to the caller.\n */\nexport interface MapTreeSequenceField<T extends FlexAllowedTypes>\n\textends FlexTreeSequenceField<T> {\n\treadonly editor: MapTreeSequenceFieldEditBuilder;\n}\n\ninterface MapTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: MapTreeField;\n\treadonly index: number;\n}\n\n/**\n * A readonly implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Any methods that would mutate the node will fail,\n * as will the querying of data specific to the {@link LazyTreeNode} implementation (e.g. {@link FlexTreeNode.context}).\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `MapTreeNode` object.\n */\nexport class EagerMapTreeNode<TSchema extends FlexTreeNodeSchema> implements MapTreeNode {\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\t/**\n\t * Create a new MapTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a MapTreeNode from a {@link MapTree}.\n\t * A `MapTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schema: TSchema,\n\t\t/** The underlying {@link MapTree} that this `MapTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a MapTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing MapTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor MapTreeNode can be created after any number of its descendant MapTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all MapTreeNodes that are descendants of the ancestor MapTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding MapTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.schema.name;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: MapTreeField, index: number): void;\n\tpublic adoptBy(parent: MapTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.location === unparentedLocation,\n\t\t\t\t0x98c /* Node may not be adopted if it already has a parent */,\n\t\t\t);\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic is<TSchemaInner extends FlexTreeNodeSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedNode<TSchemaInner> {\n\t\treturn (schema as unknown) === this.schema;\n\t}\n\n\tpublic tryGetField(key: FieldKey): EagerMapTreeField<FlexAllowedTypes> | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(this, fieldKey, this.schema.getFieldSchema(fieldKey));\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.schema.getFieldSchema(key)),\n\t\t);\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic context = undefined;\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `MapTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(\"MapTreeNode does not implement anchorNode\");\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(\n\t\t\t\t\tmapTrees[index] ?? oob(),\n\t\t\t\t\tthis.schema.getFieldSchema(key).allowedTypes,\n\t\t\t\t\t{ parent: field, index },\n\t\t\t\t);\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * The implementation of a map node created by {@link getOrCreateNode}.\n */\nexport class EagerMapTreeMapNode<TSchema extends FlexMapNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeMapNode<TSchema>\n{\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic values(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">> {\n\t\treturn mapIterable(\n\t\t\tthis.mapTree.fields.keys(),\n\t\t\t(key) =>\n\t\t\t\tunboxedField(\n\t\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\t\tkey,\n\t\t\t\t\tthis.mapTree,\n\t\t\t\t\tthis,\n\t\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t);\n\t}\n\n\tpublic entries(): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn mapIterable(this.mapTree.fields.keys(), (key) => [\n\t\t\tkey,\n\t\t\tunboxedField(\n\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\tkey,\n\t\t\t\tthis.mapTree,\n\t\t\t\tthis,\n\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t]);\n\t}\n\n\tpublic forEach(\n\t\tcallbackFn: (\n\t\t\tvalue: FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t\tkey: FieldKey,\n\t\t\tmap: FlexTreeMapNode<TSchema>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tconst fn = thisArg !== undefined ? callbackFn.bind(thisArg) : callbackFn;\n\t\tfor (const [key, value] of this.entries()) {\n\t\t\tfn(value, key, this);\n\t\t}\n\t}\n\n\tpublic override getBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]> {\n\t\treturn super.getBoxed(key) as FlexTreeTypedField<TSchema[\"info\"]>;\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn this.entries();\n\t}\n\n\tpublic override boxedIterator(): IterableIterator<FlexTreeTypedField<TSchema[\"info\"]>> {\n\t\treturn super.boxedIterator() as IterableIterator<FlexTreeTypedField<TSchema[\"info\"]>>;\n\t}\n}\n\nclass EagerMapTreeLeafNode<TSchema extends LeafNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeLeafNode<TSchema>\n{\n\tpublic override get value(): TreeValue<TSchema[\"info\"]> {\n\t\treturn super.value as TreeValue<TSchema[\"info\"]>;\n\t}\n}\n\n// #endregion Nodes\n\n// #region Fields\n\n/**\n * A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.\n * @remarks Reading data from the MapTreeField will read the corresponding data from the {@link MapTree}s.\n * Create a `MapTreeField` by calling {@link getOrCreateField}.\n */\ninterface MapTreeField extends FlexTreeField {\n\treadonly mapTrees: readonly MapTree[];\n}\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link EagerMapTreeNode}s.\n * @remarks This exists because {@link EagerMapTreeNode.parentField} must return a field.\n * If a {@link EagerMapTreeNode} is created without a parent, its {@link EagerMapTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TSchema extends FlexFieldSchema>(schema: TSchema) {\n\t\t\treturn schema === (FlexFieldSchema.empty as FlexFieldSchema);\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: FlexFieldSchema.empty,\n\t\tcontext: undefined,\n\t\tmapTrees: [],\n\t},\n\tindex: -1,\n};\n\nclass EagerMapTreeField<T extends FlexAllowedTypes> implements MapTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic constructor(\n\t\tpublic readonly schema: FlexFieldSchema<FlexFieldKind, T>,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TSchemaInner extends FlexFieldSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedField<TSchemaInner> {\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<T>> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>;\n\t\t}\n\t}\n\n\tpublic context: undefined;\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\t}\n}\n\nclass EagerMapTreeOptionalField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeOptionalField<T>\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a MapTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a MapTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn unboxedUnion(this.schema, value, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: 0,\n\t\t\t});\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField<T extends FlexAllowedTypes>\n\textends EagerMapTreeOptionalField<T>\n\timplements FlexTreeRequiredField<T>\n{\n\tpublic override get content(): FlexTreeUnboxNodeUnion<T> {\n\t\treturn super.content ?? fail(\"Expected EagerMapTree required field to have a value\");\n\t}\n}\n\nclass EagerMapTreeSequenceField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeSequenceField<T>\n{\n\tpublic readonly editor: MapTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(\"Expected removed to be set by edit\");\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn unboxedUnion(this.schema, this.mapTrees[i] ?? oob(), { parent: this, index: i });\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<T>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\tpublic mapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<T>, index: number) => U): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<T>> {\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tyield unboxedUnion(this.schema, mapTree, { parent: this, index: i });\n\t\t}\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, EagerMapTreeNode<FlexTreeNodeSchema>>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<\n\tMapTreeNode,\n\tMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>>\n>();\nfunction getFieldKeyCache(\n\tparent: MapTreeNode,\n): WeakMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link EagerMapTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link EagerMapTreeNode | MapTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryGetMapTreeNode(mapTree: MapTree): MapTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/**\n * Create a {@link EagerMapTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n * @param mapTree - the {@link MapTree} containing the data for this node.\n * @remarks It must conform to the `nodeSchema`.\n */\nexport function getOrCreateMapTreeNode(\n\tnodeSchema: FlexTreeNodeSchema,\n\tmapTree: ExclusiveMapTree,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\treturn nodeCache.get(mapTree) ?? createNode(nodeSchema, mapTree, undefined);\n}\n\n/** Helper for creating a `MapTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tmapTree: ExclusiveMapTree,\n\timplicitAllowedTypes: FlexImplicitAllowedTypes,\n\tparent: LocationInField | undefined,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst allowedTypes = normalizeAllowedTypes(implicitAllowedTypes);\n\tconst nodeSchema =\n\t\tallowedTypes\n\t\t\t.map((t) => (isLazy(t) ? t() : t))\n\t\t\t.find((t): t is FlexTreeNodeSchema => {\n\t\t\t\tassert(t !== \"Any\", 0x993 /* 'Any' type is not supported */);\n\t\t\t\treturn t.name === mapTree.type;\n\t\t\t}) ?? fail(\"Unsupported node schema\");\n\n\treturn createNode(nodeSchema, mapTree, parent);\n}\n\n/** Always constructs a new node, therefore may not be called twice for the same `MapTree`. */\nfunction createNode<TSchema extends FlexTreeNodeSchema>(\n\tnodeSchema: TSchema,\n\tmapTree: ExclusiveMapTree,\n\tparentField: LocationInField | undefined,\n): EagerMapTreeNode<TSchema> {\n\tif (schemaIsLeaf(nodeSchema)) {\n\t\treturn new EagerMapTreeLeafNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsMap(nodeSchema)) {\n\t\treturn new EagerMapTreeMapNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsObjectNode(nodeSchema)) {\n\t\treturn new EagerMapTreeNode(nodeSchema, mapTree, parentField);\n\t}\n\tassert(false, 0x994 /* Unrecognized node kind */);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\tkey: FieldKey,\n\tschema: FlexFieldSchema,\n): EagerMapTreeField<FlexFieldSchema[\"allowedTypes\"]> {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema.kind.identifier === FieldKinds.required.identifier ||\n\t\tschema.kind.identifier === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.sequence.identifier) {\n\t\treturn new EagerMapTreeSequenceField(schema, key, parent);\n\t}\n\n\treturn new EagerMapTreeField(schema, key, parent);\n}\n\n/** Unboxes non-polymorphic leaf nodes to their values, if applicable */\nfunction unboxedUnion<TTypes extends FlexAllowedTypes>(\n\tschema: FlexFieldSchema<FlexFieldKind, TTypes>,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField,\n): FlexTreeUnboxNodeUnion<TTypes> {\n\tconst type = schema.monomorphicChildType;\n\tif (type !== undefined) {\n\t\tif (schemaIsLeaf(type)) {\n\t\t\treturn mapTree.value as FlexTreeUnboxNodeUnion<TTypes>;\n\t\t}\n\t\treturn getOrCreateChild(mapTree, type, parent) as FlexTreeUnboxNodeUnion<TTypes>;\n\t}\n\n\treturn getOrCreateChild(\n\t\tmapTree,\n\t\tschema.allowedTypes,\n\t\tparent,\n\t) as FlexTreeUnboxNodeUnion<TTypes>;\n}\n\n/** Unboxes non-polymorphic required and optional fields holding leaf nodes to their values, if applicable */\nfunction unboxedField<TFieldSchema extends FlexFieldSchema>(\n\tfield: EagerMapTreeField<FlexAllowedTypes>,\n\tkey: FieldKey,\n\tmapTree: ExclusiveMapTree,\n\tparentNode: EagerMapTreeNode<FlexTreeNodeSchema>,\n): FlexTreeUnboxField<TFieldSchema> {\n\tconst fieldSchema = field.schema;\n\tconst mapTrees =\n\t\tmapTree.fields.get(key) ?? fail(\"Key does not exist in unhydrated map tree\");\n\n\tif (fieldSchema.kind === FieldKinds.required) {\n\t\treturn unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\tparent: field,\n\t\t\tindex: 0,\n\t\t}) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\tif (fieldSchema.kind === FieldKinds.optional) {\n\t\treturn (\n\t\t\tmapTrees.length > 0\n\t\t\t\t? unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\t\t\t\tparent: field,\n\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t})\n\t\t\t\t: undefined\n\t\t) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\n\treturn getOrCreateField(parentNode, key, fieldSchema) as FlexTreeUnboxField<TFieldSchema>;\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
1
+ {"version":3,"file":"mapTreeNode.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-map-tree/mapTreeNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAAkE;AAClE,kD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M,CAAmC,CAAC;IAClF,CAAC;IAED,OAAO,gBAAgB,CACtB,OAAO,EACP,MAAM,CAAC,YAAY,EACnB,MAAM,CAC4B,CAAC;AACrC,CAAC;AAED,6GAA6G;AAC7G,SAAS,YAAY,CACpB,KAA0C,EAC1C,GAAa,EACb,OAAyB,EACzB,UAAgD;IAEhD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,MAAM,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,2CAA2C,CAAC,CAAC;IAE9E,IAAI,WAAW,CAAC,IAAI,KAAK,qBAAU,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,EAAE;YACtD,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,CAAC;SACR,CAAqC,CAAC;IACxC,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,qBAAU,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,CACN,QAAQ,CAAC,MAAM,GAAG,CAAC;YAClB,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,EAAE;gBAChD,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,CAAC;aACR,CAAC;YACH,CAAC,CAAC,SAAS,CACwB,CAAC;IACvC,CAAC;IAED,OAAO,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,WAAW,CAAqC,CAAC;AAC3F,CAAC;AAED,4CAA4C;AAE5C,SAAgB,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,qBAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype MapTree,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, fail, getOrCreate, mapIterable } from \"../../util/index.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeLeafNode,\n\ttype FlexTreeMapNode,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNode,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxField,\n\ttype FlexTreeUnboxNodeUnion,\n\tflexTreeMarker,\n\tindexForAt,\n} from \"../flex-tree/index.js\";\nimport {\n\ttype FlexAllowedTypes,\n\tFlexFieldSchema,\n\ttype FlexMapNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype LeafNodeSchema,\n\tisLazy,\n\tschemaIsLeaf,\n\tschemaIsMap,\n\tschemaIsObjectNode,\n} from \"../typed-schema/index.js\";\nimport { type FlexImplicitAllowedTypes, normalizeAllowedTypes } from \"../schemaBuilderBase.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport { FieldKinds, type SequenceFieldEditBuilder } from \"../default-schema/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n// #region Nodes\n\n/**\n * A readonly {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Reading data from the MapTreeNode will read the corresponding data from the {@link MapTree}.\n * Create a `MapTreeNode` by calling {@link getOrCreateMapTreeNode}.\n */\nexport interface MapTreeNode extends FlexTreeNode {\n\treadonly mapTree: MapTree;\n}\n\n/**\n * Checks if the given {@link FlexTreeNode} is a {@link MapTreeNode}.\n */\nexport function isMapTreeNode(flexNode: FlexTreeNode): flexNode is MapTreeNode {\n\treturn flexNode instanceof EagerMapTreeNode;\n}\n\n/**\n * Checks if the given {@link FlexTreeField} is a {@link MapTreeSequenceField}.\n */\nexport function isMapTreeSequenceField<T extends FlexAllowedTypes>(\n\tfield: FlexTreeSequenceField<T> | FlexTreeField,\n): field is MapTreeSequenceField<T> {\n\treturn field instanceof EagerMapTreeSequenceField;\n}\n\n/**\n * An unhydrated {@link FlexTreeSequenceField}, which has additional editing capabilities.\n * @remarks When doing a removal edit, a {@link MapTreeSequenceField}'s `editor` returns ownership of the removed {@link ExclusiveMapTree}s to the caller.\n */\nexport interface MapTreeSequenceField<T extends FlexAllowedTypes>\n\textends FlexTreeSequenceField<T> {\n\treadonly editor: MapTreeSequenceFieldEditBuilder;\n}\n\ninterface MapTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: MapTreeField;\n\treadonly index: number;\n}\n\n/**\n * A readonly implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Any methods that would mutate the node will fail,\n * as will the querying of data specific to the {@link LazyTreeNode} implementation (e.g. {@link FlexTreeNode.context}).\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `MapTreeNode` object.\n */\nexport class EagerMapTreeNode<TSchema extends FlexTreeNodeSchema> implements MapTreeNode {\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\t/**\n\t * Create a new MapTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a MapTreeNode from a {@link MapTree}.\n\t * A `MapTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schema: TSchema,\n\t\t/** The underlying {@link MapTree} that this `MapTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a MapTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing MapTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor MapTreeNode can be created after any number of its descendant MapTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all MapTreeNodes that are descendants of the ancestor MapTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding MapTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.schema.name;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: MapTreeField, index: number): void;\n\tpublic adoptBy(parent: MapTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.location === unparentedLocation,\n\t\t\t\t0x98c /* Node may not be adopted if it already has a parent */,\n\t\t\t);\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic is<TSchemaInner extends FlexTreeNodeSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedNode<TSchemaInner> {\n\t\treturn (schema as unknown) === this.schema;\n\t}\n\n\tpublic tryGetField(key: FieldKey): EagerMapTreeField<FlexAllowedTypes> | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(this, fieldKey, this.schema.getFieldSchema(fieldKey));\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.schema.getFieldSchema(key)),\n\t\t);\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic context = undefined;\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `MapTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(\"MapTreeNode does not implement anchorNode\");\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(\n\t\t\t\t\tmapTrees[index] ?? oob(),\n\t\t\t\t\tthis.schema.getFieldSchema(key).allowedTypes,\n\t\t\t\t\t{ parent: field, index },\n\t\t\t\t);\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * The implementation of a map node created by {@link getOrCreateNode}.\n */\nexport class EagerMapTreeMapNode<TSchema extends FlexMapNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeMapNode<TSchema>\n{\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic values(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">> {\n\t\treturn mapIterable(\n\t\t\tthis.mapTree.fields.keys(),\n\t\t\t(key) =>\n\t\t\t\tunboxedField(\n\t\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\t\tkey,\n\t\t\t\t\tthis.mapTree,\n\t\t\t\t\tthis,\n\t\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t);\n\t}\n\n\tpublic entries(): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn mapIterable(this.mapTree.fields.keys(), (key) => [\n\t\t\tkey,\n\t\t\tunboxedField(\n\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\tkey,\n\t\t\t\tthis.mapTree,\n\t\t\t\tthis,\n\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t]);\n\t}\n\n\tpublic override getBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]> {\n\t\treturn super.getBoxed(key) as FlexTreeTypedField<TSchema[\"info\"]>;\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn this.entries();\n\t}\n}\n\nclass EagerMapTreeLeafNode<TSchema extends LeafNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeLeafNode<TSchema>\n{\n\tpublic override get value(): TreeValue<TSchema[\"info\"]> {\n\t\treturn super.value as TreeValue<TSchema[\"info\"]>;\n\t}\n}\n\n// #endregion Nodes\n\n// #region Fields\n\n/**\n * A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.\n * @remarks Reading data from the MapTreeField will read the corresponding data from the {@link MapTree}s.\n * Create a `MapTreeField` by calling {@link getOrCreateField}.\n */\ninterface MapTreeField extends FlexTreeField {\n\treadonly mapTrees: readonly MapTree[];\n}\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link EagerMapTreeNode}s.\n * @remarks This exists because {@link EagerMapTreeNode.parentField} must return a field.\n * If a {@link EagerMapTreeNode} is created without a parent, its {@link EagerMapTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TSchema extends FlexFieldSchema>(schema: TSchema) {\n\t\t\treturn schema === (FlexFieldSchema.empty as FlexFieldSchema);\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: FlexFieldSchema.empty,\n\t\tcontext: undefined,\n\t\tmapTrees: [],\n\t},\n\tindex: -1,\n};\n\nclass EagerMapTreeField<T extends FlexAllowedTypes> implements MapTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic constructor(\n\t\tpublic readonly schema: FlexFieldSchema<FlexFieldKind, T>,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TSchemaInner extends FlexFieldSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedField<TSchemaInner> {\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<T>> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>;\n\t\t}\n\t}\n\n\tpublic context: undefined;\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\t}\n}\n\nclass EagerMapTreeOptionalField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeOptionalField<T>\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a MapTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a MapTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn unboxedUnion(this.schema, value, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: 0,\n\t\t\t});\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField<T extends FlexAllowedTypes>\n\textends EagerMapTreeOptionalField<T>\n\timplements FlexTreeRequiredField<T>\n{\n\tpublic override get content(): FlexTreeUnboxNodeUnion<T> {\n\t\treturn super.content ?? fail(\"Expected EagerMapTree required field to have a value\");\n\t}\n}\n\nclass EagerMapTreeSequenceField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeSequenceField<T>\n{\n\tpublic readonly editor: MapTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(\"Expected removed to be set by edit\");\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn unboxedUnion(this.schema, this.mapTrees[i] ?? oob(), { parent: this, index: i });\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<T>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<T>> {\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tyield unboxedUnion(this.schema, mapTree, { parent: this, index: i });\n\t\t}\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, EagerMapTreeNode<FlexTreeNodeSchema>>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<\n\tMapTreeNode,\n\tMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>>\n>();\nfunction getFieldKeyCache(\n\tparent: MapTreeNode,\n): WeakMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link EagerMapTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link EagerMapTreeNode | MapTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryGetMapTreeNode(mapTree: MapTree): MapTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/**\n * Create a {@link EagerMapTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n * @param mapTree - the {@link MapTree} containing the data for this node.\n * @remarks It must conform to the `nodeSchema`.\n */\nexport function getOrCreateMapTreeNode(\n\tnodeSchema: FlexTreeNodeSchema,\n\tmapTree: ExclusiveMapTree,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\treturn nodeCache.get(mapTree) ?? createNode(nodeSchema, mapTree, undefined);\n}\n\n/** Helper for creating a `MapTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tmapTree: ExclusiveMapTree,\n\timplicitAllowedTypes: FlexImplicitAllowedTypes,\n\tparent: LocationInField | undefined,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst allowedTypes = normalizeAllowedTypes(implicitAllowedTypes);\n\tconst nodeSchema =\n\t\tallowedTypes\n\t\t\t.map((t) => (isLazy(t) ? t() : t))\n\t\t\t.find((t): t is FlexTreeNodeSchema => {\n\t\t\t\tassert(t !== \"Any\", 0x993 /* 'Any' type is not supported */);\n\t\t\t\treturn t.name === mapTree.type;\n\t\t\t}) ?? fail(\"Unsupported node schema\");\n\n\treturn createNode(nodeSchema, mapTree, parent);\n}\n\n/** Always constructs a new node, therefore may not be called twice for the same `MapTree`. */\nfunction createNode<TSchema extends FlexTreeNodeSchema>(\n\tnodeSchema: TSchema,\n\tmapTree: ExclusiveMapTree,\n\tparentField: LocationInField | undefined,\n): EagerMapTreeNode<TSchema> {\n\tif (schemaIsLeaf(nodeSchema)) {\n\t\treturn new EagerMapTreeLeafNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsMap(nodeSchema)) {\n\t\treturn new EagerMapTreeMapNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsObjectNode(nodeSchema)) {\n\t\treturn new EagerMapTreeNode(nodeSchema, mapTree, parentField);\n\t}\n\tassert(false, 0x994 /* Unrecognized node kind */);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\tkey: FieldKey,\n\tschema: FlexFieldSchema,\n): EagerMapTreeField<FlexFieldSchema[\"allowedTypes\"]> {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema.kind.identifier === FieldKinds.required.identifier ||\n\t\tschema.kind.identifier === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.sequence.identifier) {\n\t\treturn new EagerMapTreeSequenceField(schema, key, parent);\n\t}\n\n\treturn new EagerMapTreeField(schema, key, parent);\n}\n\n/** Unboxes non-polymorphic leaf nodes to their values, if applicable */\nfunction unboxedUnion<TTypes extends FlexAllowedTypes>(\n\tschema: FlexFieldSchema<FlexFieldKind, TTypes>,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField,\n): FlexTreeUnboxNodeUnion<TTypes> {\n\tconst type = schema.monomorphicChildType;\n\tif (type !== undefined) {\n\t\tif (schemaIsLeaf(type)) {\n\t\t\treturn mapTree.value as FlexTreeUnboxNodeUnion<TTypes>;\n\t\t}\n\t\treturn getOrCreateChild(mapTree, type, parent) as FlexTreeUnboxNodeUnion<TTypes>;\n\t}\n\n\treturn getOrCreateChild(\n\t\tmapTree,\n\t\tschema.allowedTypes,\n\t\tparent,\n\t) as FlexTreeUnboxNodeUnion<TTypes>;\n}\n\n/** Unboxes non-polymorphic required and optional fields holding leaf nodes to their values, if applicable */\nfunction unboxedField<TFieldSchema extends FlexFieldSchema>(\n\tfield: EagerMapTreeField<FlexAllowedTypes>,\n\tkey: FieldKey,\n\tmapTree: ExclusiveMapTree,\n\tparentNode: EagerMapTreeNode<FlexTreeNodeSchema>,\n): FlexTreeUnboxField<TFieldSchema> {\n\tconst fieldSchema = field.schema;\n\tconst mapTrees =\n\t\tmapTree.fields.get(key) ?? fail(\"Key does not exist in unhydrated map tree\");\n\n\tif (fieldSchema.kind === FieldKinds.required) {\n\t\treturn unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\tparent: field,\n\t\t\tindex: 0,\n\t\t}) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\tif (fieldSchema.kind === FieldKinds.optional) {\n\t\treturn (\n\t\t\tmapTrees.length > 0\n\t\t\t\t? unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\t\t\t\tparent: field,\n\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t})\n\t\t\t\t: undefined\n\t\t) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\n\treturn getOrCreateField(parentNode, key, fieldSchema) as FlexTreeUnboxField<TFieldSchema>;\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
@@ -3,10 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type AnchorNode, type ExclusiveMapTree, type FieldKey, type FieldUpPath, type TreeValue } from "../../core/index.js";
6
- import type { Assume, FlattenKeys } from "../../util/index.js";
6
+ import type { Assume } from "../../util/index.js";
7
7
  import type { FieldKinds, SequenceFieldEditBuilder, ValueFieldEditBuilder, OptionalFieldEditBuilder } from "../default-schema/index.js";
8
8
  import type { FlexFieldKind } from "../modular-schema/index.js";
9
- import type { Any, FlexAllowedTypes, FlexFieldSchema, FlexList, FlexListToUnion, FlexMapNodeSchema, FlexObjectNodeFields, FlexObjectNodeSchema, FlexTreeNodeSchema, LazyItem, LeafNodeSchema } from "../typed-schema/index.js";
9
+ import type { Any, FlexAllowedTypes, FlexFieldSchema, FlexList, FlexListToUnion, FlexMapNodeSchema, FlexObjectNodeSchema, FlexTreeNodeSchema, LazyItem, LeafNodeSchema } from "../typed-schema/index.js";
10
10
  import type { FlexTreeContext } from "./context.js";
11
11
  /**
12
12
  * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.
@@ -245,23 +245,6 @@ export interface FlexTreeMapNode<in out TSchema extends FlexMapNodeSchema> exten
245
245
  * No guarantees are made regarding the order of the entries returned.
246
246
  */
247
247
  entries(): IterableIterator<[FieldKey, FlexTreeUnboxField<TSchema["info"], "notEmpty">]>;
248
- /**
249
- * Executes a provided function once per each key/value pair in the map.
250
- * @param callbackFn - The function to run for each map entry
251
- * @param thisArg - If present, `callbackFn` will be bound to `thisArg`
252
- *
253
- * @privateRemarks
254
- * TODO: This should run over fields in insertion order if we want to match the javascript foreach spec.
255
- */
256
- forEach(callbackFn: (value: FlexTreeUnboxField<TSchema["info"], "notEmpty">, key: FieldKey, map: FlexTreeMapNode<TSchema>) => void, thisArg?: any): void;
257
- /**
258
- * Iterate through all fields in the map.
259
- *
260
- * @remarks
261
- * No mutations to the current view of the shared tree are permitted during iteration.
262
- * To iterate over the unboxed values of the map, use `Symbol.Iterator()`.
263
- */
264
- boxedIterator(): IterableIterator<FlexTreeTypedField<TSchema["info"]>>;
265
248
  [Symbol.iterator](): IterableIterator<[
266
249
  FieldKey,
267
250
  FlexTreeUnboxField<TSchema["info"], "notEmpty">
@@ -274,7 +257,6 @@ export interface FlexTreeMapNode<in out TSchema extends FlexMapNodeSchema> exten
274
257
  *
275
258
  * @remarks
276
259
  * ObjectNodes require complex typing, and have been split into two parts for implementation purposes.
277
- * See {@link FlexTreeObjectNodeTyped} for the schema aware extensions to this that provide access to the fields.
278
260
  *
279
261
  * These "Objects" resemble "Structs" from a wide variety of programming languages
280
262
  * (Including Algol 68, C, Go, Rust, C# etc.).
@@ -303,74 +285,6 @@ export interface FlexTreeLeafNode<in out TSchema extends LeafNodeSchema> extends
303
285
  */
304
286
  readonly value: TreeValue<TSchema["info"]>;
305
287
  }
306
- /**
307
- * An {@link FlexTreeObjectNode} with schema aware accessors for its fields.
308
- *
309
- * @privateRemarks
310
- *
311
- * The corresponding implementation logic for this lives in `LazyTree.ts` under `buildStructClass`.
312
- * If you change the signature here, you will need to update that logic to match.
313
- */
314
- export type FlexTreeObjectNodeTyped<TSchema extends FlexObjectNodeSchema> = FlexObjectNodeSchema extends TSchema ? FlexTreeObjectNode : FlexTreeObjectNode & FlexTreeObjectNodeFields<TSchema["info"]>;
315
- /**
316
- * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.
317
- *
318
- * @privateRemarks
319
- * TODO: Support custom field keys.
320
- */
321
- export type FlexTreeObjectNodeFields<TFields extends FlexObjectNodeFields> = FlexTreeObjectNodeFieldsInner<FlattenKeys<{
322
- [key in keyof TFields as key extends PropertyNameFromFieldKey<key & string> ? key : never]: TFields[key];
323
- } & {
324
- [key in keyof TFields as key extends PropertyNameFromFieldKey<key & string> ? never : PropertyNameFromFieldKey<key & string>]: TFields[key];
325
- }>>;
326
- /**
327
- * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.
328
- *
329
- * @privateRemarks
330
- * TODO: Do we keep assignment operator + "setFoo" methods, or just use methods?
331
- * Inconsistency in the API experience could confusing for consumers.
332
- */
333
- export type FlexTreeObjectNodeFieldsInner<TFields extends FlexObjectNodeFields> = FlattenKeys<{
334
- readonly [key in keyof TFields as `boxed${Capitalize<key & string>}`]: FlexTreeTypedField<TFields[key]>;
335
- } & {
336
- readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? never : key]: FlexTreeUnboxField<TFields[key]>;
337
- } & {
338
- -readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? key : never]: FlexTreeUnboxField<TFields[key]>;
339
- } & {
340
- readonly [key in keyof TFields as TFields[key]["kind"] extends AssignableFieldKinds ? `set${Capitalize<key & string>}` : never]: (content: FlexibleNodeContent) => void;
341
- }>;
342
- /**
343
- * Reserved object node field property names to avoid collisions with the rest of the object node API.
344
- */
345
- export declare const reservedObjectNodeFieldPropertyNames: readonly ["anchorNode", "constructor", "context", "is", "parentField", "schema", "tryGetField", "type", "value", "boxedIterator", "iterator", "getBoxed"];
346
- /**
347
- * Reserved object node field property names prefixes.
348
- * These are reserved to avoid collisions with properties derived from field other field names.
349
- *
350
- * Field names starting with these must be followed by a lowercase letter, or be escaped.
351
- */
352
- export declare const reservedObjectNodeFieldPropertyNamePrefixes: readonly ["set", "boxed", "field", "Field"];
353
- /**
354
- * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.
355
- */
356
- export type ReservedObjectNodeFieldPropertyNames = (typeof reservedObjectNodeFieldPropertyNames)[number];
357
- /**
358
- * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.
359
- */
360
- export type ReservedObjectNodeFieldPropertyNamePrefixes = (typeof reservedObjectNodeFieldPropertyNamePrefixes)[number];
361
- /**
362
- * Convert an object node's field key into an escaped string usable as a property name.
363
- *
364
- * @privateRemarks
365
- * TODO:
366
- * Collisions are still possible.
367
- * For example fields named "foo" and "Foo" would both produce a setter "setFoo".
368
- * Consider naming schemes to avoid this, ensure that there is a good workaround for these cases.
369
- * Another approach would be to support custom field names (separate from keys),
370
- * and do the escaping (if needed) when creating the flex tree schema (both when manually creating them and when doing so automatically):
371
- * this would enable better intellisense for escaped fields, as well as allow the feature of custom field property names.
372
- */
373
- export type PropertyNameFromFieldKey<T extends string> = T extends ReservedObjectNodeFieldPropertyNames ? `field${Capitalize<T>}` : T extends `${ReservedObjectNodeFieldPropertyNamePrefixes}${Capitalize<string>}` ? `field${Capitalize<T>}` : T;
374
288
  /**
375
289
  * Field kinds that allow value assignment.
376
290
  */
@@ -434,11 +348,6 @@ export interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes> e
434
348
  * @param callbackfn - A function that accepts the child and its index.
435
349
  */
436
350
  map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[];
437
- /**
438
- * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.
439
- * @param callbackfn - A function that accepts the child and its index.
440
- */
441
- mapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U): U[];
442
351
  readonly length: number;
443
352
  /**
444
353
  * Get an editor for this sequence.
@@ -493,7 +402,7 @@ export type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> = T extends FlexL
493
402
  /**
494
403
  * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexTreeNodeSchema}.
495
404
  */
496
- export type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? FlexTreeLeafNode<TSchema> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeNode;
405
+ export type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? FlexTreeLeafNode<TSchema> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNode : FlexTreeNode;
497
406
  /**
498
407
  * Schema aware unboxed field.
499
408
  * @remarks
@@ -526,7 +435,7 @@ export type IsArrayOfOne<T extends readonly unknown[]> = T["length"] extends 1 ?
526
435
  * Unboxes if the node kind does unboxing.
527
436
  * Recursively unboxes that content as well if it does unboxing.
528
437
  */
529
- export type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNodeTyped<TSchema> : FlexTreeUnknownUnboxed;
438
+ export type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> = TSchema extends LeafNodeSchema ? TreeValue<TSchema["info"]> : TSchema extends FlexMapNodeSchema ? FlexTreeMapNode<TSchema> : TSchema extends FlexObjectNodeSchema ? FlexTreeObjectNode : FlexTreeUnknownUnboxed;
530
439
  /**
531
440
  * Unboxed tree type for unknown schema cases.
532
441
  */