@fluidframework/tree 2.4.0-299374 → 2.4.0-299707
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/.vscode/settings.json +1 -9
- package/api-report/tree.alpha.api.md +21 -78
- package/api-report/tree.beta.api.md +21 -46
- package/api-report/tree.legacy.alpha.api.md +21 -46
- package/api-report/tree.legacy.public.api.md +21 -46
- package/api-report/tree.public.api.md +21 -46
- package/dist/alpha.d.ts +0 -9
- package/dist/beta.d.ts +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +1 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/legacy.d.ts +0 -2
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +0 -2
- package/dist/shared-tree/treeApi.d.ts +6 -6
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.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.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +3 -12
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +9 -48
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +3 -14
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +5 -6
- 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/withType.d.ts +1 -3
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +6 -58
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +1 -6
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +2 -4
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/lib/alpha.d.ts +0 -9
- package/lib/beta.d.ts +0 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +1 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/legacy.d.ts +0 -2
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +0 -2
- package/lib/shared-tree/treeApi.d.ts +6 -6
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.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.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +3 -12
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +9 -48
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +3 -14
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +5 -6
- 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/withType.d.ts +1 -3
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- 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/schemaTypes.d.ts +6 -58
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +0 -5
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +2 -4
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/package.json +23 -39
- package/src/index.ts +0 -9
- package/src/internalTypes.ts +0 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/treeApi.ts +9 -19
- package/src/simple-tree/api/index.ts +0 -5
- package/src/simple-tree/api/tree.ts +2 -24
- package/src/simple-tree/api/typesUnsafe.ts +18 -82
- package/src/simple-tree/arrayNode.ts +14 -34
- package/src/simple-tree/core/treeNodeSchema.ts +5 -7
- package/src/simple-tree/core/withType.ts +1 -10
- package/src/simple-tree/index.ts +1 -15
- package/src/simple-tree/schemaTypes.ts +5 -68
- package/src/simple-tree/toMapTree.ts +1 -4
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
NodeKind,
|
|
15
15
|
TreeNodeSchema,
|
|
16
16
|
TreeNodeSchemaClass,
|
|
17
|
-
TreeNode,
|
|
18
17
|
} from "./core/index.js";
|
|
19
18
|
import type { FieldKey } from "../core/index.js";
|
|
20
19
|
import type { InsertableContent } from "./toMapTree.js";
|
|
@@ -26,7 +25,7 @@ import { isLazy, type FlexListToUnion, type LazyItem } from "./flexList.js";
|
|
|
26
25
|
export function isTreeNodeSchemaClass<
|
|
27
26
|
Name extends string,
|
|
28
27
|
Kind extends NodeKind,
|
|
29
|
-
TNode
|
|
28
|
+
TNode,
|
|
30
29
|
TBuild,
|
|
31
30
|
ImplicitlyConstructable extends boolean,
|
|
32
31
|
Info,
|
|
@@ -382,17 +381,7 @@ export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
|
382
381
|
export type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;
|
|
383
382
|
|
|
384
383
|
/**
|
|
385
|
-
* Converts
|
|
386
|
-
*
|
|
387
|
-
* @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).
|
|
388
|
-
* This is ideal for "output APIs" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.
|
|
389
|
-
* Examples of such "non-exact" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.
|
|
390
|
-
* @privateRemarks
|
|
391
|
-
* TODO:
|
|
392
|
-
* There are two known problematic usages of this type (which produce invalid/unsound results when given non-specific schema):
|
|
393
|
-
* 1. setters for fields (on object nodes the Tree.view.root).
|
|
394
|
-
* 2. Indirectly in InsertableTreeFieldFromImplicitField via InsertableTypedNode including NodeFromSchema.
|
|
395
|
-
* These cases should be mitigated by introducing a way to detect inexact schema and special casing them in these two places.
|
|
384
|
+
* Converts ImplicitFieldSchema to the corresponding tree node's field type.
|
|
396
385
|
* @public
|
|
397
386
|
*/
|
|
398
387
|
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =
|
|
@@ -400,7 +389,7 @@ export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = Fie
|
|
|
400
389
|
? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false>
|
|
401
390
|
: TSchema extends ImplicitAllowedTypes
|
|
402
391
|
? TreeNodeFromImplicitAllowedTypes<TSchema>
|
|
403
|
-
:
|
|
392
|
+
: unknown;
|
|
404
393
|
|
|
405
394
|
/**
|
|
406
395
|
* Type of content that can be inserted into the tree for a field of the given schema.
|
|
@@ -412,55 +401,7 @@ export type InsertableTreeFieldFromImplicitField<
|
|
|
412
401
|
? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>
|
|
413
402
|
: TSchema extends ImplicitAllowedTypes
|
|
414
403
|
? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
|
|
415
|
-
:
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* {@inheritdoc (UnsafeUnknownSchema:type)}
|
|
419
|
-
* @alpha
|
|
420
|
-
*/
|
|
421
|
-
export const UnsafeUnknownSchema: unique symbol = Symbol("UnsafeUnknownSchema");
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.
|
|
425
|
-
* @remarks
|
|
426
|
-
* When used this means the TypeScript typing should error on the side of completeness (allow all inputs that could be valid).
|
|
427
|
-
* This introduces the risk that out of schema data could be allowed at compile time, and only error at runtime.
|
|
428
|
-
*
|
|
429
|
-
* @privateRemarks
|
|
430
|
-
* This only applies to APIs which input data which is expected to be in schema, since APIs outputting have easy mechanisms to do so in a type safe way even when the schema is unknown.
|
|
431
|
-
* In most cases that amounts to returning `TreeNode | TreeLeafValue`.
|
|
432
|
-
*
|
|
433
|
-
* This can be contrasted with the default behavior of TypeScript, which is to require the intersection of the possible types for input APIs,
|
|
434
|
-
* which for unknown schema defining input trees results in the `never` type.
|
|
435
|
-
*
|
|
436
|
-
* Any APIs which use this must produce UsageErrors when out of schema data is encountered, and never produce unrecoverable errors,
|
|
437
|
-
* or silently accept invalid data.
|
|
438
|
-
* This is currently only type exported from the package: the symbol is just used as a way to get a named type.
|
|
439
|
-
* @alpha
|
|
440
|
-
*/
|
|
441
|
-
export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Content which could be inserted into a tree.
|
|
445
|
-
* @remarks
|
|
446
|
-
* Extended version of {@link InsertableTreeNodeFromImplicitAllowedTypes} that also allows {@link (UnsafeUnknownSchema:type)}.
|
|
447
|
-
* @alpha
|
|
448
|
-
*/
|
|
449
|
-
export type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> =
|
|
450
|
-
TSchema extends ImplicitAllowedTypes
|
|
451
|
-
? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
|
|
452
|
-
: InsertableContent;
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Content which could be inserted into a field within a tree.
|
|
456
|
-
* @remarks
|
|
457
|
-
* Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.
|
|
458
|
-
* @alpha
|
|
459
|
-
*/
|
|
460
|
-
export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =
|
|
461
|
-
TSchema extends ImplicitFieldSchema
|
|
462
|
-
? InsertableTreeFieldFromImplicitField<TSchema>
|
|
463
|
-
: InsertableContent | undefined;
|
|
404
|
+
: unknown;
|
|
464
405
|
|
|
465
406
|
/**
|
|
466
407
|
* Suitable for output.
|
|
@@ -512,10 +453,6 @@ export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<
|
|
|
512
453
|
/**
|
|
513
454
|
* Data which can be used as a node to be inserted.
|
|
514
455
|
* Either an unhydrated node, or content to build a new node.
|
|
515
|
-
* @privateRemarks
|
|
516
|
-
* TODO:
|
|
517
|
-
* This should behave contravariantly, but it uses NodeFromSchema which behaves covariantly.
|
|
518
|
-
* This results in unsoundness where when the schema is less specific, more types are allowed instead of less.
|
|
519
456
|
* @public
|
|
520
457
|
*/
|
|
521
458
|
export type InsertableTypedNode<T extends TreeNodeSchema> =
|
|
@@ -534,7 +471,7 @@ export type InsertableTypedNode<T extends TreeNodeSchema> =
|
|
|
534
471
|
export type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<
|
|
535
472
|
string,
|
|
536
473
|
NodeKind,
|
|
537
|
-
|
|
474
|
+
unknown,
|
|
538
475
|
infer TBuild
|
|
539
476
|
>
|
|
540
477
|
? TBuild
|
|
@@ -726,7 +726,6 @@ function tryGetInnerNode(target: unknown): InnerNode | undefined {
|
|
|
726
726
|
* Content which can be used to build a node.
|
|
727
727
|
* @remarks
|
|
728
728
|
* Can contain unhydrated nodes, but can not be an unhydrated node at the root.
|
|
729
|
-
* @system @alpha
|
|
730
729
|
*/
|
|
731
730
|
export type FactoryContent =
|
|
732
731
|
| IFluidHandle
|
|
@@ -745,14 +744,12 @@ export type FactoryContent =
|
|
|
745
744
|
* Can contain unhydrated nodes, but can not be an unhydrated node at the root.
|
|
746
745
|
*
|
|
747
746
|
* Supports object and map nodes.
|
|
748
|
-
* @system @alpha
|
|
749
747
|
*/
|
|
750
|
-
|
|
748
|
+
type FactoryContentObject = {
|
|
751
749
|
readonly [P in string]?: InsertableContent;
|
|
752
750
|
};
|
|
753
751
|
|
|
754
752
|
/**
|
|
755
753
|
* Content which can be inserted into a tree.
|
|
756
|
-
* @system @alpha
|
|
757
754
|
*/
|
|
758
755
|
export type InsertableContent = Unhydrated<TreeNode> | FactoryContent;
|