@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
package/src/index.ts
CHANGED
|
@@ -114,7 +114,6 @@ export {
|
|
|
114
114
|
type InsertableObjectFromSchemaRecordUnsafe,
|
|
115
115
|
type InsertableTreeFieldFromImplicitFieldUnsafe,
|
|
116
116
|
type FieldSchemaUnsafe,
|
|
117
|
-
type TreeNodeSchemaClassUnsafe,
|
|
118
117
|
// System types (not in Internal types for various reasons, like doc links or cannot be named errors).
|
|
119
118
|
type typeSchemaSymbol,
|
|
120
119
|
type TreeNodeSchemaNonClass,
|
|
@@ -126,13 +125,6 @@ export {
|
|
|
126
125
|
enumFromStrings,
|
|
127
126
|
singletonSchema,
|
|
128
127
|
typedObjectValues,
|
|
129
|
-
type UnsafeUnknownSchema,
|
|
130
|
-
type TreeViewAlpha,
|
|
131
|
-
type InsertableField,
|
|
132
|
-
type Insertable,
|
|
133
|
-
type InsertableContent,
|
|
134
|
-
type FactoryContent,
|
|
135
|
-
type FactoryContentObject,
|
|
136
128
|
// test recursive schema for checking that d.ts files handles schema correctly
|
|
137
129
|
test_RecursiveObject,
|
|
138
130
|
test_RecursiveObject_base,
|
|
@@ -159,7 +151,6 @@ export {
|
|
|
159
151
|
getJsonSchema,
|
|
160
152
|
type LazyItem,
|
|
161
153
|
type Unenforced,
|
|
162
|
-
type ReadonlyArrayNode,
|
|
163
154
|
} from "./simple-tree/index.js";
|
|
164
155
|
export {
|
|
165
156
|
SharedTree,
|
package/src/internalTypes.ts
CHANGED
|
@@ -33,9 +33,6 @@ export type {
|
|
|
33
33
|
NodeBuilderDataUnsafe,
|
|
34
34
|
NodeFromSchemaUnsafe,
|
|
35
35
|
ReadonlyMapInlined,
|
|
36
|
-
TreeNodeSchemaUnsafe,
|
|
37
|
-
AllowedTypesUnsafe,
|
|
38
|
-
TreeNodeSchemaNonClassUnsafe,
|
|
39
36
|
} from "./simple-tree/index.js";
|
|
40
37
|
export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js";
|
|
41
38
|
|
package/src/packageVersion.ts
CHANGED
|
@@ -78,10 +78,7 @@ export interface RunTransaction {
|
|
|
78
78
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
79
79
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
80
80
|
*/
|
|
81
|
-
|
|
82
|
-
// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
<TView extends TreeView<any>, TResult>(
|
|
81
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
|
85
82
|
tree: TView,
|
|
86
83
|
transaction: (root: TView["root"]) => TResult,
|
|
87
84
|
): TResult;
|
|
@@ -126,9 +123,7 @@ export interface RunTransaction {
|
|
|
126
123
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
127
124
|
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
|
128
125
|
*/
|
|
129
|
-
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
-
<TView extends TreeView<any>, TResult>(
|
|
126
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
|
132
127
|
tree: TView,
|
|
133
128
|
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
|
134
129
|
): TResult | typeof rollback;
|
|
@@ -166,9 +161,10 @@ export interface RunTransaction {
|
|
|
166
161
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
167
162
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
168
163
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
<TView extends TreeView<ImplicitFieldSchema>>(
|
|
165
|
+
tree: TView,
|
|
166
|
+
transaction: (root: TView["root"]) => void,
|
|
167
|
+
): void;
|
|
172
168
|
/**
|
|
173
169
|
* Apply one or more edits to the tree as a single atomic unit.
|
|
174
170
|
* @param node - The node that will be passed to `transaction`.
|
|
@@ -215,9 +211,7 @@ export interface RunTransaction {
|
|
|
215
211
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
216
212
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
217
213
|
*/
|
|
218
|
-
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
220
|
-
<TView extends TreeView<any>, TResult>(
|
|
214
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
|
221
215
|
tree: TView,
|
|
222
216
|
transaction: (root: TView["root"]) => TResult,
|
|
223
217
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -270,9 +264,7 @@ export interface RunTransaction {
|
|
|
270
264
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
271
265
|
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
|
272
266
|
*/
|
|
273
|
-
|
|
274
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
275
|
-
<TView extends TreeView<any>, TResult>(
|
|
267
|
+
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
|
276
268
|
tree: TView,
|
|
277
269
|
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
|
278
270
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -321,9 +313,7 @@ export interface RunTransaction {
|
|
|
321
313
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
322
314
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
323
315
|
*/
|
|
324
|
-
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
|
-
<TView extends TreeView<any>>(
|
|
316
|
+
<TView extends TreeView<ImplicitFieldSchema>>(
|
|
327
317
|
tree: TView,
|
|
328
318
|
transaction: (root: TView["root"]) => void,
|
|
329
319
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -12,7 +12,6 @@ export {
|
|
|
12
12
|
type ITreeViewConfiguration,
|
|
13
13
|
type SchemaCompatibilityStatus,
|
|
14
14
|
type ITreeConfigurationOptions,
|
|
15
|
-
type TreeViewAlpha,
|
|
16
15
|
} from "./tree.js";
|
|
17
16
|
export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
|
|
18
17
|
export type {
|
|
@@ -63,10 +62,6 @@ export type {
|
|
|
63
62
|
NodeBuilderDataUnsafe,
|
|
64
63
|
NodeFromSchemaUnsafe,
|
|
65
64
|
ReadonlyMapInlined,
|
|
66
|
-
TreeNodeSchemaClassUnsafe,
|
|
67
|
-
TreeNodeSchemaUnsafe,
|
|
68
|
-
AllowedTypesUnsafe,
|
|
69
|
-
TreeNodeSchemaNonClassUnsafe,
|
|
70
65
|
} from "./typesUnsafe.js";
|
|
71
66
|
|
|
72
67
|
export type {
|
|
@@ -11,14 +11,11 @@ import type { Listenable } from "../../events/index.js";
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
type ImplicitFieldSchema,
|
|
14
|
-
type InsertableField,
|
|
15
14
|
type InsertableTreeFieldFromImplicitField,
|
|
16
15
|
type TreeFieldFromImplicitField,
|
|
17
|
-
type TreeLeafValue,
|
|
18
|
-
type UnsafeUnknownSchema,
|
|
19
16
|
FieldKind,
|
|
20
17
|
} from "../schemaTypes.js";
|
|
21
|
-
import { NodeKind, type
|
|
18
|
+
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
22
19
|
import { toStoredSchema } from "../toFlexSchema.js";
|
|
23
20
|
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
24
21
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
@@ -366,7 +363,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
366
363
|
* Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.
|
|
367
364
|
* @sealed @public
|
|
368
365
|
*/
|
|
369
|
-
export interface TreeView<
|
|
366
|
+
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
370
367
|
/**
|
|
371
368
|
* The current root of the tree.
|
|
372
369
|
*
|
|
@@ -427,25 +424,6 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
|
|
|
427
424
|
readonly schema: TSchema;
|
|
428
425
|
}
|
|
429
426
|
|
|
430
|
-
/**
|
|
431
|
-
* {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.
|
|
432
|
-
* @alpha
|
|
433
|
-
*/
|
|
434
|
-
export interface TreeViewAlpha<
|
|
435
|
-
in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
|
436
|
-
> extends Omit<
|
|
437
|
-
TreeView<TSchema extends ImplicitFieldSchema ? TSchema : ImplicitFieldSchema>,
|
|
438
|
-
"root" | "initialize"
|
|
439
|
-
> {
|
|
440
|
-
get root(): TSchema extends ImplicitFieldSchema
|
|
441
|
-
? TreeFieldFromImplicitField<TSchema>
|
|
442
|
-
: TreeLeafValue | TreeNode;
|
|
443
|
-
|
|
444
|
-
set root(newRoot: InsertableField<TSchema>);
|
|
445
|
-
|
|
446
|
-
initialize(content: InsertableField<TSchema>): void;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
427
|
/**
|
|
450
428
|
* Information about a view schema's compatibility with the document's stored schema.
|
|
451
429
|
*
|
|
@@ -6,24 +6,24 @@
|
|
|
6
6
|
import type { RestrictiveStringRecord, _InlineTrick } from "../../util/index.js";
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
|
+
AllowedTypes,
|
|
9
10
|
ApplyKind,
|
|
10
11
|
FieldKind,
|
|
11
12
|
FieldSchema,
|
|
12
13
|
ImplicitAllowedTypes,
|
|
13
14
|
ImplicitFieldSchema,
|
|
14
|
-
|
|
15
|
+
NodeFromSchema,
|
|
16
|
+
TreeNodeFromImplicitAllowedTypes,
|
|
15
17
|
} from "../schemaTypes.js";
|
|
16
18
|
import type {
|
|
17
19
|
NodeKind,
|
|
20
|
+
TreeNodeSchema,
|
|
18
21
|
WithType,
|
|
19
22
|
TreeNode,
|
|
20
23
|
Unhydrated,
|
|
21
|
-
InternalTreeNode,
|
|
22
|
-
TreeNodeSchema,
|
|
23
|
-
TreeNodeSchemaCore,
|
|
24
24
|
} from "../core/index.js";
|
|
25
|
-
import type { TreeArrayNodeBase } from "../arrayNode.js";
|
|
26
|
-
import type { FlexListToUnion
|
|
25
|
+
import type { TreeArrayNodeBase, TreeArrayNode } from "../arrayNode.js";
|
|
26
|
+
import type { FlexListToUnion } from "../flexList.js";
|
|
27
27
|
|
|
28
28
|
/*
|
|
29
29
|
* TODO:
|
|
@@ -59,65 +59,6 @@ export type ObjectFromSchemaRecordUnsafe<
|
|
|
59
59
|
-readonly [Property in keyof T]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* {@link Unenforced} version of {@link TreeNodeSchema}.
|
|
64
|
-
* @remarks
|
|
65
|
-
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
66
|
-
* @system @public
|
|
67
|
-
*/
|
|
68
|
-
export type TreeNodeSchemaUnsafe<
|
|
69
|
-
Name extends string = string,
|
|
70
|
-
Kind extends NodeKind = NodeKind,
|
|
71
|
-
TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown,
|
|
72
|
-
TBuild = never,
|
|
73
|
-
ImplicitlyConstructable extends boolean = boolean,
|
|
74
|
-
Info = unknown,
|
|
75
|
-
> =
|
|
76
|
-
| TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
|
|
77
|
-
| TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* {@link Unenforced} version of {@link TreeNodeSchemaClass}.
|
|
81
|
-
* @remarks
|
|
82
|
-
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
83
|
-
* @system @public
|
|
84
|
-
*/
|
|
85
|
-
export interface TreeNodeSchemaClassUnsafe<
|
|
86
|
-
out Name extends string,
|
|
87
|
-
out Kind extends NodeKind,
|
|
88
|
-
// TODO: maybe this can be more specific (exclude leaves)
|
|
89
|
-
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
|
90
|
-
in TInsertable = never,
|
|
91
|
-
out ImplicitlyConstructable extends boolean = boolean,
|
|
92
|
-
out Info = unknown,
|
|
93
|
-
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
|
94
|
-
/**
|
|
95
|
-
* Constructs an {@link Unhydrated} node with this schema.
|
|
96
|
-
* @remarks
|
|
97
|
-
* This constructor is also used internally to construct hydrated nodes with a different parameter type.
|
|
98
|
-
* Therefore, overriding this constructor with different argument types is not type-safe and is not supported.
|
|
99
|
-
* @sealed
|
|
100
|
-
*/
|
|
101
|
-
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* {@link Unenforced} version of {@link TreeNodeSchemaNonClass}.
|
|
106
|
-
* @remarks
|
|
107
|
-
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
108
|
-
* @system @public
|
|
109
|
-
*/
|
|
110
|
-
export interface TreeNodeSchemaNonClassUnsafe<
|
|
111
|
-
out Name extends string,
|
|
112
|
-
out Kind extends NodeKind,
|
|
113
|
-
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
|
114
|
-
in TInsertable = never,
|
|
115
|
-
out ImplicitlyConstructable extends boolean = boolean,
|
|
116
|
-
out Info = unknown,
|
|
117
|
-
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
|
118
|
-
create(data: TInsertable): TNode;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
62
|
/**
|
|
122
63
|
* {@link Unenforced} version of {@link TreeObjectNode}.
|
|
123
64
|
* @remarks
|
|
@@ -142,14 +83,6 @@ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<Implicit
|
|
|
142
83
|
? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>
|
|
143
84
|
: unknown;
|
|
144
85
|
|
|
145
|
-
/**
|
|
146
|
-
* {@link Unenforced} version of {@link AllowedTypes}.
|
|
147
|
-
* @remarks
|
|
148
|
-
* Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
149
|
-
* @system @public
|
|
150
|
-
*/
|
|
151
|
-
export type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
|
152
|
-
|
|
153
86
|
/**
|
|
154
87
|
* {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.
|
|
155
88
|
* @remarks
|
|
@@ -158,11 +91,13 @@ export type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
|
|
158
91
|
*/
|
|
159
92
|
export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
160
93
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
161
|
-
> = TSchema extends
|
|
162
|
-
?
|
|
163
|
-
: TSchema extends
|
|
164
|
-
?
|
|
165
|
-
:
|
|
94
|
+
> = TSchema extends ImplicitAllowedTypes
|
|
95
|
+
? TreeNodeFromImplicitAllowedTypes<TSchema>
|
|
96
|
+
: TSchema extends TreeNodeSchema
|
|
97
|
+
? NodeFromSchema<TSchema>
|
|
98
|
+
: TSchema extends AllowedTypes
|
|
99
|
+
? NodeFromSchema<FlexListToUnion<TSchema>>
|
|
100
|
+
: unknown;
|
|
166
101
|
|
|
167
102
|
/**
|
|
168
103
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
@@ -172,7 +107,7 @@ export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|
|
172
107
|
*/
|
|
173
108
|
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<
|
|
174
109
|
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
|
175
|
-
> = TSchema extends
|
|
110
|
+
> = TSchema extends AllowedTypes
|
|
176
111
|
? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>>
|
|
177
112
|
: InsertableTypedNodeUnsafe<TSchema>;
|
|
178
113
|
|
|
@@ -194,7 +129,7 @@ export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = [
|
|
|
194
129
|
* @system @public
|
|
195
130
|
*/
|
|
196
131
|
export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
197
|
-
T extends
|
|
132
|
+
T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
|
198
133
|
|
|
199
134
|
/**
|
|
200
135
|
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
|
@@ -203,7 +138,7 @@ export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
203
138
|
* @system @public
|
|
204
139
|
*/
|
|
205
140
|
export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
206
|
-
T extends
|
|
141
|
+
T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
|
207
142
|
|
|
208
143
|
/**
|
|
209
144
|
* {@link Unenforced} version of {@link (TreeArrayNode:interface)}.
|
|
@@ -214,7 +149,8 @@ export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
214
149
|
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>>
|
|
215
150
|
extends TreeArrayNodeBase<
|
|
216
151
|
TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
|
217
|
-
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes
|
|
152
|
+
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
|
153
|
+
TreeArrayNode
|
|
218
154
|
> {}
|
|
219
155
|
|
|
220
156
|
/**
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
normalizeAllowedTypes,
|
|
19
19
|
type ImplicitAllowedTypes,
|
|
20
20
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
21
|
-
type TreeLeafValue,
|
|
22
21
|
type TreeNodeFromImplicitAllowedTypes,
|
|
23
22
|
} from "./schemaTypes.js";
|
|
24
23
|
import {
|
|
@@ -35,7 +34,6 @@ import {
|
|
|
35
34
|
type TreeNodeSchemaBoth,
|
|
36
35
|
getSimpleNodeSchemaFromInnerNode,
|
|
37
36
|
getOrCreateInnerNode,
|
|
38
|
-
type TreeNodeSchemaClass,
|
|
39
37
|
} from "./core/index.js";
|
|
40
38
|
import { type InsertableContent, mapTreeFromNodeData } from "./toMapTree.js";
|
|
41
39
|
import { fail } from "../util/index.js";
|
|
@@ -47,19 +45,6 @@ import {
|
|
|
47
45
|
import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
|
|
48
46
|
import { getUnhydratedContext } from "./createContext.js";
|
|
49
47
|
|
|
50
|
-
/**
|
|
51
|
-
* A covariant base type for {@link (TreeArrayNode:interface)}.
|
|
52
|
-
*
|
|
53
|
-
* This provides the readonly subset of TreeArrayNode functionality, and is used as the source interface for moves since that needs to be covariant.
|
|
54
|
-
* @privateRemarks
|
|
55
|
-
* Ideally this would just include `TreeNode, WithType<string, NodeKind.Array>` in the extends list but https://github.com/microsoft/TypeScript/issues/16936 prevents that from compiling.
|
|
56
|
-
* As a workaround around for this TypeScript limitation, the conflicting type intersection is wrapped in `Awaited` (which has no effect on the type in this case) which allows it to compile.
|
|
57
|
-
* @system @sealed @public
|
|
58
|
-
*/
|
|
59
|
-
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue>
|
|
60
|
-
extends ReadonlyArray<T>,
|
|
61
|
-
Awaited<TreeNode & WithType<string, NodeKind.Array>> {}
|
|
62
|
-
|
|
63
48
|
/**
|
|
64
49
|
* A generic array type, used to defined types like {@link (TreeArrayNode:interface)}.
|
|
65
50
|
*
|
|
@@ -68,8 +53,9 @@ export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue>
|
|
|
68
53
|
*
|
|
69
54
|
* @system @sealed @public
|
|
70
55
|
*/
|
|
71
|
-
export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom
|
|
72
|
-
extends
|
|
56
|
+
export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom>
|
|
57
|
+
extends ReadonlyArray<T>,
|
|
58
|
+
TreeNode {
|
|
73
59
|
/**
|
|
74
60
|
* Inserts new item(s) at a specified location.
|
|
75
61
|
* @param index - The index at which to insert `value`.
|
|
@@ -380,7 +366,8 @@ export interface TreeArrayNode<
|
|
|
380
366
|
TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
381
367
|
> extends TreeArrayNodeBase<
|
|
382
368
|
TreeNodeFromImplicitAllowedTypes<TAllowedTypes>,
|
|
383
|
-
InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes
|
|
369
|
+
InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>,
|
|
370
|
+
TreeArrayNode
|
|
384
371
|
> {}
|
|
385
372
|
|
|
386
373
|
/**
|
|
@@ -430,7 +417,9 @@ export class IterableTreeArrayContent<T> implements Iterable<T> {
|
|
|
430
417
|
/**
|
|
431
418
|
* Given a array node proxy, returns its underlying LazySequence field.
|
|
432
419
|
*/
|
|
433
|
-
function getSequenceField
|
|
420
|
+
function getSequenceField<TSimpleType extends ImplicitAllowedTypes>(
|
|
421
|
+
arrayNode: TreeArrayNode<TSimpleType>,
|
|
422
|
+
): FlexTreeSequenceField {
|
|
434
423
|
return getOrCreateInnerNode(arrayNode).getBoxed(EmptyKey) as FlexTreeSequenceField;
|
|
435
424
|
}
|
|
436
425
|
|
|
@@ -810,11 +799,6 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
810
799
|
protected abstract get simpleSchema(): T;
|
|
811
800
|
protected abstract get allowedTypes(): ReadonlySet<TreeNodeSchema>;
|
|
812
801
|
|
|
813
|
-
public abstract override get [typeSchemaSymbol](): TreeNodeSchemaClass<
|
|
814
|
-
string,
|
|
815
|
-
NodeKind.Array
|
|
816
|
-
>;
|
|
817
|
-
|
|
818
802
|
public constructor(
|
|
819
803
|
input: Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>> | InternalTreeNode,
|
|
820
804
|
) {
|
|
@@ -917,13 +901,13 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
917
901
|
}
|
|
918
902
|
field.editor.remove(removeStart, removeEnd - removeStart);
|
|
919
903
|
}
|
|
920
|
-
public moveToStart(sourceIndex: number, source?:
|
|
904
|
+
public moveToStart(sourceIndex: number, source?: TreeArrayNode): void {
|
|
921
905
|
const sourceArray = source ?? this;
|
|
922
906
|
const sourceField = getSequenceField(sourceArray);
|
|
923
907
|
validateIndex(sourceIndex, sourceField, "moveToStart");
|
|
924
908
|
this.moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);
|
|
925
909
|
}
|
|
926
|
-
public moveToEnd(sourceIndex: number, source?:
|
|
910
|
+
public moveToEnd(sourceIndex: number, source?: TreeArrayNode): void {
|
|
927
911
|
const sourceArray = source ?? this;
|
|
928
912
|
const sourceField = getSequenceField(sourceArray);
|
|
929
913
|
validateIndex(sourceIndex, sourceField, "moveToEnd");
|
|
@@ -932,7 +916,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
932
916
|
public moveToIndex(
|
|
933
917
|
destinationGap: number,
|
|
934
918
|
sourceIndex: number,
|
|
935
|
-
source?:
|
|
919
|
+
source?: TreeArrayNode,
|
|
936
920
|
): void {
|
|
937
921
|
const sourceArray = source ?? this;
|
|
938
922
|
const sourceField = getSequenceField(sourceArray);
|
|
@@ -944,7 +928,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
944
928
|
public moveRangeToStart(
|
|
945
929
|
sourceStart: number,
|
|
946
930
|
sourceEnd: number,
|
|
947
|
-
source?:
|
|
931
|
+
source?: TreeArrayNode,
|
|
948
932
|
): void {
|
|
949
933
|
validateIndexRange(
|
|
950
934
|
sourceStart,
|
|
@@ -954,11 +938,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
954
938
|
);
|
|
955
939
|
this.moveRangeToIndex(0, sourceStart, sourceEnd, source);
|
|
956
940
|
}
|
|
957
|
-
public moveRangeToEnd(
|
|
958
|
-
sourceStart: number,
|
|
959
|
-
sourceEnd: number,
|
|
960
|
-
source?: ReadonlyArrayNode,
|
|
961
|
-
): void {
|
|
941
|
+
public moveRangeToEnd(sourceStart: number, sourceEnd: number, source?: TreeArrayNode): void {
|
|
962
942
|
validateIndexRange(
|
|
963
943
|
sourceStart,
|
|
964
944
|
sourceEnd,
|
|
@@ -971,7 +951,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
971
951
|
destinationGap: number,
|
|
972
952
|
sourceStart: number,
|
|
973
953
|
sourceEnd: number,
|
|
974
|
-
source?:
|
|
954
|
+
source?: TreeArrayNode,
|
|
975
955
|
): void {
|
|
976
956
|
const destinationField = getSequenceField(this);
|
|
977
957
|
const destinationSchema = this.allowedTypes;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
|
|
6
|
+
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Schema for a tree node.
|
|
@@ -20,7 +19,7 @@ import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
|
|
|
20
19
|
export type TreeNodeSchema<
|
|
21
20
|
Name extends string = string,
|
|
22
21
|
Kind extends NodeKind = NodeKind,
|
|
23
|
-
TNode
|
|
22
|
+
TNode = unknown,
|
|
24
23
|
TBuild = never,
|
|
25
24
|
ImplicitlyConstructable extends boolean = boolean,
|
|
26
25
|
Info = unknown,
|
|
@@ -39,7 +38,7 @@ export type TreeNodeSchema<
|
|
|
39
38
|
export interface TreeNodeSchemaNonClass<
|
|
40
39
|
out Name extends string = string,
|
|
41
40
|
out Kind extends NodeKind = NodeKind,
|
|
42
|
-
out TNode
|
|
41
|
+
out TNode = unknown,
|
|
43
42
|
in TInsertable = never,
|
|
44
43
|
out ImplicitlyConstructable extends boolean = boolean,
|
|
45
44
|
out Info = unknown,
|
|
@@ -95,8 +94,7 @@ export interface TreeNodeSchemaNonClass<
|
|
|
95
94
|
export interface TreeNodeSchemaClass<
|
|
96
95
|
out Name extends string = string,
|
|
97
96
|
out Kind extends NodeKind = NodeKind,
|
|
98
|
-
|
|
99
|
-
out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,
|
|
97
|
+
out TNode = unknown,
|
|
100
98
|
in TInsertable = never,
|
|
101
99
|
out ImplicitlyConstructable extends boolean = boolean,
|
|
102
100
|
out Info = unknown,
|
|
@@ -117,7 +115,7 @@ export interface TreeNodeSchemaClass<
|
|
|
117
115
|
export type TreeNodeSchemaBoth<
|
|
118
116
|
Name extends string = string,
|
|
119
117
|
Kind extends NodeKind = NodeKind,
|
|
120
|
-
TNode
|
|
118
|
+
TNode = unknown,
|
|
121
119
|
TInsertable = never,
|
|
122
120
|
ImplicitlyConstructable extends boolean = boolean,
|
|
123
121
|
Info = unknown,
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { TreeLeafValue } from "../schemaTypes.js";
|
|
7
6
|
import type { NodeKind, TreeNodeSchemaClass } from "./treeNodeSchema.js";
|
|
8
|
-
import type { TreeNode } from "./types.js";
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* The type of a {@link TreeNode}.
|
|
@@ -89,12 +87,5 @@ export interface WithType<
|
|
|
89
87
|
/**
|
|
90
88
|
* Type symbol, marking a type in a way to increase type safety via strong type checking.
|
|
91
89
|
*/
|
|
92
|
-
get [typeSchemaSymbol](): TreeNodeSchemaClass<
|
|
93
|
-
TName,
|
|
94
|
-
TKind,
|
|
95
|
-
TreeNode | TreeLeafValue,
|
|
96
|
-
never,
|
|
97
|
-
boolean,
|
|
98
|
-
TInfo
|
|
99
|
-
>;
|
|
90
|
+
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
|
100
91
|
}
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -92,11 +92,6 @@ export {
|
|
|
92
92
|
type NodeBuilderDataUnsafe,
|
|
93
93
|
type NodeFromSchemaUnsafe,
|
|
94
94
|
type ReadonlyMapInlined,
|
|
95
|
-
type TreeNodeSchemaClassUnsafe,
|
|
96
|
-
type TreeNodeSchemaUnsafe,
|
|
97
|
-
type AllowedTypesUnsafe,
|
|
98
|
-
type TreeNodeSchemaNonClassUnsafe,
|
|
99
|
-
type TreeViewAlpha,
|
|
100
95
|
} from "./api/index.js";
|
|
101
96
|
export {
|
|
102
97
|
type NodeFromSchema,
|
|
@@ -118,9 +113,6 @@ export {
|
|
|
118
113
|
normalizeFieldSchema,
|
|
119
114
|
type ApplyKind,
|
|
120
115
|
type FieldSchemaMetadata,
|
|
121
|
-
type InsertableField,
|
|
122
|
-
type Insertable,
|
|
123
|
-
type UnsafeUnknownSchema,
|
|
124
116
|
} from "./schemaTypes.js";
|
|
125
117
|
export {
|
|
126
118
|
getTreeNodeForField,
|
|
@@ -130,7 +122,6 @@ export {
|
|
|
130
122
|
TreeArrayNode,
|
|
131
123
|
IterableTreeArrayContent,
|
|
132
124
|
type TreeArrayNodeBase,
|
|
133
|
-
type ReadonlyArrayNode,
|
|
134
125
|
} from "./arrayNode.js";
|
|
135
126
|
export {
|
|
136
127
|
type FieldHasDefault,
|
|
@@ -140,12 +131,7 @@ export {
|
|
|
140
131
|
setField,
|
|
141
132
|
} from "./objectNode.js";
|
|
142
133
|
export type { TreeMapNode, MapNodeInsertableData } from "./mapNode.js";
|
|
143
|
-
export {
|
|
144
|
-
mapTreeFromNodeData,
|
|
145
|
-
type InsertableContent,
|
|
146
|
-
type FactoryContent,
|
|
147
|
-
type FactoryContentObject,
|
|
148
|
-
} from "./toMapTree.js";
|
|
134
|
+
export { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js";
|
|
149
135
|
export { toStoredSchema, getStoredSchema } from "./toFlexSchema.js";
|
|
150
136
|
export {
|
|
151
137
|
numberSchema,
|