@fluidframework/tree 2.0.0-dev-rc.2.0.0.245554 → 2.0.0-dev-rc.2.0.0.246488

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 (268) hide show
  1. package/api-report/tree.api.md +32 -3
  2. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  3. package/dist/codec/discriminatedUnions.js +4 -0
  4. package/dist/codec/discriminatedUnions.js.map +1 -1
  5. package/dist/codec/index.d.ts.map +1 -1
  6. package/dist/codec/index.js +2 -2
  7. package/dist/codec/index.js.map +1 -1
  8. package/dist/core/tree/visitDelta.d.ts +4 -0
  9. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  10. package/dist/core/tree/visitDelta.js +2 -2
  11. package/dist/core/tree/visitDelta.js.map +1 -1
  12. package/dist/core/tree/visitPath.d.ts.map +1 -1
  13. package/dist/core/tree/visitPath.js +4 -0
  14. package/dist/core/tree/visitPath.js.map +1 -1
  15. package/dist/domains/schemaBuilder.d.ts +1 -13
  16. package/dist/domains/schemaBuilder.d.ts.map +1 -1
  17. package/dist/domains/schemaBuilder.js +0 -12
  18. package/dist/domains/schemaBuilder.js.map +1 -1
  19. package/dist/domains/testRecursiveDomain.d.ts +0 -4
  20. package/dist/domains/testRecursiveDomain.d.ts.map +1 -1
  21. package/dist/domains/testRecursiveDomain.js +1 -8
  22. package/dist/domains/testRecursiveDomain.js.map +1 -1
  23. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +1 -1
  24. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +1 -1
  25. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  26. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  27. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +3 -3
  28. package/dist/feature-libraries/multiplicity.d.ts.map +1 -1
  29. package/dist/feature-libraries/multiplicity.js +2 -2
  30. package/dist/feature-libraries/multiplicity.js.map +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/packageVersion.d.ts +1 -1
  36. package/dist/packageVersion.js +1 -1
  37. package/dist/packageVersion.js.map +1 -1
  38. package/dist/shared-tree/schematizingTreeView.d.ts +4 -0
  39. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  40. package/dist/shared-tree/schematizingTreeView.js +2 -2
  41. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  42. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  43. package/dist/shared-tree/treeApi.d.ts +4 -0
  44. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  45. package/dist/shared-tree/treeApi.js +2 -2
  46. package/dist/shared-tree/treeApi.js.map +1 -1
  47. package/dist/shared-tree/treeCheckout.d.ts +4 -0
  48. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  49. package/dist/shared-tree/treeCheckout.js +2 -2
  50. package/dist/shared-tree/treeCheckout.js.map +1 -1
  51. package/dist/shared-tree-core/branch.js +4 -4
  52. package/dist/shared-tree-core/branch.js.map +1 -1
  53. package/dist/shared-tree-core/index.d.ts.map +1 -1
  54. package/dist/shared-tree-core/index.js +2 -2
  55. package/dist/shared-tree-core/index.js.map +1 -1
  56. package/dist/simple-tree/toFlexSchema.d.ts +4 -0
  57. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  58. package/dist/simple-tree/toFlexSchema.js +2 -2
  59. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  60. package/dist/simple-tree/toMapTree.js +1 -1
  61. package/dist/simple-tree/toMapTree.js.map +1 -1
  62. package/dist/tree-alpha.d.ts +6 -0
  63. package/dist/tree-beta.d.ts +6 -0
  64. package/dist/tree-public.d.ts +6 -0
  65. package/dist/tree-untrimmed.d.ts +107 -14
  66. package/dist/util/brand.d.ts +50 -59
  67. package/dist/util/brand.d.ts.map +1 -1
  68. package/dist/util/brand.js +32 -48
  69. package/dist/util/brand.js.map +1 -1
  70. package/dist/util/index.d.ts +5 -3
  71. package/dist/util/index.d.ts.map +1 -1
  72. package/dist/util/index.js +7 -5
  73. package/dist/util/index.js.map +1 -1
  74. package/dist/util/opaque.d.ts +46 -0
  75. package/dist/util/opaque.d.ts.map +1 -0
  76. package/dist/util/opaque.js +29 -0
  77. package/dist/util/opaque.js.map +1 -0
  78. package/dist/util/typeCheckTests.d.ts +1 -1
  79. package/dist/util/typeCheckTests.d.ts.map +1 -1
  80. package/dist/util/typeCheckTests.js.map +1 -1
  81. package/dist/util/typeUtils.d.ts +13 -0
  82. package/dist/util/typeUtils.d.ts.map +1 -1
  83. package/dist/util/typeUtils.js.map +1 -1
  84. package/dist/util/typeboxBrand.d.ts +17 -0
  85. package/dist/util/typeboxBrand.d.ts.map +1 -0
  86. package/dist/util/typeboxBrand.js +32 -0
  87. package/dist/util/typeboxBrand.js.map +1 -0
  88. package/dist/util/utils.d.ts +0 -13
  89. package/dist/util/utils.d.ts.map +1 -1
  90. package/dist/util/utils.js.map +1 -1
  91. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  92. package/lib/codec/discriminatedUnions.js +4 -0
  93. package/lib/codec/discriminatedUnions.js.map +1 -1
  94. package/lib/codec/index.d.ts.map +1 -1
  95. package/lib/codec/index.js.map +1 -1
  96. package/lib/core/tree/visitDelta.d.ts +4 -0
  97. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  98. package/lib/core/tree/visitDelta.js.map +1 -1
  99. package/lib/core/tree/visitPath.d.ts.map +1 -1
  100. package/lib/core/tree/visitPath.js +4 -0
  101. package/lib/core/tree/visitPath.js.map +1 -1
  102. package/lib/domains/schemaBuilder.d.ts +1 -13
  103. package/lib/domains/schemaBuilder.d.ts.map +1 -1
  104. package/lib/domains/schemaBuilder.js +0 -12
  105. package/lib/domains/schemaBuilder.js.map +1 -1
  106. package/lib/domains/testRecursiveDomain.d.ts +0 -4
  107. package/lib/domains/testRecursiveDomain.d.ts.map +1 -1
  108. package/lib/domains/testRecursiveDomain.js +1 -8
  109. package/lib/domains/testRecursiveDomain.js.map +1 -1
  110. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +1 -1
  111. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +1 -1
  112. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  113. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  114. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +3 -3
  115. package/lib/feature-libraries/multiplicity.d.ts.map +1 -1
  116. package/lib/feature-libraries/multiplicity.js.map +1 -1
  117. package/lib/index.d.ts +1 -1
  118. package/lib/index.d.ts.map +1 -1
  119. package/lib/index.js +1 -1
  120. package/lib/index.js.map +1 -1
  121. package/lib/packageVersion.d.ts +1 -1
  122. package/lib/packageVersion.js +1 -1
  123. package/lib/packageVersion.js.map +1 -1
  124. package/lib/shared-tree/schematizingTreeView.d.ts +4 -0
  125. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  126. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  127. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  128. package/lib/shared-tree/treeApi.d.ts +4 -0
  129. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  130. package/lib/shared-tree/treeApi.js.map +1 -1
  131. package/lib/shared-tree/treeCheckout.d.ts +4 -0
  132. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  133. package/lib/shared-tree/treeCheckout.js.map +1 -1
  134. package/lib/shared-tree-core/branch.js +4 -4
  135. package/lib/shared-tree-core/branch.js.map +1 -1
  136. package/lib/shared-tree-core/index.d.ts.map +1 -1
  137. package/lib/shared-tree-core/index.js.map +1 -1
  138. package/lib/simple-tree/toFlexSchema.d.ts +4 -0
  139. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  140. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  141. package/lib/simple-tree/toMapTree.js +1 -1
  142. package/lib/simple-tree/toMapTree.js.map +1 -1
  143. package/lib/test/domains/schemaBuilder.spec.js +0 -14
  144. package/lib/test/domains/schemaBuilder.spec.js.map +1 -1
  145. package/lib/test/feature-libraries/chunked-forest/chunkEncodingEndToEnd.d.ts +4 -0
  146. package/lib/test/feature-libraries/chunked-forest/chunkEncodingEndToEnd.d.ts.map +1 -1
  147. package/lib/test/feature-libraries/chunked-forest/chunkEncodingEndToEnd.js.map +1 -1
  148. package/lib/test/feature-libraries/contextuallyTyped.spec.js +2 -4
  149. package/lib/test/feature-libraries/contextuallyTyped.spec.js.map +1 -1
  150. package/lib/test/feature-libraries/flex-tree/events.spec.d.ts +4 -0
  151. package/lib/test/feature-libraries/flex-tree/events.spec.d.ts.map +1 -1
  152. package/lib/test/feature-libraries/flex-tree/events.spec.js.map +1 -1
  153. package/lib/test/feature-libraries/schemaBuilder.spec.js +2 -23
  154. package/lib/test/feature-libraries/schemaBuilder.spec.js.map +1 -1
  155. package/lib/test/scalableTestTrees.d.ts +4 -0
  156. package/lib/test/scalableTestTrees.d.ts.map +1 -1
  157. package/lib/test/scalableTestTrees.js.map +1 -1
  158. package/lib/test/shared-tree/editing.spec.d.ts +4 -0
  159. package/lib/test/shared-tree/editing.spec.d.ts.map +1 -1
  160. package/lib/test/shared-tree/editing.spec.js.map +1 -1
  161. package/lib/test/shared-tree/fuzz/anchorStability.fuzz.spec.d.ts +4 -0
  162. package/lib/test/shared-tree/fuzz/anchorStability.fuzz.spec.d.ts.map +1 -1
  163. package/lib/test/shared-tree/fuzz/anchorStability.fuzz.spec.js.map +1 -1
  164. package/lib/test/shared-tree/fuzz/composeVsIndividual.fuzz.spec.d.ts +4 -0
  165. package/lib/test/shared-tree/fuzz/composeVsIndividual.fuzz.spec.d.ts.map +1 -1
  166. package/lib/test/shared-tree/fuzz/composeVsIndividual.fuzz.spec.js.map +1 -1
  167. package/lib/test/shared-tree/fuzz/fuzzEditGenerators.d.ts +4 -0
  168. package/lib/test/shared-tree/fuzz/fuzzEditGenerators.d.ts.map +1 -1
  169. package/lib/test/shared-tree/fuzz/fuzzEditGenerators.js.map +1 -1
  170. package/lib/test/shared-tree/fuzz/fuzzUtils.d.ts +4 -0
  171. package/lib/test/shared-tree/fuzz/fuzzUtils.d.ts.map +1 -1
  172. package/lib/test/shared-tree/fuzz/fuzzUtils.js.map +1 -1
  173. package/lib/test/shared-tree/fuzz/topLevel.fuzz.spec.d.ts +4 -0
  174. package/lib/test/shared-tree/fuzz/topLevel.fuzz.spec.d.ts.map +1 -1
  175. package/lib/test/shared-tree/fuzz/topLevel.fuzz.spec.js.map +1 -1
  176. package/lib/test/shared-tree/opSize.bench.d.ts +4 -0
  177. package/lib/test/shared-tree/opSize.bench.d.ts.map +1 -1
  178. package/lib/test/shared-tree/opSize.bench.js.map +1 -1
  179. package/lib/test/shared-tree/sharedTree.bench.d.ts +4 -0
  180. package/lib/test/shared-tree/sharedTree.bench.d.ts.map +1 -1
  181. package/lib/test/shared-tree/sharedTree.bench.js.map +1 -1
  182. package/lib/test/shared-tree/sharedTree.spec.d.ts +4 -0
  183. package/lib/test/shared-tree/sharedTree.spec.d.ts.map +1 -1
  184. package/lib/test/shared-tree/sharedTree.spec.js.map +1 -1
  185. package/lib/test/shared-tree/treeApi.spec.d.ts +4 -0
  186. package/lib/test/shared-tree/treeApi.spec.d.ts.map +1 -1
  187. package/lib/test/shared-tree/treeApi.spec.js.map +1 -1
  188. package/lib/test/shared-tree/treeCheckout.spec.d.ts +4 -0
  189. package/lib/test/shared-tree/treeCheckout.spec.d.ts.map +1 -1
  190. package/lib/test/shared-tree/treeCheckout.spec.js.map +1 -1
  191. package/lib/test/shared-tree/treeView.spec.d.ts +4 -0
  192. package/lib/test/shared-tree/treeView.spec.d.ts.map +1 -1
  193. package/lib/test/shared-tree/treeView.spec.js.map +1 -1
  194. package/lib/test/shared-tree/undo.spec.d.ts +4 -0
  195. package/lib/test/shared-tree/undo.spec.d.ts.map +1 -1
  196. package/lib/test/shared-tree/undo.spec.js.map +1 -1
  197. package/lib/test/shared-tree-core/message.spec.d.ts +4 -0
  198. package/lib/test/shared-tree-core/message.spec.d.ts.map +1 -1
  199. package/lib/test/shared-tree-core/message.spec.js.map +1 -1
  200. package/lib/test/shared-tree-core/sharedTreeCore.spec.d.ts +4 -0
  201. package/lib/test/shared-tree-core/sharedTreeCore.spec.d.ts.map +1 -1
  202. package/lib/test/shared-tree-core/sharedTreeCore.spec.js.map +1 -1
  203. package/lib/test/shared-tree-core/utils.d.ts.map +1 -1
  204. package/lib/test/shared-tree-core/utils.js +4 -0
  205. package/lib/test/shared-tree-core/utils.js.map +1 -1
  206. package/lib/test/util/brand.spec.d.ts +0 -3
  207. package/lib/test/util/brand.spec.d.ts.map +1 -1
  208. package/lib/test/util/brand.spec.js +5 -6
  209. package/lib/test/util/brand.spec.js.map +1 -1
  210. package/lib/test/util/opaque.spec.d.ts +19 -0
  211. package/lib/test/util/opaque.spec.d.ts.map +1 -0
  212. package/lib/test/util/opaque.spec.js +14 -0
  213. package/lib/test/util/opaque.spec.js.map +1 -0
  214. package/lib/tree-alpha.d.ts +6 -0
  215. package/lib/tree-beta.d.ts +6 -0
  216. package/lib/tree-public.d.ts +6 -0
  217. package/lib/tree-untrimmed.d.ts +107 -14
  218. package/lib/util/brand.d.ts +50 -59
  219. package/lib/util/brand.d.ts.map +1 -1
  220. package/lib/util/brand.js +31 -43
  221. package/lib/util/brand.js.map +1 -1
  222. package/lib/util/index.d.ts +5 -3
  223. package/lib/util/index.d.ts.map +1 -1
  224. package/lib/util/index.js +3 -1
  225. package/lib/util/index.js.map +1 -1
  226. package/lib/util/opaque.d.ts +46 -0
  227. package/lib/util/opaque.d.ts.map +1 -0
  228. package/lib/util/opaque.js +24 -0
  229. package/lib/util/opaque.js.map +1 -0
  230. package/lib/util/typeCheckTests.d.ts +1 -1
  231. package/lib/util/typeCheckTests.d.ts.map +1 -1
  232. package/lib/util/typeCheckTests.js.map +1 -1
  233. package/lib/util/typeUtils.d.ts +13 -0
  234. package/lib/util/typeUtils.d.ts.map +1 -1
  235. package/lib/util/typeUtils.js.map +1 -1
  236. package/lib/util/typeboxBrand.d.ts +17 -0
  237. package/lib/util/typeboxBrand.d.ts.map +1 -0
  238. package/lib/util/typeboxBrand.js +27 -0
  239. package/lib/util/typeboxBrand.js.map +1 -0
  240. package/lib/util/utils.d.ts +0 -13
  241. package/lib/util/utils.d.ts.map +1 -1
  242. package/lib/util/utils.js.map +1 -1
  243. package/package.json +19 -19
  244. package/src/codec/discriminatedUnions.ts +1 -0
  245. package/src/codec/index.ts +1 -0
  246. package/src/core/tree/visitDelta.ts +1 -0
  247. package/src/core/tree/visitPath.ts +1 -0
  248. package/src/domains/schemaBuilder.ts +0 -14
  249. package/src/domains/testRecursiveDomain.ts +1 -25
  250. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -4
  251. package/src/feature-libraries/multiplicity.ts +1 -0
  252. package/src/index.ts +3 -0
  253. package/src/packageVersion.ts +1 -1
  254. package/src/shared-tree/schematizingTreeView.ts +1 -0
  255. package/src/shared-tree/treeApi.ts +1 -0
  256. package/src/shared-tree/treeCheckout.ts +1 -0
  257. package/src/shared-tree-core/branch.ts +4 -4
  258. package/src/shared-tree-core/index.ts +1 -0
  259. package/src/simple-tree/README.md +0 -6
  260. package/src/simple-tree/toFlexSchema.ts +1 -0
  261. package/src/simple-tree/toMapTree.ts +1 -1
  262. package/src/util/brand.ts +62 -96
  263. package/src/util/index.ts +3 -7
  264. package/src/util/opaque.ts +68 -0
  265. package/src/util/typeCheckTests.ts +1 -1
  266. package/src/util/typeUtils.ts +14 -0
  267. package/src/util/typeboxBrand.ts +31 -0
  268. package/src/util/utils.ts +0 -14
@@ -167,7 +167,7 @@ export type Assume<TInput, TAssumeToBe> = [TInput] extends [TAssumeToBe] ? TInpu
167
167
  export type Brand<ValueType, Name extends string | ErasedType<string>> = ValueType & BrandedType<ValueType, Name extends Erased<infer TName> ? TName : Assume<Name, string>>;
168
168
 
169
169
  // @internal
170
- export function brand<T extends Brand<any, string>>(value: T extends BrandedType<infer ValueType, string> ? ValueType : never): T;
170
+ export function brand<T>(value: T extends BrandedType<infer ValueType, string> ? ValueType : never): T;
171
171
 
172
172
  // @internal
173
173
  export type BrandedKey<TKey, TContent> = TKey & Invariant<TContent>;
@@ -189,6 +189,7 @@ export interface BrandedMapSubset<K extends BrandedKey<unknown, any>> {
189
189
 
190
190
  // @internal @sealed
191
191
  export abstract class BrandedType<out ValueType, Name extends string> {
192
+ static [Symbol.hasInstance](value: never): value is never;
192
193
  protected abstract brand(dummy: never): Name;
193
194
  // (undocumented)
194
195
  protected _typeCheck?: Covariant<ValueType>;
@@ -442,6 +443,7 @@ export interface ErasedTreeNodeSchemaDataFormat extends Erased<"TreeNodeSchemaDa
442
443
 
443
444
  // @internal @sealed
444
445
  export abstract class ErasedType<out Name extends string> {
446
+ static [Symbol.hasInstance](value: never): value is never;
445
447
  protected abstract brand(dummy: never): Name;
446
448
  }
447
449
 
@@ -1206,6 +1208,15 @@ export class LeafNodeSchema<const out Name extends string = string, const out Sp
1206
1208
  protected _typeCheck2?: MakeNominal;
1207
1209
  }
1208
1210
 
1211
+ // @internal (undocumented)
1212
+ export class LeafNodeStoredSchema extends TreeNodeStoredSchema {
1213
+ constructor(leafValue: ValueSchema);
1214
+ // (undocumented)
1215
+ encode(): ErasedTreeNodeSchemaDataFormat;
1216
+ // (undocumented)
1217
+ readonly leafValue: ValueSchema;
1218
+ }
1219
+
1209
1220
  // @internal
1210
1221
  export interface LocalNodeKey extends Opaque<Brand<SessionSpaceCompressedId, "Local Node Key">> {
1211
1222
  }
@@ -1214,6 +1225,15 @@ export interface LocalNodeKey extends Opaque<Brand<SessionSpaceCompressedId, "Lo
1214
1225
  export interface MakeNominal {
1215
1226
  }
1216
1227
 
1228
+ // @internal (undocumented)
1229
+ export class MapNodeStoredSchema extends TreeNodeStoredSchema {
1230
+ constructor(mapFields: TreeFieldStoredSchema);
1231
+ // (undocumented)
1232
+ encode(): ErasedTreeNodeSchemaDataFormat;
1233
+ // (undocumented)
1234
+ readonly mapFields: TreeFieldStoredSchema;
1235
+ }
1236
+
1217
1237
  // @internal
1218
1238
  export interface MapTree extends NodeData {
1219
1239
  // (undocumented)
@@ -1243,7 +1263,7 @@ export interface Named<TName> {
1243
1263
  }
1244
1264
 
1245
1265
  // @internal
1246
- export type NameFromBranded<T extends BrandedType<any, string>> = T extends BrandedType<any, infer Name> ? Name : never;
1266
+ export type NameFromBranded<T extends BrandedType<unknown, string>> = T extends BrandedType<unknown, infer Name> ? Name : never;
1247
1267
 
1248
1268
  // @internal
1249
1269
  export type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;
@@ -1331,6 +1351,15 @@ export type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveReadonl
1331
1351
  -readonly [Property in keyof T]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
1332
1352
  };
1333
1353
 
1354
+ // @internal (undocumented)
1355
+ export class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
1356
+ constructor(objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>);
1357
+ // (undocumented)
1358
+ encode(): ErasedTreeNodeSchemaDataFormat;
1359
+ // (undocumented)
1360
+ readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>;
1361
+ }
1362
+
1334
1363
  // @internal
1335
1364
  export function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined;
1336
1365
 
@@ -2044,7 +2073,7 @@ export interface ValueFieldEditBuilder {
2044
2073
  }
2045
2074
 
2046
2075
  // @internal
2047
- export type ValueFromBranded<T extends BrandedType<any, string>> = T extends BrandedType<infer ValueType, string> ? ValueType : never;
2076
+ export type ValueFromBranded<T extends BrandedType<unknown, string>> = T extends BrandedType<infer ValueType, string> ? ValueType : never;
2048
2077
 
2049
2078
  // @internal
2050
2079
  export enum ValueSchema {
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.d.ts","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,aAI1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,4BAA4B,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,SAAS,GAAG,EAAE,EAAE,OAAO;IAC5F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGtB;gBAGD,OAAO,EAAE;QACR;YACC,QAAQ,EAAE,QAAQ,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACjC,GAAG,IAAI,EAAE,KAAK,KACV,OAAO;SACZ;KACD,CAAC,YAAY,CAAC;IAOT,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO;CAYvD"}
1
+ {"version":3,"file":"discriminatedUnions.d.ts","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,aAI1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,4BAA4B,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,SAAS,GAAG,EAAE,EAAE,OAAO;IAC5F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGtB;gBAGD,OAAO,EAAE;QACR;YACC,QAAQ,EAAE,QAAQ,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACjC,GAAG,IAAI,EAAE,KAAK,KACV,OAAO;SACZ;KACD,CAAC,YAAY,CAAC;IAOT,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO;CAYvD"}
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.DiscriminatedUnionDispatcher = exports.unionOptions = void 0;
4
8
  const core_utils_1 = require("@fluidframework/core-utils");
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";;;AAKA,2DAAoD;AACpD,+CAAmE;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,4BAA4B;IAMxC,YACC,OAOe;QAEf,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,mBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,mCAAmC,CAAC,CAAC;QACnF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAjCD,oEAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ObjectOptions } from \"@sinclair/typebox\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { _InlineTrick, fail, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\nexport class DiscriminatedUnionDispatcher<TUnion extends object, TArgs extends any[], TResult> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(\n\t\tlibrary: [\n\t\t\t{\n\t\t\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t\t\t...args: TArgs\n\t\t\t\t) => TResult;\n\t\t\t},\n\t\t][_InlineTrick],\n\t) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory = this.library.get(key) ?? fail(\"missing function for union member\");\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
1
+ {"version":3,"file":"discriminatedUnions.js","sourceRoot":"","sources":["../../src/codec/discriminatedUnions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAAoD;AACpD,+CAAmE;AAEnE;;;;GAIG;AAEH;;;;GAIG;AACU,QAAA,YAAY,GAAkB;IAC1C,oBAAoB,EAAE,KAAK;IAC3B,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,4BAA4B;IAMxC,YACC,OAOe;QAEf,IAAI,CAAC,OAAO,GAAG,IAAA,sBAAW,EACzB,OAA4E,CAC5E,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,GAAG,IAAW;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,mBAAM,EACL,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,KAAK,CAAC,6DAA6D,CACnE,CAAC;QACF,MAAM,GAAG,GAAiB,IAAI,CAAC,CAAC,CAAiB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,mCAAmC,CAAC,CAAC;QACnF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAjCD,oEAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ObjectOptions } from \"@sinclair/typebox\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { _InlineTrick, fail, objectToMap } from \"../util/index.js\";\n\n/**\n * This module contains utilities for an encoding of a discriminated union that is efficient to validate using\n * a JSON schema validator.\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\n\n/**\n * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const unionOptions: ObjectOptions = {\n\tadditionalProperties: false,\n\tminProperties: 1,\n\tmaxProperties: 1,\n};\n\n/**\n * Applies a function to the content of a [discriminated union](https://en.wikipedia.org/wiki/Tagged_union)\n * where the function to apply depends on which value from the union it holds.\n *\n * This uses a rather non-standard encoding of the union where it is an object with many differently named optional fields,\n * and which of the fields is populated determines the content type.\n * This union encoding has the advantage that schema validation (such as that implemented by TypeBox) can validate the data efficiently.\n * Other encodings--such as using an untagged union, then tagging the content types with a marker enum--require the schema validator to disambiguate the union members.\n * Most JSON validator implementations fail to recognize the marker enum determines which component of the discriminated union the data must be,\n * and end up checking against all candidate members of the union.\n *\n * @example\n *\n * The following union:\n * ```typescript\n * type Operation = Add | Subtract | Multiply | Divide;\n *\n * interface BinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface Add extends BinaryOperation {\n * readonly type: \"add\";\n * }\n *\n * interface Subtract extends BinaryOperation {\n * readonly type: \"subtract\";\n * }\n *\n * interface Multiply extends BinaryOperation {\n * readonly type: \"multiply\";\n * }\n *\n * interface Divide extends BinaryOperation {\n * readonly type: \"divide\";\n * }\n *\n * ```\n * Would be encoded using this strategy as:\n * ```typescript\n * interface EncodedBinaryOperation {\n * readonly left: number;\n * readonly right: number;\n * }\n *\n * interface EncodedOperation {\n * add?: EncodedBinaryOperation;\n * subtract?: EncodedBinaryOperation;\n * multiply?: EncodedBinaryOperation;\n * divide?: EncodedBinaryOperation;\n * }\n * ```\n * where only a single property of `EncodedOperation` is populated for a given encoded value.\n */\nexport class DiscriminatedUnionDispatcher<TUnion extends object, TArgs extends any[], TResult> {\n\tprivate readonly library: ReadonlyMap<\n\t\tkeyof TUnion,\n\t\t(value: unknown, ...args: TArgs) => TResult\n\t>;\n\n\tpublic constructor(\n\t\tlibrary: [\n\t\t\t{\n\t\t\t\treadonly [Property in keyof TUnion]-?: (\n\t\t\t\t\tvalue: Required<TUnion>[Property],\n\t\t\t\t\t...args: TArgs\n\t\t\t\t) => TResult;\n\t\t\t},\n\t\t][_InlineTrick],\n\t) {\n\t\tthis.library = objectToMap(\n\t\t\tlibrary as Record<keyof TUnion, (value: unknown, ...args: TArgs) => TResult>,\n\t\t);\n\t}\n\n\tpublic dispatch(union: TUnion, ...args: TArgs): TResult {\n\t\tconst keys = Reflect.ownKeys(union);\n\t\tassert(\n\t\t\tkeys.length === 1,\n\t\t\t0x733 /* discriminated union type should have exactly one member */,\n\t\t);\n\t\tconst key: keyof TUnion = keys[0] as keyof TUnion;\n\t\tconst value = union[key];\n\t\tconst factory = this.library.get(key) ?? fail(\"missing function for union member\");\n\t\tconst result = factory(value, ...args);\n\t\treturn result;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,SAAS,EACT,yBAAyB,EACzB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,SAAS,EACT,yBAAyB,EACzB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = exports.Versioned = exports.noopValidator = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.withSchemaValidation = exports.withDefaultBinaryEncoding = exports.unitCodec = exports.makeCodecFamily = void 0;
4
2
  /*!
5
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
4
  * Licensed under the MIT License.
7
5
  */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = exports.Versioned = exports.noopValidator = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.withSchemaValidation = exports.withDefaultBinaryEncoding = exports.unitCodec = exports.makeCodecFamily = void 0;
8
8
  var codec_js_1 = require("./codec.js");
9
9
  Object.defineProperty(exports, "makeCodecFamily", { enumerable: true, get: function () { return codec_js_1.makeCodecFamily; } });
10
10
  Object.defineProperty(exports, "unitCodec", { enumerable: true, get: function () { return codec_js_1.unitCodec; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAcoB;AALnB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,qHAAA,yBAAyB,OAAA;AACzB,gHAAA,oBAAoB,OAAA;AAErB,mEAAsF;AAA7E,sIAAA,4BAA4B,OAAA;AAAE,sHAAA,YAAY,OAAA;AACnD,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,iDAAkG;AAAzF,qGAAA,SAAS,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAAE,uHAAA,2BAA2B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tIBinaryCodec,\n\tICodecFamily,\n\tICodecOptions,\n\tIDecoder,\n\tIEncoder,\n\tIJsonCodec,\n\tIMultiFormatCodec,\n\tJsonValidator,\n\tmakeCodecFamily,\n\tSchemaValidationFunction,\n\tunitCodec,\n\twithDefaultBinaryEncoding,\n\twithSchemaValidation,\n} from \"./codec.js\";\nexport { DiscriminatedUnionDispatcher, unionOptions } from \"./discriminatedUnions.js\";\nexport { noopValidator } from \"./noopValidator.js\";\nexport { Versioned, makeVersionedCodec, makeVersionedValidatedCodec } from \"./versioned/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCAcoB;AALnB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,qHAAA,yBAAyB,OAAA;AACzB,gHAAA,oBAAoB,OAAA;AAErB,mEAAsF;AAA7E,sIAAA,4BAA4B,OAAA;AAAE,sHAAA,YAAY,OAAA;AACnD,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,iDAAkG;AAAzF,qGAAA,SAAS,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAAE,uHAAA,2BAA2B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIBinaryCodec,\n\tICodecFamily,\n\tICodecOptions,\n\tIDecoder,\n\tIEncoder,\n\tIJsonCodec,\n\tIMultiFormatCodec,\n\tJsonValidator,\n\tmakeCodecFamily,\n\tSchemaValidationFunction,\n\tunitCodec,\n\twithDefaultBinaryEncoding,\n\twithSchemaValidation,\n} from \"./codec.js\";\nexport { DiscriminatedUnionDispatcher, unionOptions } from \"./discriminatedUnions.js\";\nexport { noopValidator } from \"./noopValidator.js\";\nexport { Versioned, makeVersionedCodec, makeVersionedValidatedCodec } from \"./versioned/index.js\";\n"]}
@@ -1,3 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
1
5
  import { FieldKey } from "../schema-stored/index.js";
2
6
  import * as Delta from "./delta.js";
3
7
  import { NodeIndex, PlaceIndex, Range } from "./pathTree.js";
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAgB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAQ3E,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,KAAK,CAAC,IAAI,EACjB,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,kBAAkB,GACpC,IAAI,CAqCN;AA6FD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC;IACb;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzD;;;;;OAKG;IACH,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,QAA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AAI,IAAI,CAAC;IACb;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzD;;;;;OAKG;IACH,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IACvE;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnD;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEzF;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAElC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAEjC;;;;;;;OAOG;IACH,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEhC;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/B"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visitDelta = void 0;
4
2
  /*!
5
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
4
  * Licensed under the MIT License.
7
5
  */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.visitDelta = void 0;
8
8
  const core_utils_1 = require("@fluidframework/core-utils");
9
9
  const deltaUtil_js_1 = require("./deltaUtil.js");
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDel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AAgB,GACrB,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;wBACvD,OAAO,CAAC,OAAO,CACd,WAAW,EACX,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,CAAC,EAAE,EAC5C,gBAAgB,CAChB,CAAC;wBACF,wDAAwD;wBACxD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;4BAC9B,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;yBACzD;qBACD;yBAAM;wBACN,uBAAuB;wBACvB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;qBAC5C;oBACD,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;oBACtD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBACtD,IAAI,MAAM,KAAK,SAAS,EAAE;wBACzB,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;wBAC1C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;qBAChD;iBACD;aACD;iBAAM,IAAI,CAAC,IAAA,2BAAY,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;gBAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aAC/C;YACD,IAAI,CAAC,IAAA,2BAAY,EAAC,IAAI,CAAC,EAAE;gBACxB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;aACpB;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\n\nimport { FieldKey } from \"../schema-stored/index.js\";\nimport * as Delta from \"./delta.js\";\nimport { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\nimport { ForestRootId, DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport {\n\tareDetachedNodeIdsEqual,\n\tisAttachMark,\n\tisDetachMark,\n\tisReplaceMark,\n\toffsetDetachId,\n} from \"./deltaUtil.js\";\nimport { ProtoNodes } from \"./delta.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n * The detach pass is therefore responsible for making sure that all roots that needs to be attached during the\n * attach pass are detached.\n * In practice, this means the detach pass must:\n * - Create all subtrees that need to be created\n * - Detach all moved nodes\n *\n * In addition to that, the detach pass also detaches nodes that need removing, with the exception of nodes that get\n * replaced. The reason for this exception is that we need to be able to communicate replaces as atomic operations.\n * In order to do that, we need to wait until we are sure that the content to attach is available as a detached root.\n * Replaces are therefore handled during the attach pass.\n * Note that this could theoretically lead to a situation where, in the attach pass, one replace wants to attach\n * a node that has yet to be detached by another replace. This does not occur in practice because we do not support\n * editing operations that would lead to this situation.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detach field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches and replaces.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(rootTransfers, attachPassRoots, detachedFieldIndex, visitor);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n) {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tconst oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n * @internal\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor. Must be called once the visitor is no longer needed, since trying to acquire\n\t * a new one before freeing an existing one is invalid.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: ProtoNodes, destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tdetach(source: Range, destination: FieldKey): void;\n\t/**\n\t * Replaces a range of nodes in the current field by transferring them out to a new detached field\n\t * and transferring in all the nodes from an existing detached field in their place.\n\t * The number of nodes being detached must match the number of nodes being attached.\n\t * @param newContentSource - The detached field to transfer the new nodes from.\n\t * @param range - The bounds of the range of nodes to replace.\n\t * @param oldContentDestination - The key for a new detached field to transfer the old nodes to.\n\t */\n\treplace(newContentSource: FieldKey, range: Range, oldContentDestination: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Performs all root creations\n * - Collects all roots that may need a detach pass\n * - Collects all roots that may need an attach pass\n * - Collects all relocates\n * - Collects all destructions\n * - Executes detaches (bottom-up) provided they are not part of a replace\n * (because we want to wait until we are sure content to attach is available as a root)\n */\nfunction detachPass(delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig): void {\n\tif (delta.global !== undefined) {\n\t\tfor (const { id, fields } of delta.global) {\n\t\t\tconst root = config.detachedFieldIndex.getEntry(id);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n\tif (delta.rename !== undefined) {\n\t\tconfig.rootTransfers.push(...delta.rename);\n\t}\n\tif (delta.local !== undefined) {\n\t\tlet index = 0;\n\t\tfor (const mark of delta.local) {\n\t\t\tif (mark.fields !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t\t);\n\t\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t\t}\n\t\t\tif (isDetachMark(mark)) {\n\t\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t\tconst root = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\toffsetDetachId(mark.detach!, i),\n\t\t\t\t\t);\n\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t\t}\n\t\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field);\n\t\t\t\t}\n\t\t\t} else if (!isAttachMark(mark)) {\n\t\t\t\tindex += mark.count;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n) {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tfor (let i = 0; i < trees.length; i += 1) {\n\t\t\t\tconst offsettedId = offsetDetachId(id, i);\n\t\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(offsettedId);\n\t\t\t\t// Tree building is idempotent. We can therefore ignore build instructions for trees that already exist.\n\t\t\t\t// The idempotence is leveraged by undo/redo as well as sandwich rebasing.\n\t\t\t\tif (root === undefined) {\n\t\t\t\t\troot = config.detachedFieldIndex.createEntry(offsettedId);\n\t\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\t\tvisitor.create([trees[i]], field);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n) {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n * - Executes replaces (top-down) applying nested changes on the attached nodes\n * - Collects detached roots (from replaces) that need an attach pass\n */\nfunction attachPass(delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig): void {\n\tif (delta.local !== undefined) {\n\t\tlet index = 0;\n\t\tfor (const mark of delta.local) {\n\t\t\tif (isAttachMark(mark) || isReplaceMark(mark)) {\n\t\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach!, i);\n\t\t\t\t\tconst sourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\t\tif (isReplaceMark(mark)) {\n\t\t\t\t\t\tconst rootDestination = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\toffsetDetachId(mark.detach!, i),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst destinationField =\n\t\t\t\t\t\t\tconfig.detachedFieldIndex.toFieldKey(rootDestination);\n\t\t\t\t\t\tvisitor.replace(\n\t\t\t\t\t\t\tsourceField,\n\t\t\t\t\t\t\t{ start: offsetIndex, end: offsetIndex + 1 },\n\t\t\t\t\t\t\tdestinationField,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// We may need to do a second pass on the detached nodes\n\t\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\t\tconfig.attachPassRoots.set(rootDestination, mark.fields);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// This a simple attach\n\t\t\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!isDetachMark(mark) && mark.fields !== undefined) {\n\t\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t\t}\n\t\t\tif (!isDetachMark(mark)) {\n\t\t\t\tindex += mark.count;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src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BACF,MAAM,gBAAgB,GACrB,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;wBACvD,OAAO,CAAC,OAAO,CACd,WAAW,EACX,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,CAAC,EAAE,EAC5C,gBAAgB,CAChB,CAAC;wBACF,wDAAwD;wBACxD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;4BAC9B,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;yBACzD;qBACD;yBAAM;wBACN,uBAAuB;wBACvB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;qBAC5C;oBACD,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;oBACtD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBACtD,IAAI,MAAM,KAAK,SAAS,EAAE;wBACzB,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;wBAC1C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;qBAChD;iBACD;aACD;iBAAM,IAAI,CAAC,IAAA,2BAAY,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;gBAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aAC/C;YACD,IAAI,CAAC,IAAA,2BAAY,EAAC,IAAI,CAAC,EAAE;gBACxB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;aACpB;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\n\nimport { FieldKey } from \"../schema-stored/index.js\";\nimport * as Delta from \"./delta.js\";\nimport { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\nimport { ForestRootId, DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport {\n\tareDetachedNodeIdsEqual,\n\tisAttachMark,\n\tisDetachMark,\n\tisReplaceMark,\n\toffsetDetachId,\n} from \"./deltaUtil.js\";\nimport { ProtoNodes } from \"./delta.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n * The detach pass is therefore responsible for making sure that all roots that needs to be attached during the\n * attach pass are detached.\n * In practice, this means the detach pass must:\n * - Create all subtrees that need to be created\n * - Detach all moved nodes\n *\n * In addition to that, the detach pass also detaches nodes that need removing, with the exception of nodes that get\n * replaced. The reason for this exception is that we need to be able to communicate replaces as atomic operations.\n * In order to do that, we need to wait until we are sure that the content to attach is available as a detached root.\n * Replaces are therefore handled during the attach pass.\n * Note that this could theoretically lead to a situation where, in the attach pass, one replace wants to attach\n * a node that has yet to be detached by another replace. This does not occur in practice because we do not support\n * editing operations that would lead to this situation.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detach field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches and replaces.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(rootTransfers, attachPassRoots, detachedFieldIndex, visitor);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n) {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tconst oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n * @internal\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor. Must be called once the visitor is no longer needed, since trying to acquire\n\t * a new one before freeing an existing one is invalid.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: ProtoNodes, destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tdetach(source: Range, destination: FieldKey): void;\n\t/**\n\t * Replaces a range of nodes in the current field by transferring them out to a new detached field\n\t * and transferring in all the nodes from an existing detached field in their place.\n\t * The number of nodes being detached must match the number of nodes being attached.\n\t * @param newContentSource - The detached field to transfer the new nodes from.\n\t * @param range - The bounds of the range of nodes to replace.\n\t * @param oldContentDestination - The key for a new detached field to transfer the old nodes to.\n\t */\n\treplace(newContentSource: FieldKey, range: Range, oldContentDestination: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Performs all root creations\n * - Collects all roots that may need a detach pass\n * - Collects all roots that may need an attach pass\n * - Collects all relocates\n * - Collects all destructions\n * - Executes detaches (bottom-up) provided they are not part of a replace\n * (because we want to wait until we are sure content to attach is available as a root)\n */\nfunction detachPass(delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig): void {\n\tif (delta.global !== undefined) {\n\t\tfor (const { id, fields } of delta.global) {\n\t\t\tconst root = config.detachedFieldIndex.getEntry(id);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n\tif (delta.rename !== undefined) {\n\t\tconfig.rootTransfers.push(...delta.rename);\n\t}\n\tif (delta.local !== undefined) {\n\t\tlet index = 0;\n\t\tfor (const mark of delta.local) {\n\t\t\tif (mark.fields !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t\t);\n\t\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t\t}\n\t\t\tif (isDetachMark(mark)) {\n\t\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t\tconst root = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\toffsetDetachId(mark.detach!, i),\n\t\t\t\t\t);\n\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t\t}\n\t\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field);\n\t\t\t\t}\n\t\t\t} else if (!isAttachMark(mark)) {\n\t\t\t\tindex += mark.count;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n) {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tfor (let i = 0; i < trees.length; i += 1) {\n\t\t\t\tconst offsettedId = offsetDetachId(id, i);\n\t\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(offsettedId);\n\t\t\t\t// Tree building is idempotent. We can therefore ignore build instructions for trees that already exist.\n\t\t\t\t// The idempotence is leveraged by undo/redo as well as sandwich rebasing.\n\t\t\t\tif (root === undefined) {\n\t\t\t\t\troot = config.detachedFieldIndex.createEntry(offsettedId);\n\t\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\t\tvisitor.create([trees[i]], field);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n) {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n * - Executes replaces (top-down) applying nested changes on the attached nodes\n * - Collects detached roots (from replaces) that need an attach pass\n */\nfunction attachPass(delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig): void {\n\tif (delta.local !== undefined) {\n\t\tlet index = 0;\n\t\tfor (const mark of delta.local) {\n\t\t\tif (isAttachMark(mark) || isReplaceMark(mark)) {\n\t\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach!, i);\n\t\t\t\t\tconst sourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\t\tif (isReplaceMark(mark)) {\n\t\t\t\t\t\tconst rootDestination = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\toffsetDetachId(mark.detach!, i),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst destinationField =\n\t\t\t\t\t\t\tconfig.detachedFieldIndex.toFieldKey(rootDestination);\n\t\t\t\t\t\tvisitor.replace(\n\t\t\t\t\t\t\tsourceField,\n\t\t\t\t\t\t\t{ start: offsetIndex, end: offsetIndex + 1 },\n\t\t\t\t\t\t\tdestinationField,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// We may need to do a second pass on the detached nodes\n\t\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\t\tconfig.attachPassRoots.set(rootDestination, mark.fields);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// This a simple attach\n\t\t\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!isDetachMark(mark) && mark.fields !== undefined) {\n\t\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t\t}\n\t\t\tif (!isDetachMark(mark)) {\n\t\t\t\tindex += mark.count;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"vis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IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;CAClD"}
@@ -1,3 +1,7 @@
1
1
  "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  //# sourceMappingURL=visitPath.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"visitPath.js","sourceRoot":"","sources":["../../../src/core/tree/visitPath.ts"],"names":[],"mappings":"","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceUpPath,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { ProtoNodes } from \"./delta.js\";\n\n/**\n * Delta visitor for the path tree.\n *\n * For any of these events, the paths are guaranteed to be valid at the time of the event,\n * and it is valid to read from the Forest at that path.\n *\n * @internal\n */\nexport interface PathVisitor {\n\t/**\n\t * Invoked after the creation of a range of nodes.\n\t * @param content - The content that was created.\n\t */\n\tafterCreate(content: DetachedRangeUpPath): void;\n\n\t/**\n\t * Invoked before the attaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that will be attached.\n\t * @param destination - The location where the content will be attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeAttach(source: DetachedRangeUpPath, destination: PlaceUpPath): void;\n\n\t/**\n\t * Invoked after the attaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The location where the content originated.\n\t * @param destination - The content that was attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tafterAttach(source: DetachedPlaceUpPath, destination: RangeUpPath): void;\n\n\t/**\n\t * Invoked before the detaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that will be detached.\n\t * @param destination - The location where the content will be sent to.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeDetach(source: RangeUpPath, destination: DetachedPlaceUpPath): void;\n\n\t/**\n\t * Invoked after the detaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that was detached.\n\t * @param destination - The location where the content will be attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tafterDetach(source: PlaceUpPath, destination: DetachedRangeUpPath): void;\n\n\t/**\n\t * Invoked before the replacement of a range of nodes.\n\t *\n\t * Note that the `newContent` range length will always match the `oldContent` range length.\n\t * A replace might actually be separate detaches and attaches which have been coalesced.\n\t *\n\t * @param newContent - The content that will be attached in place of the old.\n\t * @param oldContent - The old that will be replaced.\n\t * @param oldContentDestination - The destination of the old content.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeReplace(\n\t\tnewContent: DetachedRangeUpPath,\n\t\toldContent: RangeUpPath,\n\t\toldContentDestination: DetachedPlaceUpPath,\n\t): void;\n\n\t/**\n\t * Invoked after the replacement of a range of nodes.\n\t *\n\t * Note that the `newContent` range length will always match the `oldContent` range length.\n\t * A replace might actually be separate detaches and attaches which have been coalesced.\n\t *\n\t * @param newContentSource - The place that the new content came from.\n\t * @param newContent - The new content.\n\t * @param oldContent - The content that was replaced.\n\t */\n\tafterReplace(\n\t\tnewContentSource: DetachedPlaceUpPath,\n\t\tnewContent: RangeUpPath,\n\t\toldContent: DetachedRangeUpPath,\n\t): void;\n\n\t/**\n\t * Invoked before content is destroyed.\n\t * @param content - The content that will be destroyed\n\t */\n\tbeforeDestroy(content: DetachedRangeUpPath): void;\n\n\t/**\n\t * A sequence of nodes of length `count` is being removed starting with `path`.\n\t * Called when these nodes are no longer parented under their previous parent, and do not have a new parent.\n\t * It is possible they may be restored in the future (for example by a conflicted merge or undo).\n\t *\n\t * Not called for children of removed nodes.\n\t *\n\t * @param path - first node in the removed range.\n\t * @param count - length of removed range.\n\t *\n\t * @deprecated Migrate to using the other events.\n\t */\n\tonRemove(path: UpPath, count: number): void;\n\t/**\n\t * @param path - location which first node of inserted range will have after insert.\n\t * Any nodes at this index (or after it) will be moved to the right (have their indexes increased by `content.length`).\n\t * @param content - content which is being inserted.\n\t *\n\t * @deprecated Migrate to using the other events.\n\t */\n\tonInsert(path: UpPath, content: ProtoNodes): void;\n}\n"]}
1
+ {"version":3,"file":"visitPath.js","sourceRoot":"","sources":["../../../src/core/tree/visitPath.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceUpPath,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { ProtoNodes } from \"./delta.js\";\n\n/**\n * Delta visitor for the path tree.\n *\n * For any of these events, the paths are guaranteed to be valid at the time of the event,\n * and it is valid to read from the Forest at that path.\n *\n * @internal\n */\nexport interface PathVisitor {\n\t/**\n\t * Invoked after the creation of a range of nodes.\n\t * @param content - The content that was created.\n\t */\n\tafterCreate(content: DetachedRangeUpPath): void;\n\n\t/**\n\t * Invoked before the attaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that will be attached.\n\t * @param destination - The location where the content will be attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeAttach(source: DetachedRangeUpPath, destination: PlaceUpPath): void;\n\n\t/**\n\t * Invoked after the attaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The location where the content originated.\n\t * @param destination - The content that was attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tafterAttach(source: DetachedPlaceUpPath, destination: RangeUpPath): void;\n\n\t/**\n\t * Invoked before the detaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that will be detached.\n\t * @param destination - The location where the content will be sent to.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeDetach(source: RangeUpPath, destination: DetachedPlaceUpPath): void;\n\n\t/**\n\t * Invoked after the detaching of a range of nodes.\n\t * Not invoked for replacements.\n\t * @param source - The content that was detached.\n\t * @param destination - The location where the content will be attached.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tafterDetach(source: PlaceUpPath, destination: DetachedRangeUpPath): void;\n\n\t/**\n\t * Invoked before the replacement of a range of nodes.\n\t *\n\t * Note that the `newContent` range length will always match the `oldContent` range length.\n\t * A replace might actually be separate detaches and attaches which have been coalesced.\n\t *\n\t * @param newContent - The content that will be attached in place of the old.\n\t * @param oldContent - The old that will be replaced.\n\t * @param oldContentDestination - The destination of the old content.\n\t * @param kind - The kind of replacement that will occur.\n\t */\n\tbeforeReplace(\n\t\tnewContent: DetachedRangeUpPath,\n\t\toldContent: RangeUpPath,\n\t\toldContentDestination: DetachedPlaceUpPath,\n\t): void;\n\n\t/**\n\t * Invoked after the replacement of a range of nodes.\n\t *\n\t * Note that the `newContent` range length will always match the `oldContent` range length.\n\t * A replace might actually be separate detaches and attaches which have been coalesced.\n\t *\n\t * @param newContentSource - The place that the new content came from.\n\t * @param newContent - The new content.\n\t * @param oldContent - The content that was replaced.\n\t */\n\tafterReplace(\n\t\tnewContentSource: DetachedPlaceUpPath,\n\t\tnewContent: RangeUpPath,\n\t\toldContent: DetachedRangeUpPath,\n\t): void;\n\n\t/**\n\t * Invoked before content is destroyed.\n\t * @param content - The content that will be destroyed\n\t */\n\tbeforeDestroy(content: DetachedRangeUpPath): void;\n\n\t/**\n\t * A sequence of nodes of length `count` is being removed starting with `path`.\n\t * Called when these nodes are no longer parented under their previous parent, and do not have a new parent.\n\t * It is possible they may be restored in the future (for example by a conflicted merge or undo).\n\t *\n\t * Not called for children of removed nodes.\n\t *\n\t * @param path - first node in the removed range.\n\t * @param count - length of removed range.\n\t *\n\t * @deprecated Migrate to using the other events.\n\t */\n\tonRemove(path: UpPath, count: number): void;\n\t/**\n\t * @param path - location which first node of inserted range will have after insert.\n\t * Any nodes at this index (or after it) will be moved to the right (have their indexes increased by `content.length`).\n\t * @param content - content which is being inserted.\n\t *\n\t * @deprecated Migrate to using the other events.\n\t */\n\tonInsert(path: UpPath, content: ProtoNodes): void;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { Any, FieldKinds, FlexFieldSchema, FlexImplicitAllowedTypes, NormalizeAllowedTypes, NormalizeField, SchemaBuilderOptions, FlexTreeNodeSchema, FlexMapFieldSchema, SchemaBuilderBase, FlexImplicitFieldSchema, FlexObjectNodeSchema, Unenforced, FlexAllowedTypes, FlexFieldNodeSchema, FlexMapNodeSchema } from "../feature-libraries/index.js";
5
+ import { Any, FieldKinds, FlexFieldSchema, FlexImplicitAllowedTypes, NormalizeAllowedTypes, NormalizeField, SchemaBuilderOptions, FlexTreeNodeSchema, FlexMapFieldSchema, SchemaBuilderBase, FlexImplicitFieldSchema, FlexObjectNodeSchema, Unenforced, FlexFieldNodeSchema, FlexMapNodeSchema } from "../feature-libraries/index.js";
6
6
  import { RestrictiveReadonlyRecord } from "../util/index.js";
7
7
  /**
8
8
  * Builds schema libraries, and the schema within them.
@@ -154,18 +154,6 @@ export declare class SchemaBuilder<TScope extends string = string, TName extends
154
154
  * {@link leaf.null}
155
155
  */
156
156
  readonly null: import("../feature-libraries/index.js").LeafNodeSchema<"com.fluidframework.leaf.null", import("../index.js").ValueSchema.Null>;
157
- /**
158
- * Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.
159
- * @remarks
160
- * Some related information in https://github.com/microsoft/TypeScript/issues/55758.
161
- *
162
- * Also be aware that code which relies on this (or the "recursive" SchemaBuilder methods tends to break VSCode's IntelliSense every time anything related to that code (even comments) is edited.
163
- * The command `TypeScript: Restart TS Server` should fix it.
164
- * Sometimes this does not work: the exact cause has not been confirmed but if you have the file open multiple times (for example in both sides of a window split into two columns): closing the extra copy may help.
165
- * Focusing the file with the errors before running `TypeScript: Restart TS Server` can also help.
166
- * Real compile errors (for example elsewhere in the file) can also cause the IntelliSense to not work correctly ever after `TypeScript: Restart TS Server`.
167
- */
168
- fixRecursiveReference<T extends FlexAllowedTypes>(...types: T): void;
169
157
  }
170
158
  export declare function structuralName<const T extends string>(collectionName: T, allowedTypes: FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[]): `${T}<${string}>`;
171
159
  //# sourceMappingURL=schemaBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaBuilder.d.ts","sourceRoot":"","sources":["../../src/domains/schemaBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,GAAG,EAEH,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAElB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kBAAkB,CAAC;AAG/F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa,CACzB,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,KAAK,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CACrC,SAAQ,iBAAiB,CAAC,MAAM,EAAE,OAAO,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC;IACrE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA8C;gBAE3D,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC;IAOxC,eAAe,CAC9B,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,UAAU,CAAC,yBAAyB,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,EACrF,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAOlB;;;;;;;;;;;;;;;;OAgBG;IACI,IAAI,CAAC,KAAK,CAAC,CAAC,SAA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,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,CAAC,GACZ,iBAAiB,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,EAAE,cAAc,CAAC,CAAC,EAAE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAiCxF;;;;;;OAMG;IACH,OAAc,QAAQ,6JAAoC;IAE1D;;;;;;;OAOG;IACH,SAAgB,QAAQ,6JAA0B;IAElD;;;;;;OAMG;IACH,OAAc,QAAQ,6JAAoC;IAE1D;;;;;;;;;OASG;IACH,SAAgB,QAAQ,6JAA0B;IAElD;;;;;;OAMG;IACH,OAAc,QAAQ,6JAAoC;IAE1D;;;;;;;OAOG;IACH,SAAgB,QAAQ,6JAA0B;IAElD;;OAEG;IACH,SAAgB,MAAM,qIAAe;IAErC;;OAEG;IACH,SAAgB,OAAO,uIAAgB;IAEvC;;OAEG;IACH,SAAgB,MAAM,qIAAe;IAErC;;OAEG;IACH,SAAgB,MAAM,0IAAe;IAErC;;OAEG;IACH,SAAgB,IAAI,iIAAa;CACjC;AAWD,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACpD,cAAc,EAAE,CAAC,EACjB,YAAY,EAAE,kBAAkB,GAAG,GAAG,GAAG,SAAS,kBAAkB,EAAE,GACpE,GAAG,CAAC,IAAI,MAAM,GAAG,CA+BnB"}
@@ -120,18 +120,6 @@ class SchemaBuilder extends index_js_1.SchemaBuilderBase {
120
120
  }
121
121
  return super.map(nameOrAllowedTypes, (0, index_js_1.normalizeField)(allowedTypes, index_js_1.FieldKinds.optional));
122
122
  }
123
- /**
124
- * Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.
125
- * @remarks
126
- * Some related information in https://github.com/microsoft/TypeScript/issues/55758.
127
- *
128
- * Also be aware that code which relies on this (or the "recursive" SchemaBuilder methods tends to break VSCode's IntelliSense every time anything related to that code (even comments) is edited.
129
- * The command `TypeScript: Restart TS Server` should fix it.
130
- * Sometimes this does not work: the exact cause has not been confirmed but if you have the file open multiple times (for example in both sides of a window split into two columns): closing the extra copy may help.
131
- * Focusing the file with the errors before running `TypeScript: Restart TS Server` can also help.
132
- * Real compile errors (for example elsewhere in the file) can also cause the IntelliSense to not work correctly ever after `TypeScript: Restart TS Server`.
133
- */
134
- fixRecursiveReference(...types) { }
135
123
  }
136
124
  exports.SchemaBuilder = SchemaBuilder;
137
125
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"schemaBuilder.js","sourceRoot":"","sources":["../../src/domains/schemaBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,4DAoBuC;AACvC,+CAA+F;AAC/F,mDAAuC;AAEvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,aAGX,SAAQ,4BAA4D;IAGrE,YAAmB,OAAqC;QACvD,KAAK,CAAC,qBAAU,CAAC,QAAQ,EAAE;YAC1B,GAAG,OAAO;YACV,SAAS,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,oBAAI,CAAC,OAAO,CAAC;SACvD,CAAC,CAAC;QANa,oBAAe,GAAoC,IAAI,GAAG,EAAE,CAAC;QA6K9E;;;;;;;WAOG;QACa,aAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;QAWlD;;;;;;;;;WASG;QACa,aAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;QAWlD;;;;;;;WAOG;QACa,aAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;QAElD;;WAEG;QACa,WAAM,GAAG,oBAAI,CAAC,MAAM,CAAC;QAErC;;WAEG;QACa,YAAO,GAAG,oBAAI,CAAC,OAAO,CAAC;QAEvC;;WAEG;QACa,WAAM,GAAG,oBAAI,CAAC,MAAM,CAAC;QAErC;;WAEG;QACa,WAAM,GAAG,oBAAI,CAAC,MAAM,CAAC;QAErC;;WAEG;QACa,SAAI,GAAG,oBAAI,CAAC,IAAI,CAAC;IA/OjC,CAAC;IAEe,eAA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M,IAAI,GAAW,CAAC,CAAC,IAAI,CAAC;YAC5B,uHAAuH;YACvH,IAAA,mBAAM,EAAC,OAAO,IAAI,KAAK,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QACH,mCAAmC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,8FAA8F;QAC9F,iDAAiD;QACjD,iIAAiI;QACjI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,cAAc,IAAI,KAAK,GAAG,CAAC;AACtC,CAAC;AAlCD,wCAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tAny,\n\tFlexFieldKind,\n\tFieldKinds,\n\tFlexFieldSchema,\n\tFlexImplicitAllowedTypes,\n\tNormalizeAllowedTypes,\n\tNormalizeField,\n\tSchemaBuilderOptions,\n\tFlexTreeNodeSchema,\n\tFlexMapFieldSchema,\n\tnormalizeField,\n\tSchemaBuilderBase,\n\tFlexImplicitFieldSchema,\n\tFlexObjectNodeSchema,\n\tUnenforced,\n\tFlexAllowedTypes,\n\tFlexFieldNodeSchema,\n\tFlexMapNodeSchema,\n\tTreeNodeSchemaBase,\n} from \"../feature-libraries/index.js\";\nimport { RestrictiveReadonlyRecord, getOrCreate, isAny, requireFalse } from \"../util/index.js\";\nimport { leaf } from \"./leafDomain.js\";\n\n/**\n * Builds schema libraries, and the schema within them.\n *\n * @remarks\n * Fields, when inferred from {@link FlexImplicitFieldSchema}, default to the `Required` {@link FlexFieldKind} (except for in Maps, which default to `Optional`).\n * Implicitly includes `leaf` schema library by default.\n *\n * This type has some built in defaults which impact compatibility.\n * This includes which {@link FlexFieldKind}s it uses.\n * To ensure that these defaults can be updated without compatibility issues,\n * this class is versioned: the number in its name indicates its compatibility,\n * and if its defaults are changed to ones that would not be compatible with a version of the application using the previous versions,\n * this number will be updated to make it impossible for an app to implicitly do a compatibility breaking change by updating this package.\n * Major package version updates are allowed to break API compatibility, but must not break content compatibility unless a corresponding code change is made in the app to opt in.\n *\n * @privateRemarks\n * TODO: Maybe rename to DefaultSchemaBuilder1 because of the versioning implications above.\n * Same applies to SchemaBuilder.\n * TODO: figure out a way to link `leaf` above without breaking API Extractor.\n * @sealed\n * @deprecated Users of this class should either use {@link SchemaBuilderBase} and explicitly work with {@link FlexFieldSchema}, or use SchemaFactory and work at its higher level of abstraction.\n */\nexport class SchemaBuilder<\n\tTScope extends string = string,\n\tTName extends string | number = string,\n> extends SchemaBuilderBase<TScope, typeof FieldKinds.required, TName> {\n\tprivate readonly structuralTypes: Map<string, FlexTreeNodeSchema> = new Map();\n\n\tpublic constructor(options: SchemaBuilderOptions<TScope>) {\n\t\tsuper(FieldKinds.required, {\n\t\t\t...options,\n\t\t\tlibraries: [...(options.libraries ?? []), leaf.library],\n\t\t});\n\t}\n\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveReadonlyRecord<string, FlexImplicitFieldSchema>>,\n\t>(name: Name, t: T) {\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as unknown as RestrictiveReadonlyRecord<string, FlexImplicitFieldSchema>,\n\t\t) as unknown as FlexObjectNodeSchema<`${TScope}.${Name}`, T>;\n\t}\n\n\t/**\n\t * Define (and add to this library if not already present) a structurally typed {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * @remarks\n\t * The {@link TreeNodeSchemaIdentifier} for this List is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named lists, other types in this schema builder should avoid names of the form `List<${string}>`.\n\t *\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural lists by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t */\n\tpublic list<const T extends FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.List<${string}>`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * The name must be unique among all TreeNodeSchema in the the document schema.\n\t */\n\tpublic list<Name extends TName, const T extends FlexImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${Name}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t>;\n\n\tpublic list<const T extends FlexImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes:\n\t\t\t| TName\n\t\t\t| ((T & FlexTreeNodeSchema) | Any | readonly FlexTreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${string}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as\n\t\t\t\t| (T & FlexTreeNodeSchema)\n\t\t\t\t| Any\n\t\t\t\t| readonly FlexTreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"List\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedList(fullName, nameOrAllowedTypes as T),\n\t\t\t) as FlexFieldNodeSchema<\n\t\t\t\t`${TScope}.${string}`,\n\t\t\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t\t\t>;\n\t\t}\n\t\treturn this.namedList(nameOrAllowedTypes as TName, allowedTypes);\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * The name must be unique among all TreeNodeSchema in the the document schema.\n\t *\n\t * @privateRemarks\n\t * TODO: If A custom \"List\" API is added as a subtype of {@link FieldNode}, this would opt into that.\n\t */\n\tprivate namedList<Name extends TName | string, const T extends FlexImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${Name}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t> {\n\t\tconst schema = FlexFieldNodeSchema.create(\n\t\t\tthis,\n\t\t\tthis.scoped(name as TName & Name),\n\t\t\tthis.sequence(allowedTypes),\n\t\t);\n\t\tthis.addNodeSchema(schema);\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Define (and add to this library if not already present) a structurally typed {@link FlexMapNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @remarks\n\t * The {@link TreeNodeSchemaIdentifier} for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @privateRemarks\n\t * See note on list.\n\t */\n\tpublic override map<const T extends FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): FlexMapNodeSchema<`${TScope}.Map<${string}>`, NormalizeField<T, typeof FieldKinds.optional>>;\n\n\t/**\n\t * Define (and add to this library) a {@link FlexMapNodeSchema} for a {@link TreeMapNode}.\n\t */\n\tpublic override map<\n\t\tName extends TName,\n\t\tconst T extends FlexMapFieldSchema | FlexImplicitAllowedTypes,\n\t>(\n\t\tname: Name,\n\t\tfieldSchema: T,\n\t): FlexMapNodeSchema<`${TScope}.${Name}`, NormalizeField<T, typeof FieldKinds.optional>>;\n\n\tpublic override map<const T extends FlexMapFieldSchema | FlexImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes:\n\t\t\t| TName\n\t\t\t| ((T & FlexTreeNodeSchema) | Any | readonly FlexTreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): FlexMapNodeSchema<`${TScope}.${string}`, NormalizeField<T, typeof FieldKinds.optional>> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as\n\t\t\t\t| (T & FlexTreeNodeSchema)\n\t\t\t\t| Any\n\t\t\t\t| readonly FlexTreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tsuper.map(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnormalizeField(nameOrAllowedTypes as T, FieldKinds.optional),\n\t\t\t\t\t) as FlexTreeNodeSchema,\n\t\t\t) as FlexMapNodeSchema<\n\t\t\t\t`${TScope}.${string}`,\n\t\t\t\tNormalizeField<T, typeof FieldKinds.optional>\n\t\t\t>;\n\t\t}\n\t\treturn super.map(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tnormalizeField(allowedTypes, FieldKinds.optional),\n\t\t);\n\t}\n\n\t/**\n\t * Define a schema for an {@link FieldKinds.optional|optional field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.optional` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}.\n\t */\n\tpublic static optional = fieldHelper(FieldKinds.optional);\n\n\t/**\n\t * Define a schema for an {@link FieldKinds.optional|optional field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.optional` to {@link FlexFieldSchema.create}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly optional = SchemaBuilder.optional;\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.required|required field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.required` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}.\n\t */\n\tpublic static required = fieldHelper(FieldKinds.required);\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.required|required field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.required` to {@link FlexFieldSchema.create}.\n\t * Note that `FieldKinds.required` is the current default field kind, so APIs accepting {@link FlexImplicitFieldSchema}\n\t * can be passed the `allowedTypes` and will implicitly wrap it up in a {@link FieldKinds.required|required field}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly required = SchemaBuilder.required;\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.sequence|sequence field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.sequence` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}\n\t */\n\tpublic static sequence = fieldHelper(FieldKinds.sequence);\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.sequence|sequence field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.sequence` to {@link FlexFieldSchema.create}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly sequence = SchemaBuilder.sequence;\n\n\t/**\n\t * {@link leaf.number}\n\t */\n\tpublic readonly number = leaf.number;\n\n\t/**\n\t * {@link leaf.boolean}\n\t */\n\tpublic readonly boolean = leaf.boolean;\n\n\t/**\n\t * {@link leaf.string}\n\t */\n\tpublic readonly string = leaf.string;\n\n\t/**\n\t * {@link leaf.handle}\n\t */\n\tpublic readonly handle = leaf.handle;\n\n\t/**\n\t * {@link leaf.null}\n\t */\n\tpublic readonly null = leaf.null;\n\n\t/**\n\t * Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.\n\t * @remarks\n\t * Some related information in https://github.com/microsoft/TypeScript/issues/55758.\n\t *\n\t * Also be aware that code which relies on this (or the \"recursive\" SchemaBuilder methods tends to break VSCode's IntelliSense every time anything related to that code (even comments) is edited.\n\t * The command `TypeScript: Restart TS Server` should fix it.\n\t * Sometimes this does not work: the exact cause has not been confirmed but if you have the file open multiple times (for example in both sides of a window split into two columns): closing the extra copy may help.\n\t * Focusing the file with the errors before running `TypeScript: Restart TS Server` can also help.\n\t * Real compile errors (for example elsewhere in the file) can also cause the IntelliSense to not work correctly ever after `TypeScript: Restart TS Server`.\n\t */\n\tpublic fixRecursiveReference<T extends FlexAllowedTypes>(...types: T): void {}\n}\n\n/**\n * Returns a wrapper around SchemaBuilder.field for a specific FieldKind.\n */\nfunction fieldHelper<Kind extends FlexFieldKind>(kind: Kind) {\n\treturn <const T extends FlexImplicitAllowedTypes>(\n\t\tallowedTypes: T,\n\t): FlexFieldSchema<Kind, NormalizeAllowedTypes<T>> => SchemaBuilder.field(kind, allowedTypes);\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (allowedTypes === Any) {\n\t\tinner = \"Any\";\n\t} else if (allowedTypes instanceof TreeNodeSchemaBase) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tassert(Array.isArray(allowedTypes), 0x7c7 /* Types should be an array */);\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(t instanceof TreeNodeSchemaBase, 0x7c8 /* invalid type provided */);\n\t\t\t// TypeScript should know `t.name` is a string (from the extends constraint on TreeNodeSchema's name), but the linter objects.\n\t\t\t// @ts-expect-error: Apparently TypeScript also fails to apply this constraint for some reason and is giving any:\n\t\t\ttype _check = requireFalse<isAny<typeof t.name>>;\n\t\t\t// Adding `as string` here would silence the linter, but make this code less type safe (since if this became not a string, it would still build).\n\t\t\t// Thus we explicitly check that this satisfies string.\n\t\t\t// This would best be done by appending `satisfies string`, but the linter also rejects this.\n\t\t\t// Therefor introducing a variable to do the same thing as `satisfies string` but such that the linter can understand:\n\t\t\tconst name: string = t.name;\n\t\t\t// Just incase the compiler and linter really are onto something and this might sometimes not be a string, validate it:\n\t\t\tassert(typeof name === \"string\", 0x7c9 /* Name should be a string */);\n\t\t\treturn name;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result are also needed so that a single type name \"Any\" would not collide with the \"any\" case above.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n"]}
1
+ {"version":3,"file":"schemaBuilder.js","sourceRoot":"","sources":["../../src/domains/schemaBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,4DAmBuC;AACvC,+CAA+F;AAC/F,mDAAuC;AAEvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,aAGX,SAAQ,4BAA4D;IAGrE,YAAmB,OAAqC;QACvD,KAAK,CAAC,qBAAU,CAAC,QAAQ,EAAE;YAC1B,GAAG,OAAO;YACV,SAAS,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,oBAAI,CAAC,OAAO,CAAC;SACvD,CAAC,CAAC;QANa,o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AAM,IAAI,YAAY,YAAY,6BAAkB,EAAE;QACtD,OAAO,cAAc,CAAC,cAAc,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;KACtD;SAAM;QACN,IAAA,mBAAM,EAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAU,EAAE;YAC5C,8DAA8D;YAC9D,IAAA,mBAAM,EAAC,CAAC,YAAY,6BAAkB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAI3E,iJAAiJ;YACjJ,uDAAuD;YACvD,6FAA6F;YAC7F,sHAAsH;YACtH,MAAM,IAAI,GAAW,CAAC,CAAC,IAAI,CAAC;YAC5B,uHAAuH;YACvH,IAAA,mBAAM,EAAC,OAAO,IAAI,KAAK,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QACH,mCAAmC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,8FAA8F;QAC9F,iDAAiD;QACjD,iIAAiI;QACjI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,cAAc,IAAI,KAAK,GAAG,CAAC;AACtC,CAAC;AAlCD,wCAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tAny,\n\tFlexFieldKind,\n\tFieldKinds,\n\tFlexFieldSchema,\n\tFlexImplicitAllowedTypes,\n\tNormalizeAllowedTypes,\n\tNormalizeField,\n\tSchemaBuilderOptions,\n\tFlexTreeNodeSchema,\n\tFlexMapFieldSchema,\n\tnormalizeField,\n\tSchemaBuilderBase,\n\tFlexImplicitFieldSchema,\n\tFlexObjectNodeSchema,\n\tUnenforced,\n\tFlexFieldNodeSchema,\n\tFlexMapNodeSchema,\n\tTreeNodeSchemaBase,\n} from \"../feature-libraries/index.js\";\nimport { RestrictiveReadonlyRecord, getOrCreate, isAny, requireFalse } from \"../util/index.js\";\nimport { leaf } from \"./leafDomain.js\";\n\n/**\n * Builds schema libraries, and the schema within them.\n *\n * @remarks\n * Fields, when inferred from {@link FlexImplicitFieldSchema}, default to the `Required` {@link FlexFieldKind} (except for in Maps, which default to `Optional`).\n * Implicitly includes `leaf` schema library by default.\n *\n * This type has some built in defaults which impact compatibility.\n * This includes which {@link FlexFieldKind}s it uses.\n * To ensure that these defaults can be updated without compatibility issues,\n * this class is versioned: the number in its name indicates its compatibility,\n * and if its defaults are changed to ones that would not be compatible with a version of the application using the previous versions,\n * this number will be updated to make it impossible for an app to implicitly do a compatibility breaking change by updating this package.\n * Major package version updates are allowed to break API compatibility, but must not break content compatibility unless a corresponding code change is made in the app to opt in.\n *\n * @privateRemarks\n * TODO: Maybe rename to DefaultSchemaBuilder1 because of the versioning implications above.\n * Same applies to SchemaBuilder.\n * TODO: figure out a way to link `leaf` above without breaking API Extractor.\n * @sealed\n * @deprecated Users of this class should either use {@link SchemaBuilderBase} and explicitly work with {@link FlexFieldSchema}, or use SchemaFactory and work at its higher level of abstraction.\n */\nexport class SchemaBuilder<\n\tTScope extends string = string,\n\tTName extends string | number = string,\n> extends SchemaBuilderBase<TScope, typeof FieldKinds.required, TName> {\n\tprivate readonly structuralTypes: Map<string, FlexTreeNodeSchema> = new Map();\n\n\tpublic constructor(options: SchemaBuilderOptions<TScope>) {\n\t\tsuper(FieldKinds.required, {\n\t\t\t...options,\n\t\t\tlibraries: [...(options.libraries ?? []), leaf.library],\n\t\t});\n\t}\n\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveReadonlyRecord<string, FlexImplicitFieldSchema>>,\n\t>(name: Name, t: T) {\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as unknown as RestrictiveReadonlyRecord<string, FlexImplicitFieldSchema>,\n\t\t) as unknown as FlexObjectNodeSchema<`${TScope}.${Name}`, T>;\n\t}\n\n\t/**\n\t * Define (and add to this library if not already present) a structurally typed {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * @remarks\n\t * The {@link TreeNodeSchemaIdentifier} for this List is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named lists, other types in this schema builder should avoid names of the form `List<${string}>`.\n\t *\n\t * @privateRemarks\n\t * The name produced at the type level here is not as specific as it could be, however doing type level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal since TypeScript's structural types.\n\t * For example attempts to narrow unions of structural lists by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t */\n\tpublic list<const T extends FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.List<${string}>`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * The name must be unique among all TreeNodeSchema in the the document schema.\n\t */\n\tpublic list<Name extends TName, const T extends FlexImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${Name}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t>;\n\n\tpublic list<const T extends FlexImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes:\n\t\t\t| TName\n\t\t\t| ((T & FlexTreeNodeSchema) | Any | readonly FlexTreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${string}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as\n\t\t\t\t| (T & FlexTreeNodeSchema)\n\t\t\t\t| Any\n\t\t\t\t| readonly FlexTreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"List\", types);\n\t\t\treturn getOrCreate(this.structuralTypes, fullName, () =>\n\t\t\t\tthis.namedList(fullName, nameOrAllowedTypes as T),\n\t\t\t) as FlexFieldNodeSchema<\n\t\t\t\t`${TScope}.${string}`,\n\t\t\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t\t\t>;\n\t\t}\n\t\treturn this.namedList(nameOrAllowedTypes as TName, allowedTypes);\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link FlexFieldNodeSchema} for a {@link (TreeListNode:interface)}.\n\t *\n\t * The name must be unique among all TreeNodeSchema in the the document schema.\n\t *\n\t * @privateRemarks\n\t * TODO: If A custom \"List\" API is added as a subtype of {@link FieldNode}, this would opt into that.\n\t */\n\tprivate namedList<Name extends TName | string, const T extends FlexImplicitAllowedTypes>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t): FlexFieldNodeSchema<\n\t\t`${TScope}.${Name}`,\n\t\tFlexFieldSchema<typeof FieldKinds.sequence, NormalizeAllowedTypes<T>>\n\t> {\n\t\tconst schema = FlexFieldNodeSchema.create(\n\t\t\tthis,\n\t\t\tthis.scoped(name as TName & Name),\n\t\t\tthis.sequence(allowedTypes),\n\t\t);\n\t\tthis.addNodeSchema(schema);\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Define (and add to this library if not already present) a structurally typed {@link FlexMapNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @remarks\n\t * The {@link TreeNodeSchemaIdentifier} for this Map is defined as a function of the provided types.\n\t * It is still scoped to this SchemaBuilder, but multiple calls with the same arguments will return the same schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named maps, other types in this schema builder should avoid names of the form `Map<${string}>`.\n\t *\n\t * @privateRemarks\n\t * See note on list.\n\t */\n\tpublic override map<const T extends FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): FlexMapNodeSchema<`${TScope}.Map<${string}>`, NormalizeField<T, typeof FieldKinds.optional>>;\n\n\t/**\n\t * Define (and add to this library) a {@link FlexMapNodeSchema} for a {@link TreeMapNode}.\n\t */\n\tpublic override map<\n\t\tName extends TName,\n\t\tconst T extends FlexMapFieldSchema | FlexImplicitAllowedTypes,\n\t>(\n\t\tname: Name,\n\t\tfieldSchema: T,\n\t): FlexMapNodeSchema<`${TScope}.${Name}`, NormalizeField<T, typeof FieldKinds.optional>>;\n\n\tpublic override map<const T extends FlexMapFieldSchema | FlexImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes:\n\t\t\t| TName\n\t\t\t| ((T & FlexTreeNodeSchema) | Any | readonly FlexTreeNodeSchema[]),\n\t\tallowedTypes?: T,\n\t): FlexMapNodeSchema<`${TScope}.${string}`, NormalizeField<T, typeof FieldKinds.optional>> {\n\t\tif (allowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as\n\t\t\t\t| (T & FlexTreeNodeSchema)\n\t\t\t\t| Any\n\t\t\t\t| readonly FlexTreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Map\", types);\n\t\t\treturn getOrCreate(\n\t\t\t\tthis.structuralTypes,\n\t\t\t\tfullName,\n\t\t\t\t() =>\n\t\t\t\t\tsuper.map(\n\t\t\t\t\t\tfullName as TName,\n\t\t\t\t\t\tnormalizeField(nameOrAllowedTypes as T, FieldKinds.optional),\n\t\t\t\t\t) as FlexTreeNodeSchema,\n\t\t\t) as FlexMapNodeSchema<\n\t\t\t\t`${TScope}.${string}`,\n\t\t\t\tNormalizeField<T, typeof FieldKinds.optional>\n\t\t\t>;\n\t\t}\n\t\treturn super.map(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tnormalizeField(allowedTypes, FieldKinds.optional),\n\t\t);\n\t}\n\n\t/**\n\t * Define a schema for an {@link FieldKinds.optional|optional field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.optional` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}.\n\t */\n\tpublic static optional = fieldHelper(FieldKinds.optional);\n\n\t/**\n\t * Define a schema for an {@link FieldKinds.optional|optional field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.optional` to {@link FlexFieldSchema.create}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly optional = SchemaBuilder.optional;\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.required|required field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.required` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}.\n\t */\n\tpublic static required = fieldHelper(FieldKinds.required);\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.required|required field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.required` to {@link FlexFieldSchema.create}.\n\t * Note that `FieldKinds.required` is the current default field kind, so APIs accepting {@link FlexImplicitFieldSchema}\n\t * can be passed the `allowedTypes` and will implicitly wrap it up in a {@link FieldKinds.required|required field}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly required = SchemaBuilder.required;\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.sequence|sequence field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.sequence` to {@link FlexFieldSchema.create}.\n\t *\n\t * This method is also available as an instance method on {@link SchemaBuilder}\n\t */\n\tpublic static sequence = fieldHelper(FieldKinds.sequence);\n\n\t/**\n\t * Define a schema for a {@link FieldKinds.sequence|sequence field}.\n\t * @remarks\n\t * Shorthand or passing `FieldKinds.sequence` to {@link FlexFieldSchema.create}.\n\t *\n\t * Since this creates a {@link FlexFieldSchema} (and not a {@link FlexTreeNodeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}:\n\t * therefore this method is the same as the static version.\n\t */\n\tpublic readonly sequence = SchemaBuilder.sequence;\n\n\t/**\n\t * {@link leaf.number}\n\t */\n\tpublic readonly number = leaf.number;\n\n\t/**\n\t * {@link leaf.boolean}\n\t */\n\tpublic readonly boolean = leaf.boolean;\n\n\t/**\n\t * {@link leaf.string}\n\t */\n\tpublic readonly string = leaf.string;\n\n\t/**\n\t * {@link leaf.handle}\n\t */\n\tpublic readonly handle = leaf.handle;\n\n\t/**\n\t * {@link leaf.null}\n\t */\n\tpublic readonly null = leaf.null;\n}\n\n/**\n * Returns a wrapper around SchemaBuilder.field for a specific FieldKind.\n */\nfunction fieldHelper<Kind extends FlexFieldKind>(kind: Kind) {\n\treturn <const T extends FlexImplicitAllowedTypes>(\n\t\tallowedTypes: T,\n\t): FlexFieldSchema<Kind, NormalizeAllowedTypes<T>> => SchemaBuilder.field(kind, allowedTypes);\n}\n\nexport function structuralName<const T extends string>(\n\tcollectionName: T,\n\tallowedTypes: FlexTreeNodeSchema | Any | readonly FlexTreeNodeSchema[],\n): `${T}<${string}>` {\n\tlet inner: string;\n\tif (allowedTypes === Any) {\n\t\tinner = \"Any\";\n\t} else if (allowedTypes instanceof TreeNodeSchemaBase) {\n\t\treturn structuralName(collectionName, [allowedTypes]);\n\t} else {\n\t\tassert(Array.isArray(allowedTypes), 0x7c7 /* Types should be an array */);\n\t\tconst names = allowedTypes.map((t): string => {\n\t\t\t// Ensure that lazy types (functions) don't slip through here.\n\t\t\tassert(t instanceof TreeNodeSchemaBase, 0x7c8 /* invalid type provided */);\n\t\t\t// TypeScript should know `t.name` is a string (from the extends constraint on TreeNodeSchema's name), but the linter objects.\n\t\t\t// @ts-expect-error: Apparently TypeScript also fails to apply this constraint for some reason and is giving any:\n\t\t\ttype _check = requireFalse<isAny<typeof t.name>>;\n\t\t\t// Adding `as string` here would silence the linter, but make this code less type safe (since if this became not a string, it would still build).\n\t\t\t// Thus we explicitly check that this satisfies string.\n\t\t\t// This would best be done by appending `satisfies string`, but the linter also rejects this.\n\t\t\t// Therefor introducing a variable to do the same thing as `satisfies string` but such that the linter can understand:\n\t\t\tconst name: string = t.name;\n\t\t\t// Just incase the compiler and linter really are onto something and this might sometimes not be a string, validate it:\n\t\t\tassert(typeof name === \"string\", 0x7c9 /* Name should be a string */);\n\t\t\treturn name;\n\t\t});\n\t\t// Ensure name is order independent\n\t\tnames.sort();\n\t\t// Ensure name can't have collisions by quoting and escaping any quotes in the names of types.\n\t\t// Using JSON is a simple way to accomplish this.\n\t\t// The outer `[]` around the result are also needed so that a single type name \"Any\" would not collide with the \"any\" case above.\n\t\tinner = JSON.stringify(names);\n\t}\n\treturn `${collectionName}<${inner}>`;\n}\n"]}
@@ -13,9 +13,5 @@ export declare const recursiveObject: import("../feature-libraries/index.js").Fl
13
13
  readonly recursive: FlexFieldSchema<import("../feature-libraries/index.js").Optional, readonly [() => import("../feature-libraries/index.js").FlexObjectNodeSchema<"Test Recursive Domain.object", any>]>;
14
14
  readonly number: import("../feature-libraries/index.js").LeafNodeSchema<"com.fluidframework.leaf.number", import("../index.js").ValueSchema.Number>;
15
15
  }>;
16
- export declare const recursiveObject2: import("../feature-libraries/index.js").FlexObjectNodeSchema<"Test Recursive Domain.object2", {
17
- readonly recursive: FlexFieldSchema<import("../feature-libraries/index.js").Optional, readonly [() => import("../feature-libraries/index.js").FlexObjectNodeSchema<"Test Recursive Domain.object2", any>]>;
18
- readonly number: FlexFieldSchema<import("../feature-libraries/index.js").Optional, readonly [import("../feature-libraries/index.js").LeafNodeSchema<"com.fluidframework.leaf.number", import("../index.js").ValueSchema.Number>]>;
19
- }>;
20
16
  export declare const library: import("../feature-libraries/schemaBuilderBase.js").SchemaLibrary;
21
17
  //# sourceMappingURL=testRecursiveDomain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testRecursiveDomain.d.ts","sourceRoot":"","sources":["../../src/domains/testRecursiveDomain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAIN,eAAe,EACf,MAAM,+BAA+B,CAAC;AAMvC,eAAO,MAAM,eAAe;;;EAG1B,CAAC;AAOH,eAAO,MAAM,gBAAgB;;;EAG3B,CAAC;AAUH,eAAO,MAAM,OAAO,mEAAwB,CAAC"}
1
+ {"version":3,"file":"testRecursiveDomain.d.ts","sourceRoot":"","sources":["../../src/domains/testRecursiveDomain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAiC,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAK/F,eAAO,MAAM,eAAe;;;EAG1B,CAAC;AAEH,eAAO,MAAM,OAAO,mEAAwB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.library = exports.recursiveObject2 = exports.recursiveObject = void 0;
7
+ exports.library = exports.recursiveObject = void 0;
8
8
  /**
9
9
  * This file exists and is package exported to aid in testing of exporting recursive types across package boundaries.
10
10
  * Sometimes when TypeScript generates d.ts files, they type check significantly differently than the original source (One example of this: https://github.com/microsoft/TypeScript/issues/20979).
@@ -18,13 +18,6 @@ exports.recursiveObject = builder.objectRecursive("object", {
18
18
  recursive: index_js_1.FlexFieldSchema.createUnsafe(index_js_1.FieldKinds.optional, [() => exports.recursiveObject]),
19
19
  number: leafDomain_js_1.leaf.number,
20
20
  });
21
- function fixRecursiveReference(...types) { }
22
- const recursiveReference = () => exports.recursiveObject2;
23
- fixRecursiveReference(recursiveReference);
24
- exports.recursiveObject2 = builder.object("object2", {
25
- recursive: index_js_1.FlexFieldSchema.create(index_js_1.FieldKinds.optional, [recursiveReference]),
26
- number: leafDomain_js_1.leaf.number,
27
- });
28
21
  exports.library = builder.intoLibrary();
29
22
  {
30
23
  const b = new index_js_1.SchemaBuilderBase(index_js_1.FieldKinds.optional, { scope: "Test Recursive Domain" });
@@ -1 +1 @@
1
- {"version":3,"file":"testRecursiveDomain.js","sourceRoot":"","sources":["../../src/domains/testRecursiveDomain.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,4DAKuC;AAEvC,mDAAuC;AAEvC,MAAM,OAAO,GAAG,IAAI,4BAAiB,CAAC,qBAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAElF,QAAA,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE;IAChE,SAAS,EAAE,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,CAAC;IACrF,MAAM,EAAE,oBAAI,CAAC,MAAM;CACnB,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAA6B,GAAG,KAAQ,IAAS,CAAC;AAEhF,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,wBAAgB,CAAC;AAClD,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AAE7B,QAAA,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE;IACzD,SAAS,EAAE,0BAAe,CAAC,MAAM,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAC5E,MAAM,EAAE,oBAAI,CAAC,MAAM;CACnB,CAAC,CAAC;AAUU,QAAA,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;AAE7C;IACC,MAAM,CAAC,GAAG,IAAI,4BAAiB,CAAC,qBAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;IACzF,MAAM,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE;QACxC,KAAK,EAAE,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;KACtE,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,wEAAwE;IACxE,uEAAuE;IACvE,oCAAoC;IACpC,gDAAgD;IAChD,sCAAsC;IACtC,uCAAuC;CACvC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This file exists and is package exported to aid in testing of exporting recursive types across package boundaries.\n * Sometimes when TypeScript generates d.ts files, they type check significantly differently than the original source (One example of this: https://github.com/microsoft/TypeScript/issues/20979).\n * Unfortunately our recursive schema types are an example of types that have this kind of issue: the d.ts files tend to get \"any\" instead of the recursive type reference.\n * Currently we do not have tooling in place to test this in our test suite, and exporting these types here is a temporary crutch to aid in diagnosing this issue.\n */\n\nimport {\n\tFlexAllowedTypes,\n\tFieldKinds,\n\tSchemaBuilderBase,\n\tFlexFieldSchema,\n} from \"../feature-libraries/index.js\";\nimport { areSafelyAssignable, isAny, requireFalse, requireTrue } from \"../util/index.js\";\nimport { leaf } from \"./leafDomain.js\";\n\nconst builder = new SchemaBuilderBase(FieldKinds.optional, { scope: \"Test Recursive Domain\" });\n\nexport const recursiveObject = builder.objectRecursive(\"object\", {\n\trecursive: FlexFieldSchema.createUnsafe(FieldKinds.optional, [() => recursiveObject]),\n\tnumber: leaf.number,\n});\n\nfunction fixRecursiveReference<T extends FlexAllowedTypes>(...types: T): void {}\n\nconst recursiveReference = () => recursiveObject2;\nfixRecursiveReference(recursiveReference);\n\nexport const recursiveObject2 = builder.object(\"object2\", {\n\trecursive: FlexFieldSchema.create(FieldKinds.optional, [recursiveReference]),\n\tnumber: leaf.number,\n});\n\ntype _0 = requireFalse<isAny<typeof recursiveObject2>>;\ntype _1 = requireTrue<\n\tareSafelyAssignable<\n\t\ttypeof recursiveObject2,\n\t\tReturnType<(typeof recursiveObject2.objectNodeFieldsObject.recursive.allowedTypes)[0]>\n\t>\n>;\n\nexport const library = builder.intoLibrary();\n\n{\n\tconst b = new SchemaBuilderBase(FieldKinds.optional, { scope: \"Test Recursive Domain\" });\n\tconst node = b.objectRecursive(\"object\", {\n\t\tchild: FlexFieldSchema.createUnsafe(FieldKinds.optional, [() => node]),\n\t});\n\tconst _field = FlexFieldSchema.createUnsafe(FieldKinds.optional, [node]);\n\t// All these cause TSC to \"RangeError: Maximum call stack size exceeded\"\n\t// const _field4 = FlexFieldSchema.create(FieldKinds.optional, [node]);\n\t// const _field2 = b.optional(node);\n\t// const _field3 = SchemaBuilder.optional(node);\n\t// const schema = b.intoSchema(field);\n\t// const schema = b.intoSchema(_field);\n}\n"]}
1
+ {"version":3,"file":"testRecursiveDomain.js","sourceRoot":"","sources":["../../src/domains/testRecursiveDomain.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,4DAA+F;AAC/F,mDAAuC;AAEvC,MAAM,OAAO,GAAG,IAAI,4BAAiB,CAAC,qBAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAElF,QAAA,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE;IAChE,SAAS,EAAE,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,CAAC;IACrF,MAAM,EAAE,oBAAI,CAAC,MAAM;CACnB,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;AAE7C;IACC,MAAM,CAAC,GAAG,IAAI,4BAAiB,CAAC,qBAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;IACzF,MAAM,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE;QACxC,KAAK,EAAE,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;KACtE,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,0BAAe,CAAC,YAAY,CAAC,qBAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,wEAAwE;IACxE,uEAAuE;IACvE,oCAAoC;IACpC,gDAAgD;IAChD,sCAAsC;IACtC,uCAAuC;CACvC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This file exists and is package exported to aid in testing of exporting recursive types across package boundaries.\n * Sometimes when TypeScript generates d.ts files, they type check significantly differently than the original source (One example of this: https://github.com/microsoft/TypeScript/issues/20979).\n * Unfortunately our recursive schema types are an example of types that have this kind of issue: the d.ts files tend to get \"any\" instead of the recursive type reference.\n * Currently we do not have tooling in place to test this in our test suite, and exporting these types here is a temporary crutch to aid in diagnosing this issue.\n */\n\nimport { FieldKinds, SchemaBuilderBase, FlexFieldSchema } from \"../feature-libraries/index.js\";\nimport { leaf } from \"./leafDomain.js\";\n\nconst builder = new SchemaBuilderBase(FieldKinds.optional, { scope: \"Test Recursive Domain\" });\n\nexport const recursiveObject = builder.objectRecursive(\"object\", {\n\trecursive: FlexFieldSchema.createUnsafe(FieldKinds.optional, [() => recursiveObject]),\n\tnumber: leaf.number,\n});\n\nexport const library = builder.intoLibrary();\n\n{\n\tconst b = new SchemaBuilderBase(FieldKinds.optional, { scope: \"Test Recursive Domain\" });\n\tconst node = b.objectRecursive(\"object\", {\n\t\tchild: FlexFieldSchema.createUnsafe(FieldKinds.optional, [() => node]),\n\t});\n\tconst _field = FlexFieldSchema.createUnsafe(FieldKinds.optional, [node]);\n\t// All these cause TSC to \"RangeError: Maximum call stack size exceeded\"\n\t// const _field4 = FlexFieldSchema.create(FieldKinds.optional, [node]);\n\t// const _field2 = b.optional(node);\n\t// const _field3 = SchemaBuilder.optional(node);\n\t// const schema = b.intoSchema(field);\n\t// const schema = b.intoSchema(_field);\n}\n"]}