@fluidframework/tree 2.92.0 → 2.93.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.
- package/CHANGELOG.md +40 -0
- package/README.md +1 -1
- package/api-report/tree.alpha.api.md +57 -29
- package/api-report/tree.beta.api.md +41 -12
- package/api-report/tree.legacy.beta.api.md +41 -12
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +21 -0
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js +4 -4
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/entrypoints/beta.d.ts +1 -1
- package/dist/entrypoints/beta.d.ts.map +1 -1
- package/dist/entrypoints/beta.js +3 -1
- package/dist/entrypoints/beta.js.map +1 -1
- package/dist/entrypoints/legacy.d.ts +1 -1
- package/dist/entrypoints/legacy.d.ts.map +1 -1
- package/dist/entrypoints/legacy.js +3 -1
- package/dist/entrypoints/legacy.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +22 -18
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +1 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +3 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/indexing/types.d.ts +4 -3
- package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializableDomainSchema.d.ts +5 -5
- package/dist/serializableDomainSchema.d.ts.map +1 -1
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +6 -2
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +4 -1
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
- package/dist/simple-tree/api/identifierIndex.js +1 -1
- package/dist/simple-tree/api/identifierIndex.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +31 -2
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.d.ts +5 -5
- package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +4 -1
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeAlpha.d.ts +70 -13
- package/dist/simple-tree/api/treeAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/treeAlpha.js.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.d.ts +1 -1
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +60 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +68 -6
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/core/toStored.d.ts +7 -0
- package/dist/simple-tree/core/toStored.d.ts.map +1 -1
- package/dist/simple-tree/core/toStored.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +114 -12
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +6 -1
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +3 -0
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/map/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +6 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +17 -0
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +23 -1
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +4 -5
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +12 -23
- package/dist/tableSchema.js.map +1 -1
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +27 -0
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +4 -4
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -3
- package/dist/util/index.js.map +1 -1
- package/dist/util/utils.d.ts +0 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +1 -6
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +1 -1
- package/lib/api.d.ts +6 -1
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +21 -0
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/entrypoints/beta.d.ts +1 -1
- package/lib/entrypoints/beta.d.ts.map +1 -1
- package/lib/entrypoints/beta.js +1 -1
- package/lib/entrypoints/beta.js.map +1 -1
- package/lib/entrypoints/legacy.d.ts +1 -1
- package/lib/entrypoints/legacy.d.ts.map +1 -1
- package/lib/entrypoints/legacy.js +1 -1
- package/lib/entrypoints/legacy.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +22 -18
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +1 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +3 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/indexing/types.d.ts +4 -3
- package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/types.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializableDomainSchema.d.ts +5 -5
- package/lib/serializableDomainSchema.d.ts.map +1 -1
- package/lib/serializableDomainSchema.js +4 -1
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +6 -2
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +4 -1
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
- package/lib/simple-tree/api/identifierIndex.js +1 -1
- package/lib/simple-tree/api/identifierIndex.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +31 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +19 -3
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.d.ts +5 -5
- package/lib/simple-tree/api/simpleTreeIndex.js +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +4 -1
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeAlpha.d.ts +70 -13
- package/lib/simple-tree/api/treeAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/treeAlpha.js.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.d.ts +1 -1
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +60 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +66 -6
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/core/toStored.d.ts +7 -0
- package/lib/simple-tree/core/toStored.d.ts.map +1 -1
- package/lib/simple-tree/core/toStored.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +115 -13
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +6 -1
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +3 -0
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/map/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +6 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +17 -0
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +24 -2
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +4 -5
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +12 -23
- package/lib/tableSchema.js.map +1 -1
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +29 -0
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +4 -4
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/utils.d.ts +0 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +0 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +30 -35
- package/src/api.ts +10 -0
- package/src/core/tree/anchorSet.ts +25 -0
- package/src/entrypoints/alpha.ts +20 -16
- package/src/entrypoints/beta.ts +7 -1
- package/src/entrypoints/legacy.ts +8 -10
- package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -2
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +42 -20
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +1 -0
- package/src/feature-libraries/indexing/types.ts +5 -3
- package/src/index.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +6 -0
- package/src/shared-tree/treeAlpha.ts +6 -2
- package/src/simple-tree/api/discrepancies.ts +6 -1
- package/src/simple-tree/api/identifierIndex.ts +2 -2
- package/src/simple-tree/api/index.ts +4 -0
- package/src/simple-tree/api/schemaFactoryAlpha.ts +67 -2
- package/src/simple-tree/api/simpleTreeIndex.ts +6 -6
- package/src/simple-tree/api/storedSchema.ts +4 -1
- package/src/simple-tree/api/treeAlpha.ts +75 -12
- package/src/simple-tree/api/treeChangeEvents.ts +1 -1
- package/src/simple-tree/api/treeNodeApi.ts +101 -7
- package/src/simple-tree/core/toStored.ts +8 -0
- package/src/simple-tree/core/unhydratedFlexTree.ts +134 -10
- package/src/simple-tree/fieldSchema.ts +10 -0
- package/src/simple-tree/index.ts +5 -0
- package/src/simple-tree/node-kinds/index.ts +1 -0
- package/src/simple-tree/node-kinds/map/index.ts +1 -0
- package/src/simple-tree/node-kinds/map/mapNode.ts +20 -3
- package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +6 -6
- package/src/simple-tree/simpleSchema.ts +20 -0
- package/src/simple-tree/toStoredSchema.ts +28 -1
- package/src/tableSchema.ts +16 -28
- package/src/text/textDomain.ts +68 -1
- package/src/util/index.ts +0 -1
- package/src/util/utils.ts +0 -2
- package/.mocharc.customBenchmarks.cjs +0 -25
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { FluidReadonlyMap } from "@fluidframework/core-interfaces/internal";
|
|
6
7
|
import { assert, Lazy } from "@fluidframework/core-utils/internal";
|
|
7
8
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
9
|
|
|
@@ -152,10 +153,25 @@ export interface TreeMapNode<T extends ImplicitAllowedTypes = ImplicitAllowedTyp
|
|
|
152
153
|
): void;
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
/**
|
|
157
|
+
* {@link TreeMapNode} with FluidReadonlyMap-based iteration.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* This is the same as {@link TreeMapNode} except that it extends FluidReadonlyMap
|
|
161
|
+
* instead of the built-in `ReadonlyMap`, insulating against breaking changes
|
|
162
|
+
* in TypeScript's standard library iterator types.
|
|
163
|
+
*
|
|
164
|
+
* @sealed @alpha
|
|
165
|
+
*/
|
|
166
|
+
export interface TreeMapNodeAlpha<T extends ImplicitAllowedTypes = ImplicitAllowedTypes>
|
|
167
|
+
extends FluidReadonlyMap<string, TreeNodeFromImplicitAllowedTypes<T>>,
|
|
168
|
+
TreeNode,
|
|
169
|
+
Pick<TreeMapNode<T>, "set" | "delete"> {}
|
|
170
|
+
|
|
155
171
|
// TreeMapNode is invariant over schema type, so for this handler to work with all schema, the only possible type for the schema is `any`.
|
|
156
172
|
// This is not ideal, but no alternatives are possible.
|
|
157
173
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
-
const handler: ProxyHandler<
|
|
174
|
+
const handler: ProxyHandler<TreeMapNodeAlpha<any>> = {
|
|
159
175
|
getPrototypeOf: () => {
|
|
160
176
|
return Map.prototype;
|
|
161
177
|
},
|
|
@@ -239,7 +255,7 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
239
255
|
yield value;
|
|
240
256
|
}
|
|
241
257
|
}
|
|
242
|
-
public forEach<TThis extends
|
|
258
|
+
public forEach<TThis extends TreeMapNodeAlpha<T>>(
|
|
243
259
|
this: TThis,
|
|
244
260
|
callbackFn: (value: TreeNodeFromImplicitAllowedTypes<T>, key: string, map: TThis) => void,
|
|
245
261
|
thisArg?: unknown,
|
|
@@ -283,7 +299,8 @@ export function mapSchema<
|
|
|
283
299
|
let privateData: TreeNodeSchemaPrivateData | undefined;
|
|
284
300
|
const persistedMetadata = nodeOptions.persistedMetadata;
|
|
285
301
|
|
|
286
|
-
class Schema extends CustomMapNodeBase<T> implements
|
|
302
|
+
class Schema extends CustomMapNodeBase<T> implements TreeMapNodeAlpha<T> {
|
|
303
|
+
public readonly [Symbol.toStringTag] = "TreeMapNodeSchema";
|
|
287
304
|
public static override prepareInstance<T2>(
|
|
288
305
|
this: typeof TreeNodeValid<T2>,
|
|
289
306
|
instance: TreeNodeValid<T2>,
|
|
@@ -13,10 +13,10 @@ import type {
|
|
|
13
13
|
} from "../../core/index.js";
|
|
14
14
|
import type { SchemaType, SimpleMapNodeSchema } from "../../simpleSchema.js";
|
|
15
15
|
|
|
16
|
-
import type { MapNodeInsertableData,
|
|
16
|
+
import type { MapNodeInsertableData, TreeMapNodeAlpha } from "./mapNode.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* A schema for customizable {@link (
|
|
19
|
+
* A schema for customizable {@link (TreeMapNodeAlpha:interface)}s.
|
|
20
20
|
* @system @sealed @alpha
|
|
21
21
|
*/
|
|
22
22
|
export interface MapNodeCustomizableSchema<
|
|
@@ -27,7 +27,7 @@ export interface MapNodeCustomizableSchema<
|
|
|
27
27
|
> extends TreeNodeSchemaClass<
|
|
28
28
|
TName,
|
|
29
29
|
NodeKind.Map,
|
|
30
|
-
|
|
30
|
+
TreeMapNodeAlpha<T> & WithType<TName, NodeKind.Map, T>,
|
|
31
31
|
MapNodeInsertableData<T>,
|
|
32
32
|
ImplicitlyConstructable,
|
|
33
33
|
T,
|
|
@@ -37,7 +37,7 @@ export interface MapNodeCustomizableSchema<
|
|
|
37
37
|
SimpleMapNodeSchema<SchemaType.View, TCustomMetadata> {}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* A schema for POJO emulation mode {@link (
|
|
40
|
+
* A schema for POJO emulation mode {@link (TreeMapNodeAlpha:interface)}s.
|
|
41
41
|
* @system @sealed @alpha
|
|
42
42
|
*/
|
|
43
43
|
export interface MapNodePojoEmulationSchema<
|
|
@@ -48,7 +48,7 @@ export interface MapNodePojoEmulationSchema<
|
|
|
48
48
|
> extends TreeNodeSchemaNonClass<
|
|
49
49
|
TName,
|
|
50
50
|
NodeKind.Map,
|
|
51
|
-
|
|
51
|
+
TreeMapNodeAlpha<T> & WithType<TName, NodeKind.Map, T>,
|
|
52
52
|
MapNodeInsertableData<T>,
|
|
53
53
|
ImplicitlyConstructable,
|
|
54
54
|
T,
|
|
@@ -58,7 +58,7 @@ export interface MapNodePojoEmulationSchema<
|
|
|
58
58
|
SimpleMapNodeSchema<SchemaType.View, TCustomMetadata> {}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* A schema for {@link (
|
|
61
|
+
* A schema for {@link (TreeMapNodeAlpha:interface)}s.
|
|
62
62
|
* @privateRemarks
|
|
63
63
|
* This could have generic arguments added and forwarded.
|
|
64
64
|
* The expected use-cases for this don't need them however, and if they did want an argument it would probably be the allowed types;
|
|
@@ -286,6 +286,26 @@ export interface SimpleFieldSchema<Type extends SchemaType = SchemaType> {
|
|
|
286
286
|
* Set via {@link FieldPropsAlpha.persistedMetadata}.
|
|
287
287
|
*/
|
|
288
288
|
readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Indicates that this field is a {@link SchemaStaticsAlpha.stagedOptional | staged optional} field,
|
|
292
|
+
* allowing the view schema to be compatible with stored schema where the field is required (pre-upgrade) or optional (post-upgrade).
|
|
293
|
+
* New documents and schema upgrades will keep the field as required in the stored schema.
|
|
294
|
+
*
|
|
295
|
+
* `false` if this is a view schema field that is not staged optional.
|
|
296
|
+
* Absent (`undefined`) if derived from a stored schema (where staged optional has no meaning).
|
|
297
|
+
*
|
|
298
|
+
* `false` and `undefined` are both "not staged optional," but distinct: `false` means "view schema field, not staged
|
|
299
|
+
* optional" while `undefined` means "stored schema field." Consumers that need to check for staged optional should
|
|
300
|
+
* compare against `false` (e.g., `!== false`) rather than checking truthiness.
|
|
301
|
+
*
|
|
302
|
+
* @privateRemarks
|
|
303
|
+
* Analogous to {@link SimpleAllowedTypeAttributes.isStaged} for allowed types.
|
|
304
|
+
* Optional (`?`) so that existing code constructing `SimpleFieldSchema` object literals does not need to be updated.
|
|
305
|
+
*/
|
|
306
|
+
readonly isStagedOptional?: Type extends SchemaType.Stored
|
|
307
|
+
? undefined
|
|
308
|
+
: false | SchemaUpgrade;
|
|
289
309
|
}
|
|
290
310
|
|
|
291
311
|
/**
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
ExpectStored,
|
|
38
38
|
NodeKind,
|
|
39
|
+
SchemaUpgrade,
|
|
39
40
|
Unchanged,
|
|
40
41
|
type SimpleSchemaTransformationOptions,
|
|
41
42
|
type StoredFromViewSchemaGenerationOptions,
|
|
@@ -76,6 +77,7 @@ const viewToStoredCache = new WeakMap<
|
|
|
76
77
|
export const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =
|
|
77
78
|
{
|
|
78
79
|
includeStaged: () => false,
|
|
80
|
+
includeStagedOptional: () => false,
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -92,6 +94,7 @@ export const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGener
|
|
|
92
94
|
*/
|
|
93
95
|
export const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {
|
|
94
96
|
includeStaged: () => true,
|
|
97
|
+
includeStagedOptional: () => true,
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
/**
|
|
@@ -423,8 +426,12 @@ function filterFieldAllowedTypes(
|
|
|
423
426
|
f: SimpleFieldSchema,
|
|
424
427
|
options: SimpleSchemaTransformationOptions,
|
|
425
428
|
): SimpleFieldSchema {
|
|
429
|
+
const isStagedOptional =
|
|
430
|
+
preservesViewData(options) && f.isStagedOptional instanceof SchemaUpgrade
|
|
431
|
+
? f.isStagedOptional
|
|
432
|
+
: undefined;
|
|
426
433
|
return {
|
|
427
|
-
kind: f
|
|
434
|
+
kind: getStoredFieldKind(f, options),
|
|
428
435
|
persistedMetadata: f.persistedMetadata,
|
|
429
436
|
metadata: preservesViewData(options)
|
|
430
437
|
? {
|
|
@@ -433,9 +440,29 @@ function filterFieldAllowedTypes(
|
|
|
433
440
|
}
|
|
434
441
|
: {},
|
|
435
442
|
simpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),
|
|
443
|
+
...(isStagedOptional === undefined ? {} : { isStagedOptional }),
|
|
436
444
|
};
|
|
437
445
|
}
|
|
438
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Returns the field kind to use in the stored schema for the given view field schema.
|
|
449
|
+
* @remarks
|
|
450
|
+
* For {@link SchemaFactoryAlpha.stagedOptional | staged optional} fields, the stored field kind is Required
|
|
451
|
+
* when the staged optional is not being included (i.e., restrictive options).
|
|
452
|
+
*/
|
|
453
|
+
function getStoredFieldKind(
|
|
454
|
+
f: SimpleFieldSchema,
|
|
455
|
+
options: SimpleSchemaTransformationOptions,
|
|
456
|
+
): FieldKind {
|
|
457
|
+
if (!isStoredFromView(options)) {
|
|
458
|
+
return f.kind;
|
|
459
|
+
}
|
|
460
|
+
const { isStagedOptional } = f;
|
|
461
|
+
if (isStagedOptional === undefined || isStagedOptional === false) return f.kind;
|
|
462
|
+
// isStagedOptional is a SchemaUpgrade — use includeStagedOptional to decide the stored kind.
|
|
463
|
+
return options.includeStagedOptional(isStagedOptional) ? f.kind : FieldKind.Required;
|
|
464
|
+
}
|
|
465
|
+
|
|
439
466
|
/**
|
|
440
467
|
* Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.
|
|
441
468
|
*/
|
package/src/tableSchema.ts
CHANGED
|
@@ -8,13 +8,13 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
8
8
|
|
|
9
9
|
import { EmptyKey } from "./core/index.js";
|
|
10
10
|
import { TreeAlpha } from "./shared-tree/index.js";
|
|
11
|
-
import type { SchemaFactoryBeta } from "./simple-tree/index.js";
|
|
12
11
|
import {
|
|
13
12
|
type FieldHasDefault,
|
|
14
13
|
type ImplicitAllowedTypes,
|
|
15
14
|
type InsertableObjectFromSchemaRecord,
|
|
16
15
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
17
16
|
type NodeKind,
|
|
17
|
+
type SchemaFactoryBeta,
|
|
18
18
|
type ScopedSchemaName,
|
|
19
19
|
TreeArrayNode,
|
|
20
20
|
type TreeNode,
|
|
@@ -32,8 +32,12 @@ import {
|
|
|
32
32
|
type TreeRecordNode,
|
|
33
33
|
objectSchema,
|
|
34
34
|
eraseSchemaDetailsSubclassable,
|
|
35
|
-
//
|
|
35
|
+
// #region Unused imports to make d.ts cleaner
|
|
36
|
+
/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars */
|
|
36
37
|
TreeNodeSchemaCore,
|
|
38
|
+
FieldKind,
|
|
39
|
+
/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars */
|
|
40
|
+
// #endregion
|
|
37
41
|
type TransactionConstraintAlpha,
|
|
38
42
|
createCustomizedFluidFrameworkScopedFactory,
|
|
39
43
|
} from "./simple-tree/index.js";
|
|
@@ -792,7 +796,12 @@ export namespace System_TableSchema {
|
|
|
792
796
|
|
|
793
797
|
// First, remove all cells that correspond to each column from each row:
|
|
794
798
|
for (const column of columnsToRemove) {
|
|
795
|
-
this
|
|
799
|
+
for (const row of this.table.rows) {
|
|
800
|
+
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
801
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
802
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is currently how Record node entries are deleted.
|
|
803
|
+
delete (row as RowValueInternalType).cells[column.id];
|
|
804
|
+
}
|
|
796
805
|
}
|
|
797
806
|
|
|
798
807
|
// Second, remove the column nodes:
|
|
@@ -830,10 +839,8 @@ export namespace System_TableSchema {
|
|
|
830
839
|
for (const row of this.table.rows) {
|
|
831
840
|
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
832
841
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
row: row as RowValueType,
|
|
836
|
-
});
|
|
842
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is currently how Record node entries are deleted.
|
|
843
|
+
delete (row as RowValueInternalType).cells[columnToRemove.id];
|
|
837
844
|
}
|
|
838
845
|
|
|
839
846
|
// We have already validated that all of the columns exist above, so this is safe.
|
|
@@ -930,7 +937,7 @@ export namespace System_TableSchema {
|
|
|
930
937
|
|
|
931
938
|
this.#applyEditsInBatch({
|
|
932
939
|
applyEdits: () => {
|
|
933
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
940
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is currently how Record node entries are deleted.
|
|
934
941
|
delete row.cells[column.id];
|
|
935
942
|
},
|
|
936
943
|
// Relevant invariant: each cell corresponds to an existing row and column
|
|
@@ -938,31 +945,12 @@ export namespace System_TableSchema {
|
|
|
938
945
|
// Example scenario: Client A removes a cell, then Client B removes the column for that cell.
|
|
939
946
|
// If A's cell removal is later reverted, the cell would be restored but B's column removal means there's no column for it.
|
|
940
947
|
// This constraint on revert ensures the column still exists, ensuring restored cells correspond to existing columns.
|
|
941
|
-
preconditionsOnRevert: [
|
|
942
|
-
{
|
|
943
|
-
type: "nodeInDocument",
|
|
944
|
-
node: column,
|
|
945
|
-
},
|
|
946
|
-
],
|
|
948
|
+
preconditionsOnRevert: [{ type: "nodeInDocument", node: column }],
|
|
947
949
|
});
|
|
948
950
|
|
|
949
951
|
return cell;
|
|
950
952
|
}
|
|
951
953
|
|
|
952
|
-
/**
|
|
953
|
-
* Removes the cell corresponding with the specified column from each row in the table.
|
|
954
|
-
*/
|
|
955
|
-
#removeCells(column: ColumnValueType): void {
|
|
956
|
-
for (const row of this.table.rows) {
|
|
957
|
-
// TypeScript is unable to narrow the row type correctly here, hence the cast.
|
|
958
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
959
|
-
this.removeCell({
|
|
960
|
-
column,
|
|
961
|
-
row: row as RowValueType,
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
|
|
966
954
|
/**
|
|
967
955
|
* Applies the provided edits in a "batch".
|
|
968
956
|
*
|
package/src/text/textDomain.ts
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { compareArrays, debugAssert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import {
|
|
8
|
+
buildFunc,
|
|
9
|
+
exposeMethodsSymbol,
|
|
10
|
+
type ExposedMethods,
|
|
11
|
+
type IExposedMethods,
|
|
12
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
13
|
+
} from "@fluidframework/type-factory/alpha";
|
|
14
|
+
import { typeFactory as tf } from "@fluidframework/type-factory/internal";
|
|
7
15
|
|
|
8
16
|
import { EmptyKey, mapCursorField, type ITreeCursorSynchronous } from "../core/index.js";
|
|
9
17
|
import {
|
|
@@ -26,8 +34,67 @@ class TextNode
|
|
|
26
34
|
extends sf.object("Text", {
|
|
27
35
|
content: SchemaFactory.required([() => StringArray], { key: EmptyKey }),
|
|
28
36
|
})
|
|
29
|
-
implements TextAsTree.Members
|
|
37
|
+
implements TextAsTree.Members, IExposedMethods
|
|
30
38
|
{
|
|
39
|
+
public static [exposeMethodsSymbol](methods: ExposedMethods): void {
|
|
40
|
+
methods.exposeMethod(
|
|
41
|
+
TextNode,
|
|
42
|
+
"insertAt",
|
|
43
|
+
buildFunc(
|
|
44
|
+
{
|
|
45
|
+
description:
|
|
46
|
+
"Insert characters into the text at the given character index (Unicode code points).",
|
|
47
|
+
returns: tf.void(),
|
|
48
|
+
},
|
|
49
|
+
["index", tf.number()],
|
|
50
|
+
["additionalCharacters", tf.string()],
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
methods.exposeMethod(
|
|
54
|
+
TextNode,
|
|
55
|
+
"removeRange",
|
|
56
|
+
buildFunc(
|
|
57
|
+
{
|
|
58
|
+
description:
|
|
59
|
+
"Remove a range of characters from the text by character index (Unicode code points). startIndex defaults to 0 and endIndex defaults to the length of the text.",
|
|
60
|
+
returns: tf.void(),
|
|
61
|
+
},
|
|
62
|
+
["startIndex", tf.union([tf.number(), tf.undefined()])],
|
|
63
|
+
["endIndex", tf.union([tf.number(), tf.undefined()])],
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
methods.exposeMethod(
|
|
67
|
+
TextNode,
|
|
68
|
+
"fullString",
|
|
69
|
+
buildFunc({
|
|
70
|
+
description: "Return a copy of this text node's content as a string.",
|
|
71
|
+
returns: tf.string(),
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
methods.exposeMethod(
|
|
75
|
+
TextNode,
|
|
76
|
+
"characterCount",
|
|
77
|
+
buildFunc({
|
|
78
|
+
description:
|
|
79
|
+
"Gets the number of characters (Unicode code points) currently in the text. Joined emojis and other grapheme clusters count as multiple characters.",
|
|
80
|
+
returns: tf.number(),
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
methods.exposeMethod(
|
|
84
|
+
TextNode,
|
|
85
|
+
"charactersCopy",
|
|
86
|
+
buildFunc({
|
|
87
|
+
description:
|
|
88
|
+
"Returns all characters in the text as an array, where each element is a single Unicode code point. Joined emojis and other grapheme clusters are split into separate elements.",
|
|
89
|
+
returns: tf.array(tf.string()),
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public [exposeMethodsSymbol](methods: ExposedMethods): void {
|
|
95
|
+
TextNode[exposeMethodsSymbol](methods);
|
|
96
|
+
}
|
|
97
|
+
|
|
31
98
|
public insertAt(index: number, additionalCharacters: string): void {
|
|
32
99
|
this.content.insertAt(
|
|
33
100
|
index,
|
package/src/util/index.ts
CHANGED
package/src/util/utils.ts
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Mocha configuration file to run memory-profiling tests
|
|
8
|
-
*/
|
|
9
|
-
"use strict";
|
|
10
|
-
|
|
11
|
-
const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
|
|
12
|
-
|
|
13
|
-
const packageDir = __dirname;
|
|
14
|
-
const baseConfig = getFluidTestMochaConfig(packageDir);
|
|
15
|
-
|
|
16
|
-
baseConfig["node-option"].push("gc-global");
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
...baseConfig,
|
|
20
|
-
"fgrep": ["@CustomBenchmark"],
|
|
21
|
-
"recursive": true,
|
|
22
|
-
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
|
|
23
|
-
"reporterOptions": ["reportDir=.customBenchmarksOutput/"],
|
|
24
|
-
"spec": ["lib/test/**/*.*js"],
|
|
25
|
-
};
|