@fluidframework/tree 2.70.0 → 2.71.0

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 (179) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/api-report/tree.alpha.api.md +25 -4
  3. package/api-report/tree.beta.api.md +3 -0
  4. package/api-report/tree.legacy.beta.api.md +3 -0
  5. package/dist/alpha.d.ts +3 -0
  6. package/dist/beta.d.ts +1 -0
  7. package/dist/codec/discriminatedUnions.d.ts +1 -1
  8. package/dist/codec/discriminatedUnions.js +1 -1
  9. package/dist/codec/discriminatedUnions.js.map +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/legacy.d.ts +1 -0
  15. package/dist/packageVersion.d.ts +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/dist/shared-tree/independentView.d.ts +74 -5
  19. package/dist/shared-tree/independentView.d.ts.map +1 -1
  20. package/dist/shared-tree/independentView.js +104 -38
  21. package/dist/shared-tree/independentView.js.map +1 -1
  22. package/dist/shared-tree/index.d.ts +2 -1
  23. package/dist/shared-tree/index.d.ts.map +1 -1
  24. package/dist/shared-tree/index.js +6 -1
  25. package/dist/shared-tree/index.js.map +1 -1
  26. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  27. package/dist/shared-tree/sharedTree.js +18 -3
  28. package/dist/shared-tree/sharedTree.js.map +1 -1
  29. package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
  30. package/dist/simple-tree/api/schemaFactory.js +2 -2
  31. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  32. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  33. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -0
  34. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  35. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  36. package/dist/simple-tree/api/schemaFromSimple.js +9 -5
  37. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  38. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  39. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -2
  40. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  41. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -1
  42. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  43. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +31 -10
  44. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  45. package/dist/simple-tree/core/allowedTypes.d.ts +9 -4
  46. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  47. package/dist/simple-tree/core/allowedTypes.js +17 -4
  48. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  49. package/dist/simple-tree/fieldSchema.d.ts +2 -1
  50. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  51. package/dist/simple-tree/fieldSchema.js +10 -0
  52. package/dist/simple-tree/fieldSchema.js.map +1 -1
  53. package/dist/simple-tree/index.d.ts +1 -1
  54. package/dist/simple-tree/index.d.ts.map +1 -1
  55. package/dist/simple-tree/index.js.map +1 -1
  56. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  57. package/dist/simple-tree/node-kinds/array/arrayNode.js +6 -0
  58. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  59. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  60. package/dist/simple-tree/node-kinds/map/mapNode.js +6 -0
  61. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  62. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +17 -0
  63. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  64. package/dist/simple-tree/node-kinds/object/objectNode.js +19 -6
  65. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  66. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  67. package/dist/simple-tree/node-kinds/record/recordNode.js +6 -0
  68. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  69. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +16 -0
  70. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  71. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  72. package/dist/simple-tree/simpleSchema.d.ts +21 -5
  73. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  74. package/dist/simple-tree/simpleSchema.js.map +1 -1
  75. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  76. package/dist/simple-tree/toStoredSchema.js +6 -3
  77. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  78. package/dist/util/referenceCounting.d.ts.map +1 -1
  79. package/dist/util/referenceCounting.js +1 -0
  80. package/dist/util/referenceCounting.js.map +1 -1
  81. package/lib/alpha.d.ts +3 -0
  82. package/lib/beta.d.ts +1 -0
  83. package/lib/codec/discriminatedUnions.d.ts +1 -1
  84. package/lib/codec/discriminatedUnions.js +1 -1
  85. package/lib/codec/discriminatedUnions.js.map +1 -1
  86. package/lib/index.d.ts +2 -2
  87. package/lib/index.d.ts.map +1 -1
  88. package/lib/index.js +1 -1
  89. package/lib/index.js.map +1 -1
  90. package/lib/legacy.d.ts +1 -0
  91. package/lib/packageVersion.d.ts +1 -1
  92. package/lib/packageVersion.js +1 -1
  93. package/lib/packageVersion.js.map +1 -1
  94. package/lib/shared-tree/independentView.d.ts +74 -5
  95. package/lib/shared-tree/independentView.d.ts.map +1 -1
  96. package/lib/shared-tree/independentView.js +103 -38
  97. package/lib/shared-tree/independentView.js.map +1 -1
  98. package/lib/shared-tree/index.d.ts +2 -1
  99. package/lib/shared-tree/index.d.ts.map +1 -1
  100. package/lib/shared-tree/index.js +2 -1
  101. package/lib/shared-tree/index.js.map +1 -1
  102. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  103. package/lib/shared-tree/sharedTree.js +18 -3
  104. package/lib/shared-tree/sharedTree.js.map +1 -1
  105. package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
  106. package/lib/simple-tree/api/schemaFactory.js +2 -2
  107. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  108. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  109. package/lib/simple-tree/api/schemaFactoryRecursive.js +1 -0
  110. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  111. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  112. package/lib/simple-tree/api/schemaFromSimple.js +9 -5
  113. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  114. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  115. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +4 -2
  116. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  117. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -1
  118. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  119. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +31 -10
  120. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  121. package/lib/simple-tree/core/allowedTypes.d.ts +9 -4
  122. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  123. package/lib/simple-tree/core/allowedTypes.js +18 -5
  124. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  125. package/lib/simple-tree/fieldSchema.d.ts +2 -1
  126. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  127. package/lib/simple-tree/fieldSchema.js +10 -0
  128. package/lib/simple-tree/fieldSchema.js.map +1 -1
  129. package/lib/simple-tree/index.d.ts +1 -1
  130. package/lib/simple-tree/index.d.ts.map +1 -1
  131. package/lib/simple-tree/index.js.map +1 -1
  132. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  133. package/lib/simple-tree/node-kinds/array/arrayNode.js +7 -1
  134. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  135. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  136. package/lib/simple-tree/node-kinds/map/mapNode.js +7 -1
  137. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  138. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +17 -0
  139. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  140. package/lib/simple-tree/node-kinds/object/objectNode.js +19 -6
  141. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  142. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  143. package/lib/simple-tree/node-kinds/record/recordNode.js +7 -1
  144. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  145. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +16 -0
  146. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  147. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  148. package/lib/simple-tree/simpleSchema.d.ts +21 -5
  149. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  150. package/lib/simple-tree/simpleSchema.js.map +1 -1
  151. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  152. package/lib/simple-tree/toStoredSchema.js +6 -3
  153. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  154. package/lib/util/referenceCounting.d.ts.map +1 -1
  155. package/lib/util/referenceCounting.js +1 -0
  156. package/lib/util/referenceCounting.js.map +1 -1
  157. package/package.json +24 -24
  158. package/src/codec/discriminatedUnions.ts +1 -1
  159. package/src/index.ts +3 -0
  160. package/src/packageVersion.ts +1 -1
  161. package/src/shared-tree/independentView.ts +147 -72
  162. package/src/shared-tree/index.ts +4 -0
  163. package/src/shared-tree/sharedTree.ts +25 -3
  164. package/src/simple-tree/api/schemaFactory.ts +2 -2
  165. package/src/simple-tree/api/schemaFactoryRecursive.ts +2 -0
  166. package/src/simple-tree/api/schemaFromSimple.ts +17 -14
  167. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +8 -2
  168. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +44 -8
  169. package/src/simple-tree/core/allowedTypes.ts +26 -13
  170. package/src/simple-tree/fieldSchema.ts +14 -1
  171. package/src/simple-tree/index.ts +1 -0
  172. package/src/simple-tree/node-kinds/array/arrayNode.ts +9 -0
  173. package/src/simple-tree/node-kinds/map/mapNode.ts +9 -0
  174. package/src/simple-tree/node-kinds/object/objectNode.ts +54 -18
  175. package/src/simple-tree/node-kinds/record/recordNode.ts +9 -0
  176. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +16 -0
  177. package/src/simple-tree/simpleSchema.ts +22 -5
  178. package/src/simple-tree/toStoredSchema.ts +12 -3
  179. package/src/util/referenceCounting.ts +1 -0
@@ -6,8 +6,8 @@ import { assert } from "@fluidframework/core-utils/internal";
6
6
  import { createIdCompressor, } from "@fluidframework/id-compressor/internal";
7
7
  import { RevisionTagCodec, SchemaVersion, TreeStoredSchemaRepository, } from "../core/index.js";
8
8
  import { createNodeIdentifierManager, makeFieldBatchCodec, makeSchemaCodec, defaultSchemaPolicy, TreeCompressionStrategy, defaultIncrementalEncodingPolicy, } from "../feature-libraries/index.js";
9
- import { Breakable } from "../util/index.js";
10
- import { buildConfiguredForest, defaultSharedTreeOptions, } from "./sharedTree.js";
9
+ import { Breakable, oneFromIterable, } from "../util/index.js";
10
+ import { buildConfiguredForest, defaultSharedTreeOptions, exportSimpleSchema, } from "./sharedTree.js";
11
11
  import { createTreeCheckout } from "./treeCheckout.js";
12
12
  import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
13
13
  import { initialize, initializerFromChunk } from "./schematizeTree.js";
@@ -22,19 +22,7 @@ import { combineChunks } from "../feature-libraries/index.js";
22
22
  * @alpha
23
23
  */
24
24
  export function independentView(config, options) {
25
- const breaker = new Breakable("independentView");
26
- const idCompressor = options.idCompressor ?? createIdCompressor();
27
- const mintRevisionTag = () => idCompressor.generateCompressedId();
28
- const revisionTagCodec = new RevisionTagCodec(idCompressor);
29
- const schema = new TreeStoredSchemaRepository();
30
- const forest = buildConfiguredForest(breaker, options.forest ?? defaultSharedTreeOptions.forest, schema, idCompressor, defaultIncrementalEncodingPolicy);
31
- const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
32
- forest,
33
- schema,
34
- breaker,
35
- });
36
- const out = new SchematizingSimpleTreeView(checkout, config, createNodeIdentifierManager(idCompressor));
37
- return out;
25
+ return createIndependentTreeAlpha(options).viewWith(config);
38
26
  }
39
27
  /**
40
28
  * Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.
@@ -48,39 +36,116 @@ export function independentView(config, options) {
48
36
  * @alpha
49
37
  */
50
38
  export function independentInitializedView(config, options, content) {
51
- const idCompressor = content.idCompressor;
52
- const fieldBatchCodec = makeFieldBatchCodec(options, 1);
53
- const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
54
- const schema = schemaCodec.decode(content.schema);
55
- const context = {
56
- encodeType: TreeCompressionStrategy.Compressed,
57
- idCompressor,
58
- originatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?
59
- schema: { schema, policy: defaultSchemaPolicy },
60
- };
61
- const fieldCursors = fieldBatchCodec.decode(content.tree, context);
62
- assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
63
- return independentInitializedViewInternal(config, options, schema,
64
- // Checked above.
65
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
- fieldCursors[0], idCompressor);
39
+ return createIndependentTreeAlpha({ ...options, content }).viewWith(config);
40
+ }
41
+ /**
42
+ * Create a {@link ViewableTree} that is not tied to any Fluid runtimes or services.
43
+ *
44
+ * @remarks
45
+ * Such a tree can never experience collaboration or be persisted to to a Fluid Container.
46
+ *
47
+ * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const tree = createIndependentTreeBeta();
52
+ *
53
+ * const stagedConfig = new TreeViewConfiguration({
54
+ * schema: SchemaFactoryAlpha.types([
55
+ * SchemaFactory.number,
56
+ * SchemaFactoryAlpha.staged(SchemaFactory.string),
57
+ * ]),
58
+ * });
59
+ * const afterConfig = new TreeViewConfigurationAlpha({
60
+ * schema: [SchemaFactory.number, SchemaFactory.string],
61
+ * });
62
+ *
63
+ * // Initialize tree
64
+ * {
65
+ * const view = tree.viewWith(stagedConfig);
66
+ * view.initialize(1);
67
+ * view.dispose();
68
+ * }
69
+ *
70
+ * // Do schema upgrade
71
+ * {
72
+ * const view = tree.viewWith(afterConfig);
73
+ * view.upgradeSchema();
74
+ * view.root = "A";
75
+ * view.dispose();
76
+ * }
77
+ *
78
+ * // Can still view tree with staged schema
79
+ * {
80
+ * const view = tree.viewWith(stagedConfig);
81
+ * assert.equal(view.root, "A");
82
+ * view.dispose();
83
+ * }
84
+ * ```
85
+ * @privateRemarks
86
+ * Before stabilizing this as public, consider if we can instead just expose a better way to create regular Fluid service based SharedTrees for tests.
87
+ * Something like https://github.com/microsoft/FluidFramework/pull/25422 might be a better long term stable/public solution.
88
+ * @beta
89
+ */
90
+ export function createIndependentTreeBeta(options) {
91
+ return createIndependentTreeAlpha(options);
67
92
  }
68
93
  /**
69
- * {@link independentInitializedView} but using internal types instead of persisted data formats.
94
+ * Alpha extensions to {@link createIndependentTreeBeta}.
95
+ *
96
+ * @param options - Configuration options for the independent tree.
97
+ * This can be used to create an uninitialized tree, or `content` can be provided to create an initialized tree.
98
+ * If content is provided, the idCompressor is a required part of it: otherwise it is optional and provided at the top level.
99
+ *
100
+ * @privateRemarks
101
+ * TODO: Support more of {@link ITreeAlpha}, including branching APIs to allow for merges.
102
+ * TODO: Better unify this logic with SharedTreeKernel and SharedTreeCore.
103
+ *
104
+ * Before further stabilizing: consider better ways to handle initialized vs uninitialized trees.
105
+ * Perhaps it would be better to not allow initialize here at all, but expose the ability to load compressed tree content and stored schema via ITree or TreeView?
106
+ * If keeping the option here, maybe a separate function of overload would be better? Or maybe flatten ViewContent inline to deduplicate the idCompressor options?
107
+ * @alpha
70
108
  */
71
- export function independentInitializedViewInternal(config, options, schema, rootFieldCursor, idCompressor) {
72
- const breaker = new Breakable("independentInitializedView");
73
- const revisionTagCodec = new RevisionTagCodec(idCompressor);
109
+ export function createIndependentTreeAlpha(options) {
110
+ const breaker = new Breakable("independentView");
111
+ const idCompressor = options?.idCompressor ?? options?.content?.idCompressor ?? createIdCompressor();
74
112
  const mintRevisionTag = () => idCompressor.generateCompressedId();
113
+ const revisionTagCodec = new RevisionTagCodec(idCompressor);
75
114
  // To ensure the forest is in schema when constructed, start it with an empty schema and set the schema repository content later.
76
115
  const schemaRepository = new TreeStoredSchemaRepository();
77
- const forest = buildConfiguredForest(breaker, options.forest ?? defaultSharedTreeOptions.forest, schemaRepository, idCompressor, defaultIncrementalEncodingPolicy);
116
+ const forest = buildConfiguredForest(breaker, options?.forest ?? defaultSharedTreeOptions.forest, schemaRepository, idCompressor, defaultIncrementalEncodingPolicy);
78
117
  const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
79
118
  forest,
80
119
  schema: schemaRepository,
81
120
  breaker,
82
121
  });
83
- initialize(checkout, schema, initializerFromChunk(checkout, () => combineChunks(checkout.forest.chunkField(rootFieldCursor))));
84
- return new SchematizingSimpleTreeView(checkout, config, createNodeIdentifierManager(idCompressor));
122
+ if (options?.content !== undefined) {
123
+ const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
124
+ const fieldBatchCodec = makeFieldBatchCodec(options, 1);
125
+ const newSchema = schemaCodec.decode(options.content.schema);
126
+ const context = {
127
+ encodeType: TreeCompressionStrategy.Compressed,
128
+ idCompressor,
129
+ originatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?
130
+ schema: { schema: newSchema, policy: defaultSchemaPolicy },
131
+ };
132
+ const fieldCursors = fieldBatchCodec.decode(options.content.tree, context);
133
+ assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
134
+ const fieldCursor = oneFromIterable(fieldCursors);
135
+ assert(fieldCursor !== undefined, 0xc94 /* expected exactly one field in batch */);
136
+ initialize(checkout, newSchema, initializerFromChunk(checkout, () => combineChunks(checkout.forest.chunkField(fieldCursor))));
137
+ }
138
+ return {
139
+ viewWith(config) {
140
+ const out = new SchematizingSimpleTreeView(checkout, config, createNodeIdentifierManager(idCompressor));
141
+ return out;
142
+ },
143
+ exportVerbose() {
144
+ return checkout.exportVerbose();
145
+ },
146
+ exportSimpleSchema() {
147
+ return exportSimpleSchema(checkout.storedSchema);
148
+ },
149
+ };
85
150
  }
86
151
  //# sourceMappingURL=independentView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"independentView.js","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAEN,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAGN,gBAAgB,EAChB,aAAa,EAEb,0BAA0B,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EAEf,mBAAmB,EACnB,uBAAuB,EACvB,gCAAgC,GAChC,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAoD,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EACN,qBAAqB,EACrB,wBAAwB,GAExB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;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ACN,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CACnC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAC1D,CACD,CAAC;IACF,OAAO,IAAI,0BAA0B,CACpC,QAAQ,EACR,MAAM,EACN,2BAA2B,CAAC,YAAY,CAAC,CACzC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IIdCompressor,\n\tcreateIdCompressor,\n} from \"@fluidframework/id-compressor/internal\";\n\nimport type { ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype ITreeCursorSynchronous,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\tSchemaVersion,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\tcreateNodeIdentifierManager,\n\tmakeFieldBatchCodec,\n\tmakeSchemaCodec,\n\ttype FieldBatchEncodingContext,\n\tdefaultSchemaPolicy,\n\tTreeCompressionStrategy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"../feature-libraries/index.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport type { Format } from \"../feature-libraries/schema-index/formatV1.js\";\nimport type {\n\tTreeViewConfiguration,\n\tImplicitFieldSchema,\n\tTreeViewAlpha,\n} from \"../simple-tree/index.js\";\nimport { type JsonCompatibleReadOnly, type JsonCompatible, Breakable } from \"../util/index.js\";\nimport {\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\ttype ForestOptions,\n} from \"./sharedTree.js\";\nimport { createTreeCheckout } from \"./treeCheckout.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport { initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport { combineChunks } from \"../feature-libraries/index.js\";\n\n/**\n * Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @alpha\n */\nexport function independentView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & { idCompressor?: IIdCompressor | undefined },\n): TreeViewAlpha<TSchema> {\n\tconst breaker = new Breakable(\"independentView\");\n\tconst idCompressor: IIdCompressor = options.idCompressor ?? createIdCompressor();\n\tconst mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();\n\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\tconst schema = new TreeStoredSchemaRepository();\n\tconst forest = buildConfiguredForest(\n\t\tbreaker,\n\t\toptions.forest ?? defaultSharedTreeOptions.forest,\n\t\tschema,\n\t\tidCompressor,\n\t\tdefaultIncrementalEncodingPolicy,\n\t);\n\tconst checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {\n\t\tforest,\n\t\tschema,\n\t\tbreaker,\n\t});\n\tconst out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(\n\t\tcheckout,\n\t\tconfig,\n\t\tcreateNodeIdentifierManager(idCompressor),\n\t);\n\treturn out;\n}\n/**\n * Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @privateRemarks\n * TODO: Providing an API which generates a {@link ViewableTree} extended with export options from {@link ITreeAlpha} and maybe even branching APIs would likely be better that just exposing a {@link TreeViewAlpha}.\n * @alpha\n */\nexport function independentInitializedView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & ICodecOptions,\n\tcontent: ViewContent,\n): TreeViewAlpha<TSchema> {\n\tconst idCompressor: IIdCompressor = content.idCompressor;\n\tconst fieldBatchCodec = makeFieldBatchCodec(options, 1);\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\n\tconst schema = schemaCodec.decode(content.schema as Format);\n\tconst context: FieldBatchEncodingContext = {\n\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\tidCompressor,\n\t\toriginatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?\n\t\tschema: { schema, policy: defaultSchemaPolicy },\n\t};\n\n\tconst fieldCursors = fieldBatchCodec.decode(content.tree as JsonCompatibleReadOnly, context);\n\tassert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);\n\n\treturn independentInitializedViewInternal(\n\t\tconfig,\n\t\toptions,\n\t\tschema,\n\t\t// Checked above.\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tfieldCursors[0]!,\n\t\tidCompressor,\n\t);\n}\n\n/**\n * {@link independentInitializedView} but using internal types instead of persisted data formats.\n */\nexport function independentInitializedViewInternal<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & ICodecOptions,\n\tschema: TreeStoredSchema,\n\trootFieldCursor: ITreeCursorSynchronous,\n\tidCompressor: IIdCompressor,\n): SchematizingSimpleTreeView<TSchema> {\n\tconst breaker = new Breakable(\"independentInitializedView\");\n\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\tconst mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();\n\n\t// To ensure the forest is in schema when constructed, start it with an empty schema and set the schema repository content later.\n\tconst schemaRepository = new TreeStoredSchemaRepository();\n\n\tconst forest = buildConfiguredForest(\n\t\tbreaker,\n\t\toptions.forest ?? defaultSharedTreeOptions.forest,\n\t\tschemaRepository,\n\t\tidCompressor,\n\t\tdefaultIncrementalEncodingPolicy,\n\t);\n\n\tconst checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {\n\t\tforest,\n\t\tschema: schemaRepository,\n\t\tbreaker,\n\t});\n\n\tinitialize(\n\t\tcheckout,\n\t\tschema,\n\t\tinitializerFromChunk(checkout, () =>\n\t\t\tcombineChunks(checkout.forest.chunkField(rootFieldCursor)),\n\t\t),\n\t);\n\treturn new SchematizingSimpleTreeView<TSchema>(\n\t\tcheckout,\n\t\tconfig,\n\t\tcreateNodeIdentifierManager(idCompressor),\n\t);\n}\n\n/**\n * The portion of SharedTree data typically persisted by the container.\n * Usable with {@link independentInitializedView} to create a {@link TreeView}\n * without loading a container.\n * @alpha\n */\nexport interface ViewContent {\n\t/**\n\t * Compressed tree from {@link (TreeAlpha:interface).exportCompressed}.\n\t * @remarks\n\t * This is an owning reference:\n\t * consumers of this content might modify this data in place (for example when applying edits) to avoid copying.\n\t */\n\treadonly tree: JsonCompatible<IFluidHandle>;\n\t/**\n\t * Persisted schema from {@link extractPersistedSchema}.\n\t */\n\treadonly schema: JsonCompatible;\n\t/**\n\t * IIdCompressor which will be used to decompress any compressed identifiers in `tree`\n\t * as well as for any other identifiers added to the view.\n\t */\n\treadonly idCompressor: IIdCompressor;\n}\n"]}
1
+ {"version":3,"file":"independentView.js","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAEN,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAEN,gBAAgB,EAChB,aAAa,EACb,0BAA0B,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EAEf,mBAAmB,EACnB,uBAAuB,EACvB,gCAAgC,GAChC,MAAM,+BAA+B,CAAC;AAcvC,OAAO,EAGN,SAAS,EACT,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,GAElB,MAAM,iBAAiB,CA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CAAC,CAAC,CACtD,CACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,QAAQ,CACP,MAAoC;YAEpC,MAAM,GAAG,GAA2B,IAAI,0BAA0B,CACjE,QAAQ,EACR,MAA6E,EAC7E,2BAA2B,CAAC,YAAY,CAAC,CACzC,CAAC;YACF,OAAO,GAAiC,CAAC;QAC1C,CAAC;QAED,aAAa;YACZ,OAAO,QAAQ,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAED,kBAAkB;YACjB,OAAO,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IIdCompressor,\n\tcreateIdCompressor,\n} from \"@fluidframework/id-compressor/internal\";\n\nimport type { ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\tSchemaVersion,\n\tTreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\tcreateNodeIdentifierManager,\n\tmakeFieldBatchCodec,\n\tmakeSchemaCodec,\n\ttype FieldBatchEncodingContext,\n\tdefaultSchemaPolicy,\n\tTreeCompressionStrategy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"../feature-libraries/index.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport type { Format } from \"../feature-libraries/schema-index/formatV1.js\";\nimport type {\n\tTreeViewConfiguration,\n\tImplicitFieldSchema,\n\tTreeViewAlpha,\n\tITreeAlpha,\n\tViewableTree,\n\tTreeView,\n\tReadSchema,\n\tVerboseTree,\n\tSimpleTreeSchema,\n} from \"../simple-tree/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatible,\n\tBreakable,\n\toneFromIterable,\n} from \"../util/index.js\";\nimport {\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\texportSimpleSchema,\n\ttype ForestOptions,\n} from \"./sharedTree.js\";\nimport { createTreeCheckout } from \"./treeCheckout.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport { initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport { combineChunks } from \"../feature-libraries/index.js\";\n\n/**\n * Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @alpha\n */\nexport function independentView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & { idCompressor?: IIdCompressor | undefined },\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha(options).viewWith(config) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @privateRemarks\n * TODO: Providing an API which generates a {@link ViewableTree} extended with export options from {@link ITreeAlpha} and maybe even branching APIs would likely be better that just exposing a {@link TreeViewAlpha}.\n * @alpha\n */\nexport function independentInitializedView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & ICodecOptions,\n\tcontent: ViewContent,\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha({ ...options, content }).viewWith(\n\t\tconfig,\n\t) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create a {@link ViewableTree} that is not tied to any Fluid runtimes or services.\n *\n * @remarks\n * Such a tree can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n *\n * @example\n * ```typescript\n * const tree = createIndependentTreeBeta();\n *\n * const stagedConfig = new TreeViewConfiguration({\n * \tschema: SchemaFactoryAlpha.types([\n * \t\tSchemaFactory.number,\n * \t\tSchemaFactoryAlpha.staged(SchemaFactory.string),\n * \t]),\n * });\n * const afterConfig = new TreeViewConfigurationAlpha({\n * \tschema: [SchemaFactory.number, SchemaFactory.string],\n * });\n *\n * // Initialize tree\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tview.initialize(1);\n * \tview.dispose();\n * }\n *\n * // Do schema upgrade\n * {\n * \tconst view = tree.viewWith(afterConfig);\n * \tview.upgradeSchema();\n * \tview.root = \"A\";\n * \tview.dispose();\n * }\n *\n * // Can still view tree with staged schema\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tassert.equal(view.root, \"A\");\n * \tview.dispose();\n * }\n * ```\n * @privateRemarks\n * Before stabilizing this as public, consider if we can instead just expose a better way to create regular Fluid service based SharedTrees for tests.\n * Something like https://github.com/microsoft/FluidFramework/pull/25422 might be a better long term stable/public solution.\n * @beta\n */\nexport function createIndependentTreeBeta<const TSchema extends ImplicitFieldSchema>(\n\toptions?: ForestOptions,\n): ViewableTree {\n\treturn createIndependentTreeAlpha<TSchema>(options);\n}\n\n/**\n * Alpha extensions to {@link createIndependentTreeBeta}.\n *\n * @param options - Configuration options for the independent tree.\n * This can be used to create an uninitialized tree, or `content` can be provided to create an initialized tree.\n * If content is provided, the idCompressor is a required part of it: otherwise it is optional and provided at the top level.\n *\n * @privateRemarks\n * TODO: Support more of {@link ITreeAlpha}, including branching APIs to allow for merges.\n * TODO: Better unify this logic with SharedTreeKernel and SharedTreeCore.\n *\n * Before further stabilizing: consider better ways to handle initialized vs uninitialized trees.\n * Perhaps it would be better to not allow initialize here at all, but expose the ability to load compressed tree content and stored schema via ITree or TreeView?\n * If keeping the option here, maybe a separate function of overload would be better? Or maybe flatten ViewContent inline to deduplicate the idCompressor options?\n * @alpha\n */\nexport function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSchema>(\n\toptions?: ForestOptions &\n\t\t(\n\t\t\t| ({ idCompressor?: IIdCompressor | undefined } & { content?: undefined })\n\t\t\t| (ICodecOptions & { content: ViewContent } & { idCompressor?: undefined })\n\t\t),\n): ViewableTree & Pick<ITreeAlpha, \"exportVerbose\" | \"exportSimpleSchema\"> {\n\tconst breaker = new Breakable(\"independentView\");\n\tconst idCompressor: IIdCompressor =\n\t\toptions?.idCompressor ?? options?.content?.idCompressor ?? createIdCompressor();\n\tconst mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();\n\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\n\t// To ensure the forest is in schema when constructed, start it with an empty schema and set the schema repository content later.\n\tconst schemaRepository = new TreeStoredSchemaRepository();\n\n\tconst forest = buildConfiguredForest(\n\t\tbreaker,\n\t\toptions?.forest ?? defaultSharedTreeOptions.forest,\n\t\tschemaRepository,\n\t\tidCompressor,\n\t\tdefaultIncrementalEncodingPolicy,\n\t);\n\n\tconst checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {\n\t\tforest,\n\t\tschema: schemaRepository,\n\t\tbreaker,\n\t});\n\n\tif (options?.content !== undefined) {\n\t\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\t\tconst fieldBatchCodec = makeFieldBatchCodec(options, 1);\n\t\tconst newSchema = schemaCodec.decode(options.content.schema as Format);\n\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?\n\t\t\tschema: { schema: newSchema, policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst fieldCursors = fieldBatchCodec.decode(\n\t\t\toptions.content.tree as JsonCompatibleReadOnly,\n\t\t\tcontext,\n\t\t);\n\t\tassert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);\n\n\t\tconst fieldCursor = oneFromIterable(fieldCursors);\n\t\tassert(fieldCursor !== undefined, 0xc94 /* expected exactly one field in batch */);\n\n\t\tinitialize(\n\t\t\tcheckout,\n\t\t\tnewSchema,\n\t\t\tinitializerFromChunk(checkout, () =>\n\t\t\t\tcombineChunks(checkout.forest.chunkField(fieldCursor)),\n\t\t\t),\n\t\t);\n\t}\n\n\treturn {\n\t\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\t\tconfig: TreeViewConfiguration<TRoot>,\n\t\t): TreeView<TRoot> {\n\t\t\tconst out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(\n\t\t\t\tcheckout,\n\t\t\t\tconfig as TreeViewConfiguration as TreeViewConfiguration<ReadSchema<TSchema>>,\n\t\t\t\tcreateNodeIdentifierManager(idCompressor),\n\t\t\t);\n\t\t\treturn out as unknown as TreeView<TRoot>;\n\t\t},\n\n\t\texportVerbose(): VerboseTree | undefined {\n\t\t\treturn checkout.exportVerbose();\n\t\t},\n\n\t\texportSimpleSchema(): SimpleTreeSchema {\n\t\t\treturn exportSimpleSchema(checkout.storedSchema);\n\t\t},\n\t};\n}\n\n/**\n * The portion of SharedTree data typically persisted by the container.\n * Usable with {@link independentInitializedView} to create a {@link TreeView}\n * without loading a container.\n * @alpha\n */\nexport interface ViewContent {\n\t/**\n\t * Compressed tree from {@link (TreeAlpha:interface).exportCompressed}.\n\t * @remarks\n\t * This is an owning reference:\n\t * consumers of this content might modify this data in place (for example when applying edits) to avoid copying.\n\t */\n\treadonly tree: JsonCompatible<IFluidHandle>;\n\t/**\n\t * Persisted schema from {@link extractPersistedSchema}.\n\t */\n\treadonly schema: JsonCompatible;\n\t/**\n\t * IIdCompressor which will be used to decompress any compressed identifiers in `tree`\n\t * as well as for any other identifiers added to the view.\n\t */\n\treadonly idCompressor: IIdCompressor;\n}\n"]}
@@ -5,11 +5,12 @@
5
5
  export { type ITreePrivate, type SharedTreeOptionsInternal, type SharedTreeOptions, type SharedTreeOptionsBeta, SharedTreeKernel, getBranch, type ForestType, type SharedTreeContentSnapshot, type SharedTreeFormatOptions, SharedTreeFormatVersion, buildConfiguredForest, defaultSharedTreeOptions, type ForestOptions, type ITreeInternal, ForestTypeOptimized, ForestTypeExpensiveDebug, ForestTypeReference, exportSimpleSchema, type SharedTreeKernelView, persistedToSimpleSchema, getCodecTreeForSharedTreeFormat, } from "./sharedTree.js";
6
6
  export { createTreeCheckout, TreeCheckout, type ITreeCheckout, type CheckoutEvents, type ITreeCheckoutFork, type BranchableTree, type TreeBranchFork, } from "./treeCheckout.js";
7
7
  export { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
8
+ export { initialize, initializerFromChunk } from "./schematizeTree.js";
8
9
  export type { ISharedTreeEditor, ISchemaEditor, SharedTreeEditBuilder, } from "./sharedTreeEditBuilder.js";
9
10
  export { Tree } from "./tree.js";
10
11
  export type { RunTransaction } from "./tree.js";
11
12
  export { TreeAlpha, type TreeIdentifierUtils, type ObservationResults, } from "./treeAlpha.js";
12
- export { independentInitializedView, type ViewContent, independentView, } from "./independentView.js";
13
+ export { independentInitializedView, type ViewContent, independentView, createIndependentTreeBeta, createIndependentTreeAlpha, } from "./independentView.js";
13
14
  export type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
14
15
  export { getCodecTreeForChangeFormat, type SharedTreeChangeFormatVersion, } from "./sharedTreeChangeCodecs.js";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,gBAAgB,EAChB,SAAS,EACT,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,mBAAmB,EAC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EACzB,uBAAuB,EACvB,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EACN,SAAS,EACT,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,0BAA0B,EAC1B,KAAK,WAAW,EAChB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EACN,2BAA2B,EAC3B,KAAK,6BAA6B,GAClC,MAAM,6BAA6B,CAAC"}
@@ -5,8 +5,9 @@
5
5
  export { SharedTreeKernel, getBranch, SharedTreeFormatVersion, buildConfiguredForest, defaultSharedTreeOptions, ForestTypeOptimized, ForestTypeExpensiveDebug, ForestTypeReference, exportSimpleSchema, persistedToSimpleSchema, getCodecTreeForSharedTreeFormat, } from "./sharedTree.js";
6
6
  export { createTreeCheckout, TreeCheckout, } from "./treeCheckout.js";
7
7
  export { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
8
+ export { initialize, initializerFromChunk } from "./schematizeTree.js";
8
9
  export { Tree } from "./tree.js";
9
10
  export { TreeAlpha, } from "./treeAlpha.js";
10
- export { independentInitializedView, independentView, } from "./independentView.js";
11
+ export { independentInitializedView, independentView, createIndependentTreeBeta, createIndependentTreeAlpha, } from "./independentView.js";
11
12
  export { getCodecTreeForChangeFormat, } from "./sharedTreeChangeCodecs.js";
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,gBAAgB,EAChB,SAAS,EAIT,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EAGxB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAElB,uBAAuB,EACvB,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,kBAAkB,EAClB,YAAY,GAMZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAQvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EACN,SAAS,GAGT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,0BAA0B,EAE1B,eAAe,GACf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACN,2BAA2B,GAE3B,MAAM,6BAA6B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITreePrivate,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\tSharedTreeKernel,\n\tgetBranch,\n\ttype ForestType,\n\ttype SharedTreeContentSnapshot,\n\ttype SharedTreeFormatOptions,\n\tSharedTreeFormatVersion,\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\ttype ForestOptions,\n\ttype ITreeInternal,\n\tForestTypeOptimized,\n\tForestTypeExpensiveDebug,\n\tForestTypeReference,\n\texportSimpleSchema,\n\ttype SharedTreeKernelView,\n\tpersistedToSimpleSchema,\n\tgetCodecTreeForSharedTreeFormat,\n} from \"./sharedTree.js\";\n\nexport {\n\tcreateTreeCheckout,\n\tTreeCheckout,\n\ttype ITreeCheckout,\n\ttype CheckoutEvents,\n\ttype ITreeCheckoutFork,\n\ttype BranchableTree,\n\ttype TreeBranchFork,\n} from \"./treeCheckout.js\";\n\nexport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\n\nexport type {\n\tISharedTreeEditor,\n\tISchemaEditor,\n\tSharedTreeEditBuilder,\n} from \"./sharedTreeEditBuilder.js\";\n\nexport { Tree } from \"./tree.js\";\nexport type { RunTransaction } from \"./tree.js\";\n\nexport {\n\tTreeAlpha,\n\ttype TreeIdentifierUtils,\n\ttype ObservationResults,\n} from \"./treeAlpha.js\";\n\nexport {\n\tindependentInitializedView,\n\ttype ViewContent,\n\tindependentView,\n} from \"./independentView.js\";\n\nexport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\nexport {\n\tgetCodecTreeForChangeFormat,\n\ttype SharedTreeChangeFormatVersion,\n} from \"./sharedTreeChangeCodecs.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,gBAAgB,EAChB,SAAS,EAIT,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EAGxB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAElB,uBAAuB,EACvB,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,kBAAkB,EAClB,YAAY,GAMZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAQvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EACN,SAAS,GAGT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,0BAA0B,EAE1B,eAAe,EACf,yBAAyB,EACzB,0BAA0B,GAC1B,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACN,2BAA2B,GAE3B,MAAM,6BAA6B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITreePrivate,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\tSharedTreeKernel,\n\tgetBranch,\n\ttype ForestType,\n\ttype SharedTreeContentSnapshot,\n\ttype SharedTreeFormatOptions,\n\tSharedTreeFormatVersion,\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\ttype ForestOptions,\n\ttype ITreeInternal,\n\tForestTypeOptimized,\n\tForestTypeExpensiveDebug,\n\tForestTypeReference,\n\texportSimpleSchema,\n\ttype SharedTreeKernelView,\n\tpersistedToSimpleSchema,\n\tgetCodecTreeForSharedTreeFormat,\n} from \"./sharedTree.js\";\n\nexport {\n\tcreateTreeCheckout,\n\tTreeCheckout,\n\ttype ITreeCheckout,\n\ttype CheckoutEvents,\n\ttype ITreeCheckoutFork,\n\ttype BranchableTree,\n\ttype TreeBranchFork,\n} from \"./treeCheckout.js\";\n\nexport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\n\nexport { initialize, initializerFromChunk } from \"./schematizeTree.js\";\n\nexport type {\n\tISharedTreeEditor,\n\tISchemaEditor,\n\tSharedTreeEditBuilder,\n} from \"./sharedTreeEditBuilder.js\";\n\nexport { Tree } from \"./tree.js\";\nexport type { RunTransaction } from \"./tree.js\";\n\nexport {\n\tTreeAlpha,\n\ttype TreeIdentifierUtils,\n\ttype ObservationResults,\n} from \"./treeAlpha.js\";\n\nexport {\n\tindependentInitializedView,\n\ttype ViewContent,\n\tindependentView,\n\tcreateIndependentTreeBeta,\n\tcreateIndependentTreeAlpha,\n} from \"./independentView.js\";\n\nexport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\n\nexport {\n\tgetCodecTreeForChangeFormat,\n\ttype SharedTreeChangeFormatVersion,\n} from \"./sharedTreeChangeCodecs.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAItB,KAAK,aAAa,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGN,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,YAAY,EASjB,KAAK,gBAAgB,EACrB,0BAA0B,EAC1B,KAAK,4BAA4B,EAIjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKN,uBAAuB,EAavB,KAAK,yBAAyB,EAG9B,KAAK,8BAA8B,EACnC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAI7B,KAAK,oBAAoB,EACzB,cAAc,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,KAAK,KAAK,EACV,KAAK,mBAAmB,EAExB,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,mB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IAAI,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,EAChD,OAAO,CAAC,+BAA+B,CAAC;IACzC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CACtD;AACD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,cAAc,EAAE,uBAAuB,CAAC;IACxC;;;;;;;;;;OAUG;IACH,aAAa,EAAE,uBAAuB,CAAC,MAAM,uBAAuB,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,+BAChB,SAAQ,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,CAAC;IACvD,cAAc,EAAE,8BAA8B,CAAC;CAC/C;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU,CAAC,YAAY,CAAC;CAAG;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,YAG/B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,YAY/B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,YAGpC,CAAC;AAaF;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,4BAA4B,EACpC,YAAY,EAAE,aAAa,EAC3B,yBAAyB,EAAE,yBAAyB,GAClD,eAAe,CAOjB;AAED,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,yBAAyB,CAQxE,CAAC"}
@@ -511,6 +511,21 @@ export const defaultSharedTreeOptions = {
511
511
  disposeForksAfterTransaction: true,
512
512
  shouldEncodeIncrementally: defaultIncrementalEncodingPolicy,
513
513
  };
514
+ /**
515
+ * Build the allowed types for a Stored Schema.
516
+ *
517
+ * @remarks Staged upgrades do not apply to stored schemas, so we omit the {@link SimpleAllowedTypeAttributes.isStaged | staging flag } when building {@link SimpleAllowedTypeAttributes}.
518
+ * @param types - The types to create allowed types for.
519
+ * @returns The allowed types.
520
+ */
521
+ function buildSimpleAllowedTypeAttributesForStoredSchema(types) {
522
+ const allowedTypesInfo = new Map();
523
+ for (const type of types) {
524
+ // Stored schemas do not have staged upgrades
525
+ allowedTypesInfo.set(type, { isStaged: undefined });
526
+ }
527
+ return allowedTypesInfo;
528
+ }
514
529
  function exportSimpleFieldSchemaStored(schema) {
515
530
  let kind;
516
531
  switch (schema.kind) {
@@ -532,7 +547,7 @@ function exportSimpleFieldSchemaStored(schema) {
532
547
  }
533
548
  return {
534
549
  kind,
535
- allowedTypesIdentifiers: schema.types,
550
+ simpleAllowedTypes: buildSimpleAllowedTypeAttributesForStoredSchema(schema.types),
536
551
  metadata: {},
537
552
  persistedMetadata: schema.persistedMetadata,
538
553
  };
@@ -547,7 +562,7 @@ function exportSimpleNodeSchemaStored(schema) {
547
562
  if (arrayTypes !== undefined) {
548
563
  return {
549
564
  kind: NodeKind.Array,
550
- allowedTypesIdentifiers: arrayTypes,
565
+ simpleAllowedTypes: buildSimpleAllowedTypeAttributesForStoredSchema(arrayTypes),
551
566
  metadata: {},
552
567
  persistedMetadata: schema.metadata,
553
568
  };
@@ -563,7 +578,7 @@ function exportSimpleNodeSchemaStored(schema) {
563
578
  assert(schema.mapFields.kind === FieldKinds.optional.identifier, 0xa95 /* Invalid map schema */);
564
579
  return {
565
580
  kind: NodeKind.Map,
566
- allowedTypesIdentifiers: schema.mapFields.types,
581
+ simpleAllowedTypes: buildSimpleAllowedTypeAttributesForStoredSchema(schema.mapFields.types),
567
582
  metadata: {},
568
583
  persistedMetadata: schema.metadata,
569
584
  };