@fluidframework/tree 2.70.0-360753 → 2.70.0-361248
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/.eslintrc.cjs +1 -0
- package/dist/codec/codec.d.ts +3 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +4 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +0 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -14
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/dist/feature-libraries/incrementalSummarizationUtils.d.ts +1 -1
- package/dist/feature-libraries/incrementalSummarizationUtils.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV1.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/formatV1.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.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/shared-tree/sharedTree.d.ts +1 -1
- package/dist/shared-tree/sharedTree.js +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +2 -2
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +6 -2
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +2 -2
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -8
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts +2 -2
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +2 -2
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +1 -1
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +1 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/util/breakable.js +3 -3
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts +1 -1
- package/dist/util/nestedMap.js +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/referenceCounting.d.ts +1 -1
- package/dist/util/referenceCounting.js.map +1 -1
- package/dist/util/utils.d.ts +7 -4
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +23 -16
- package/dist/util/utils.js.map +1 -1
- package/lib/codec/codec.d.ts +3 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +4 -1
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +0 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +2 -12
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/lib/feature-libraries/incrementalSummarizationUtils.d.ts +1 -1
- package/lib/feature-libraries/incrementalSummarizationUtils.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/formatV1.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.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/shared-tree/sharedTree.d.ts +1 -1
- package/lib/shared-tree/sharedTree.js +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +2 -2
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +6 -2
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +2 -2
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -8
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts +2 -2
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +2 -2
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +1 -1
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +2 -2
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +1 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/util/breakable.js +3 -3
- package/lib/util/breakable.js.map +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/nestedMap.d.ts +1 -1
- package/lib/util/nestedMap.js +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/referenceCounting.d.ts +1 -1
- package/lib/util/referenceCounting.js.map +1 -1
- package/lib/util/utils.d.ts +7 -4
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +21 -14
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/codec/codec.ts +3 -3
- package/src/core/rebase/changeRebaser.ts +1 -1
- package/src/core/tree/detachedFieldIndex.ts +4 -1
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +2 -13
- package/src/feature-libraries/flex-tree/utilities.ts +1 -1
- package/src/feature-libraries/incrementalSummarizationUtils.ts +1 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -1
- package/src/feature-libraries/sequence-field/formatV1.ts +1 -1
- package/src/feature-libraries/sequence-field/formatV2.ts +1 -1
- package/src/feature-libraries/sequence-field/formatV3.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/sharedTree.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +1 -1
- package/src/shared-tree-core/transaction.ts +2 -2
- package/src/simple-tree/core/allowedTypes.ts +5 -17
- package/src/simple-tree/core/treeNodeSchema.ts +3 -8
- package/src/simple-tree/core/treeNodeValid.ts +3 -3
- package/src/simple-tree/core/walkSchema.ts +1 -2
- package/src/simple-tree/createContext.ts +1 -4
- package/src/simple-tree/leafNodeSchema.ts +1 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -2
- package/src/simple-tree/node-kinds/map/mapNode.ts +1 -1
- package/src/simple-tree/node-kinds/object/objectNode.ts +2 -5
- package/src/simple-tree/node-kinds/record/recordNode.ts +1 -1
- package/src/util/breakable.ts +4 -4
- package/src/util/index.ts +1 -1
- package/src/util/nestedMap.ts +1 -1
- package/src/util/referenceCounting.ts +1 -1
- package/src/util/utils.ts +22 -15
|
@@ -31,7 +31,7 @@ export function treeStatusFromDetachedField(detachedField: DetachedField): TreeS
|
|
|
31
31
|
*
|
|
32
32
|
* @param anchors - the {@link AnchorSet} to compare your anchorNode cache to.
|
|
33
33
|
* @param anchorNode - the {@link AnchorNode} to get the {@link TreeStatus} of.
|
|
34
|
-
* @returns
|
|
34
|
+
* @returns the {@link TreeStatus} of the anchorNode provided.
|
|
35
35
|
*/
|
|
36
36
|
export function treeStatusFromAnchorCache(anchorNode: AnchorNode): TreeStatus {
|
|
37
37
|
const cache = anchorNode.slots.get(detachedFieldSlot);
|
|
@@ -13,7 +13,7 @@ export interface CollabWindow {
|
|
|
13
13
|
* gives the sequenceNumber of the op currently being processed.
|
|
14
14
|
* `undefined` if no message has been processed, e.g. for a detached document or document loaded
|
|
15
15
|
* from summary without any subsequent ops.
|
|
16
|
-
* @remarks
|
|
16
|
+
* @remarks Most rebasing is built atop a revision system decoupled from message sequence number.
|
|
17
17
|
* However, this is sometimes necessary to interop with Fluid runtime APIs, e.g. for incremental summarization.
|
|
18
18
|
*/
|
|
19
19
|
getCurrentSeq: () => number | undefined;
|
|
@@ -2142,7 +2142,7 @@ function deltaFromNodeChange(
|
|
|
2142
2142
|
* For example, when rebasing change B from a local branch [A, B, C] over a branch [X, Y], the `baseRevisions` must include
|
|
2143
2143
|
* revisions [A⁻¹ X, Y, A] if rebasing over the composition of all those changes, or
|
|
2144
2144
|
* revision [A⁻¹] for the first rebase, then [X], etc. if rebasing over edits individually.
|
|
2145
|
-
* @returns
|
|
2145
|
+
* @returns RebaseRevisionMetadata to be passed to `FieldChangeRebaser.rebase`*
|
|
2146
2146
|
*/
|
|
2147
2147
|
export function rebaseRevisionMetadataFromInfo(
|
|
2148
2148
|
revInfos: readonly RevisionInfo[],
|
|
@@ -161,7 +161,7 @@ export const Changeset = <Schema extends TSchema>(tNodeChange: Schema) =>
|
|
|
161
161
|
Type.Array(Mark(tNodeChange));
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* @privateRemarks
|
|
164
|
+
* @privateRemarks Many of these names are currently used in the sequence-field types. Putting them in a namespace makes codec code more readable.
|
|
165
165
|
*/
|
|
166
166
|
export namespace Encoded {
|
|
167
167
|
export type CellCount = Static<typeof CellCount>;
|
|
@@ -110,7 +110,7 @@ export const Changeset = <Schema extends TSchema>(tNodeChange: Schema) =>
|
|
|
110
110
|
Type.Array(Mark(tNodeChange));
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* @privateRemarks
|
|
113
|
+
* @privateRemarks Many of these names are currently used in the sequence-field types. Putting them in a namespace makes codec code more readable.
|
|
114
114
|
*/
|
|
115
115
|
export namespace Encoded {
|
|
116
116
|
export type CellCount = Static<typeof CellCount>;
|
|
@@ -39,7 +39,7 @@ export const Changeset = <Schema extends TSchema>(tNodeChange: Schema) =>
|
|
|
39
39
|
Type.Array(Mark(tNodeChange));
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* @privateRemarks
|
|
42
|
+
* @privateRemarks Many of these names are currently used in the sequence-field types. Putting them in a namespace makes codec code more readable.
|
|
43
43
|
*/
|
|
44
44
|
export namespace Encoded {
|
|
45
45
|
export type CellCount = EncodedV2.CellCount;
|
package/src/packageVersion.ts
CHANGED
|
@@ -667,7 +667,7 @@ export const SharedTreeFormatVersion = {
|
|
|
667
667
|
/**
|
|
668
668
|
* Requires \@fluidframework/tree \>= 2.0.0.
|
|
669
669
|
*
|
|
670
|
-
* @deprecated
|
|
670
|
+
* @deprecated FF does not currently plan on supporting this format long-term.
|
|
671
671
|
* Do not write production documents using this format, as they may not be loadable in the future.
|
|
672
672
|
*/
|
|
673
673
|
v1: 1,
|
|
@@ -636,7 +636,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
636
636
|
* @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).
|
|
637
637
|
* @param checkout - The {@link TreeCheckout} instance this revertible belongs to.
|
|
638
638
|
* @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.
|
|
639
|
-
* @returns
|
|
639
|
+
* @returns A {@link RevertibleAlpha} object.
|
|
640
640
|
*/
|
|
641
641
|
private createRevertible(
|
|
642
642
|
revision: RevisionTag,
|
|
@@ -42,7 +42,7 @@ export interface Transactor {
|
|
|
42
42
|
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
43
43
|
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
44
44
|
*
|
|
45
|
-
* @remarks
|
|
45
|
+
* @remarks Asynchronous transactions are not supported on the root checkout,
|
|
46
46
|
* since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
|
|
47
47
|
* the transaction) is not visible to the application author.
|
|
48
48
|
* Instead,
|
|
@@ -51,7 +51,7 @@ export interface Transactor {
|
|
|
51
51
|
* 2. run the transaction on the fork
|
|
52
52
|
* 3. merge the fork back into the root checkout
|
|
53
53
|
*
|
|
54
|
-
* @privateRemarks
|
|
54
|
+
* @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
|
|
55
55
|
* AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
|
|
56
56
|
*/
|
|
57
57
|
start(): void;
|
|
@@ -253,32 +253,20 @@ export class AnnotatedAllowedTypesInternal<
|
|
|
253
253
|
return this.lazyEvaluate.value.identifiers;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
public static override [Symbol.hasInstance]<
|
|
257
|
-
TThis extends
|
|
258
|
-
| (abstract new (
|
|
259
|
-
...args: unknown[]
|
|
260
|
-
) => object)
|
|
261
|
-
| typeof AnnotatedAllowedTypesInternal,
|
|
262
|
-
>(
|
|
256
|
+
public static override [Symbol.hasInstance]<TThis extends { prototype: object }>(
|
|
263
257
|
this: TThis,
|
|
264
|
-
value:
|
|
258
|
+
value: unknown,
|
|
265
259
|
): value is InstanceTypeRelaxed<TThis> & AnnotatedAllowedTypesInternal & AllowedTypesFull {
|
|
266
|
-
return
|
|
260
|
+
return ErasedTypeImplementation[Symbol.hasInstance].call(this, value);
|
|
267
261
|
}
|
|
268
262
|
|
|
269
|
-
public static override narrow<
|
|
270
|
-
TThis extends
|
|
271
|
-
| (abstract new (
|
|
272
|
-
...args: unknown[]
|
|
273
|
-
) => object)
|
|
274
|
-
| typeof AnnotatedAllowedTypesInternal,
|
|
275
|
-
>(
|
|
263
|
+
public static override narrow<TThis extends { prototype: object }>(
|
|
276
264
|
this: TThis,
|
|
277
265
|
value: ErasedBaseType | InstanceTypeRelaxed<TThis> | ImplicitAllowedTypes,
|
|
278
266
|
): asserts value is InstanceTypeRelaxed<TThis> &
|
|
279
267
|
AnnotatedAllowedTypesInternal &
|
|
280
268
|
AllowedTypesFull {
|
|
281
|
-
if (!
|
|
269
|
+
if (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value)) {
|
|
282
270
|
throw new TypeError("Invalid AnnotatedAllowedTypes instance");
|
|
283
271
|
}
|
|
284
272
|
}
|
|
@@ -10,7 +10,7 @@ import type { SimpleNodeSchemaBase } from "./simpleNodeSchemaBase.js";
|
|
|
10
10
|
import type { TreeNode } from "./treeNode.js";
|
|
11
11
|
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
12
12
|
import type { UnionToIntersection } from "../../util/index.js";
|
|
13
|
-
import type {
|
|
13
|
+
import type { AllowedTypesFullEvaluated, AllowedTypesFull } from "./allowedTypes.js";
|
|
14
14
|
import type { Context } from "./context.js";
|
|
15
15
|
import type { FieldKey, NodeData, TreeNodeStoredSchema } from "../../core/index.js";
|
|
16
16
|
import type { UnhydratedFlexTreeField } from "./unhydratedFlexTree.js";
|
|
@@ -379,16 +379,11 @@ export interface TreeNodeSchemaPrivateData {
|
|
|
379
379
|
* In this case "field" includes anything that is a field in the internal (flex-tree) abstraction layer.
|
|
380
380
|
* This includes the content field for arrays, and all the fields for map nodes.
|
|
381
381
|
* If this node does not have fields (and thus is a leaf), the array will be empty.
|
|
382
|
-
*
|
|
383
|
-
* This set cannot be used before the schema in it have been defined:
|
|
384
|
-
* more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),
|
|
385
|
-
* users must wait until after the schema are defined to access this array.
|
|
386
|
-
*
|
|
387
382
|
* @privateRemarks
|
|
388
383
|
* If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.
|
|
389
384
|
* @system
|
|
390
385
|
*/
|
|
391
|
-
readonly
|
|
386
|
+
readonly childAllowedTypes: readonly AllowedTypesFull[];
|
|
392
387
|
|
|
393
388
|
/**
|
|
394
389
|
* Idempotent initialization function that pre-caches data and can dereference lazy schema references.
|
|
@@ -422,7 +417,7 @@ export interface TreeNodeSchemaInitializedData {
|
|
|
422
417
|
* If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.
|
|
423
418
|
* @system
|
|
424
419
|
*/
|
|
425
|
-
readonly
|
|
420
|
+
readonly childAllowedTypes: readonly AllowedTypesFullEvaluated[];
|
|
426
421
|
|
|
427
422
|
/**
|
|
428
423
|
* A {@link Context} which can be used for unhydrated nodes of this schema.
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./treeNodeKernel.js";
|
|
26
26
|
import type { InternalTreeNode } from "./types.js";
|
|
27
27
|
import { typeSchemaSymbol } from "./withType.js";
|
|
28
|
-
import type {
|
|
28
|
+
import type { AllowedTypesFull } from "./allowedTypes.js";
|
|
29
29
|
import type { SimpleNodeSchemaBase } from "./simpleNodeSchemaBase.js";
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -259,7 +259,7 @@ export function isClassBasedSchema(
|
|
|
259
259
|
*/
|
|
260
260
|
export function createTreeNodeSchemaPrivateData(
|
|
261
261
|
schema: TreeNodeSchemaCore<string, NodeKind, boolean>,
|
|
262
|
-
|
|
262
|
+
childAllowedTypes: readonly AllowedTypesFull[],
|
|
263
263
|
toStored: TreeNodeSchemaPrivateData["toStored"],
|
|
264
264
|
): TreeNodeSchemaPrivateData {
|
|
265
265
|
const schemaValid = schemaAsTreeNodeValid(schema);
|
|
@@ -269,7 +269,7 @@ export function createTreeNodeSchemaPrivateData(
|
|
|
269
269
|
|
|
270
270
|
return {
|
|
271
271
|
idempotentInitialize: () => schemaValid.oneTimeInitialize().oneTimeInitialized,
|
|
272
|
-
|
|
272
|
+
childAllowedTypes,
|
|
273
273
|
toStored,
|
|
274
274
|
};
|
|
275
275
|
}
|
|
@@ -28,8 +28,7 @@ export function walkNodeSchema(
|
|
|
28
28
|
// Since walkNodeSchema is used in the implementation of TreeNodeSchemaPrivateData.idempotentInitialize,
|
|
29
29
|
// Avoid depending on it here to avoid circular dependencies for recursive schema.
|
|
30
30
|
// Instead normalize/evaluate the allowed types as needed.
|
|
31
|
-
const annotatedAllowedTypes =
|
|
32
|
-
getTreeNodeSchemaPrivateData(schema).childAnnotatedAllowedTypes;
|
|
31
|
+
const annotatedAllowedTypes = getTreeNodeSchemaPrivateData(schema).childAllowedTypes;
|
|
33
32
|
|
|
34
33
|
for (const fieldAllowedTypes of annotatedAllowedTypes) {
|
|
35
34
|
walkAllowedTypes(
|
|
@@ -9,7 +9,6 @@ import { getOrCreate } from "../util/index.js";
|
|
|
9
9
|
import {
|
|
10
10
|
Context,
|
|
11
11
|
getTreeNodeSchemaPrivateData,
|
|
12
|
-
normalizeAndEvaluateAnnotatedAllowedTypes,
|
|
13
12
|
UnhydratedContext,
|
|
14
13
|
type TreeNodeSchema,
|
|
15
14
|
type TreeNodeSchemaInitializedData,
|
|
@@ -50,8 +49,6 @@ export function getTreeNodeSchemaInitializedData(
|
|
|
50
49
|
return {
|
|
51
50
|
...handler,
|
|
52
51
|
context: getUnhydratedContext(schema),
|
|
53
|
-
|
|
54
|
-
normalizeAndEvaluateAnnotatedAllowedTypes,
|
|
55
|
-
),
|
|
52
|
+
childAllowedTypes: data.childAllowedTypes.map((t) => t.evaluate()),
|
|
56
53
|
};
|
|
57
54
|
}
|
|
@@ -63,7 +63,7 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
63
63
|
allowedTypes: ReadonlySet<TreeNodeSchema>,
|
|
64
64
|
): FlexContent => leafToFlexContent(data, this, allowedTypes),
|
|
65
65
|
})),
|
|
66
|
-
|
|
66
|
+
childAllowedTypes: [],
|
|
67
67
|
toStored: () => new LeafNodeStoredSchema(this.leafKind),
|
|
68
68
|
};
|
|
69
69
|
#initializedData: TreeNodeSchemaInitializedData | undefined;
|
|
@@ -1273,8 +1273,11 @@ export function arraySchema<
|
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
1275
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
1276
|
-
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
1277
|
-
|
|
1276
|
+
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
1277
|
+
this,
|
|
1278
|
+
[normalizedTypes],
|
|
1279
|
+
(storedOptions) =>
|
|
1280
|
+
arrayNodeStoredSchema(convertAllowedTypes(info, storedOptions), persistedMetadata),
|
|
1278
1281
|
));
|
|
1279
1282
|
}
|
|
1280
1283
|
}
|
|
@@ -336,7 +336,7 @@ export function mapSchema<
|
|
|
336
336
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
337
337
|
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
338
338
|
this,
|
|
339
|
-
[
|
|
339
|
+
[normalizedTypes],
|
|
340
340
|
(storedOptions) =>
|
|
341
341
|
new MapNodeStoredSchema(
|
|
342
342
|
{
|
|
@@ -99,7 +99,7 @@ import type { ObjectSchemaOptionsAlpha } from "../../api/index.js";
|
|
|
99
99
|
*/
|
|
100
100
|
export type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =
|
|
101
101
|
RestrictiveStringRecord<ImplicitFieldSchema> extends T
|
|
102
|
-
? // eslint-disable-next-line @typescript-eslint/ban-types
|
|
102
|
+
? // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types
|
|
103
103
|
{}
|
|
104
104
|
: {
|
|
105
105
|
-readonly [Property in keyof T]: Property extends string
|
|
@@ -577,10 +577,7 @@ export function objectSchema<
|
|
|
577
577
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
578
578
|
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
579
579
|
this,
|
|
580
|
-
Array.from(
|
|
581
|
-
flexKeyMap.values(),
|
|
582
|
-
({ schema }) => normalizeFieldSchema(schema).allowedTypes,
|
|
583
|
-
),
|
|
580
|
+
Array.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),
|
|
584
581
|
(storedOptions) => {
|
|
585
582
|
const fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();
|
|
586
583
|
for (const fieldSchema of flexKeyMap.values()) {
|
|
@@ -381,7 +381,7 @@ export function recordSchema<
|
|
|
381
381
|
public static get [privateDataSymbol](): TreeNodeSchemaPrivateData {
|
|
382
382
|
return (privateData ??= createTreeNodeSchemaPrivateData(
|
|
383
383
|
this,
|
|
384
|
-
[
|
|
384
|
+
[normalizedTypes],
|
|
385
385
|
(storedOptions) =>
|
|
386
386
|
new MapNodeStoredSchema(
|
|
387
387
|
{
|
package/src/util/breakable.ts
CHANGED
|
@@ -171,10 +171,10 @@ export function throwIfBroken<
|
|
|
171
171
|
return replacementMethod as Target;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
175
175
|
type PossiblyNamedFunction = Function & { displayName?: undefined | string };
|
|
176
176
|
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
178
178
|
function nameFunctionFrom(toName: Function, nameFrom: Function): void {
|
|
179
179
|
(toName as PossiblyNamedFunction).displayName =
|
|
180
180
|
(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;
|
|
@@ -183,13 +183,13 @@ function nameFunctionFrom(toName: Function, nameFrom: Function): void {
|
|
|
183
183
|
const isBreakerSymbol: unique symbol = Symbol("isBreaker");
|
|
184
184
|
|
|
185
185
|
// Accepting any function like value is desired and safe here as this does not call the provided function.
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
187
187
|
function markBreaker(f: Function): void {
|
|
188
188
|
(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// Accepting any function like value is desired and safe here as this does not call the provided function.
|
|
192
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
193
193
|
function isBreaker(f: Function): boolean {
|
|
194
194
|
return isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);
|
|
195
195
|
}
|
package/src/util/index.ts
CHANGED
package/src/util/nestedMap.ts
CHANGED
|
@@ -49,7 +49,7 @@ export function tryAddToNestedMap<Key1, Key2, Value>(
|
|
|
49
49
|
* @param destination - The map to copy data into. Both the outer and inner map may be mutated.
|
|
50
50
|
* @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.
|
|
51
51
|
*
|
|
52
|
-
* @remarks
|
|
52
|
+
* @remarks This function performs deep copying when necessary.
|
|
53
53
|
* This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.
|
|
54
54
|
*/
|
|
55
55
|
export function populateNestedMap<Key1, Key2, Value>(
|
|
@@ -8,7 +8,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
8
8
|
/**
|
|
9
9
|
* An object which counts the number of users / references to it.
|
|
10
10
|
* @remarks
|
|
11
|
-
* This implements the
|
|
11
|
+
* This implements the {@link https://en.wikipedia.org/wiki/Reference_counting | Reference counting} pattern.
|
|
12
12
|
* Getting the reference count correct is difficult in TypeScript and great care must be used.
|
|
13
13
|
* Because of this, this interface should not be used in the public API.
|
|
14
14
|
*/
|
package/src/util/utils.ts
CHANGED
|
@@ -105,6 +105,28 @@ export function iterableHasSome<T>(iterable: Iterable<T>): boolean {
|
|
|
105
105
|
return iterable[Symbol.iterator]().next().done === false;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Returns the value from the given iterable if it contains exactly one item, otherwise `undefined`.
|
|
110
|
+
* @remarks
|
|
111
|
+
* Note that if the iterable itself may contain `undefined` values,
|
|
112
|
+
* it is not possible to use this to distinguish between an iterable that contains exactly one `undefined` value and an iterable that contains zero or multiple values.
|
|
113
|
+
*/
|
|
114
|
+
export function oneFromIterable<T>(items: Iterable<T>): T | undefined {
|
|
115
|
+
const iterator = items[Symbol.iterator]();
|
|
116
|
+
const first = iterator.next();
|
|
117
|
+
if (first.done === true) {
|
|
118
|
+
// Empty iterable case.
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const second = iterator.next();
|
|
122
|
+
if (second.done === true) {
|
|
123
|
+
// Single item iterable case.
|
|
124
|
+
return first.value;
|
|
125
|
+
}
|
|
126
|
+
// Multiple item iterable case.
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
108
130
|
/**
|
|
109
131
|
* Returns true if and only if the given array has exactly one element.
|
|
110
132
|
* @param array - The array to check.
|
|
@@ -477,21 +499,6 @@ export function invertMap<Key, Value>(input: Map<Key, Value>): Map<Value, Key> {
|
|
|
477
499
|
return result;
|
|
478
500
|
}
|
|
479
501
|
|
|
480
|
-
/**
|
|
481
|
-
* Returns the value from `set` if it contains exactly one item, otherwise `undefined`.
|
|
482
|
-
*/
|
|
483
|
-
export function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {
|
|
484
|
-
if (set === undefined) {
|
|
485
|
-
return undefined;
|
|
486
|
-
}
|
|
487
|
-
if (set.size !== 1) {
|
|
488
|
-
return undefined;
|
|
489
|
-
}
|
|
490
|
-
for (const item of set) {
|
|
491
|
-
return item;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
502
|
/**
|
|
496
503
|
* Type with a name describing what it is.
|
|
497
504
|
* Typically used with values (like schema) that can be stored in a map, but in some representations have their name/key as a field.
|