fluid-framework 2.0.0-dev-rc.3.0.0.253463 → 2.0.0-dev-rc.3.0.0.254274
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/api-report/fluid-framework.api.md +15 -7
- package/dist/fluid-framework-alpha.d.ts +65 -15
- package/dist/fluid-framework-beta.d.ts +65 -15
- package/dist/fluid-framework-public.d.ts +65 -15
- package/dist/fluid-framework-untrimmed.d.ts +65 -15
- package/lib/fluid-framework-alpha.d.ts +65 -15
- package/lib/fluid-framework-beta.d.ts +65 -15
- package/lib/fluid-framework-public.d.ts +65 -15
- package/lib/fluid-framework-untrimmed.d.ts +65 -15
- package/package.json +8 -8
|
@@ -128,6 +128,7 @@ export type ExtractItemType<Item extends LazyItem> = Item extends () => infer Re
|
|
|
128
128
|
|
|
129
129
|
// @public
|
|
130
130
|
export enum FieldKind {
|
|
131
|
+
Identifier = 2,
|
|
131
132
|
Optional = 0,
|
|
132
133
|
Required = 1
|
|
133
134
|
}
|
|
@@ -269,7 +270,7 @@ export class IterableTreeArrayContent<T> implements Iterable<T> {
|
|
|
269
270
|
|
|
270
271
|
// @public
|
|
271
272
|
export interface ITree extends IChannel {
|
|
272
|
-
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<
|
|
273
|
+
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
// @public @sealed
|
|
@@ -325,11 +326,15 @@ export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
|
|
|
325
326
|
|
|
326
327
|
// @public
|
|
327
328
|
export interface Revertible {
|
|
328
|
-
|
|
329
|
+
[disposeSymbol](): void;
|
|
329
330
|
revert(): void;
|
|
331
|
+
revert(dispose: boolean): void;
|
|
330
332
|
readonly status: RevertibleStatus;
|
|
331
333
|
}
|
|
332
334
|
|
|
335
|
+
// @public
|
|
336
|
+
export type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
|
|
337
|
+
|
|
333
338
|
// @public
|
|
334
339
|
export enum RevertibleStatus {
|
|
335
340
|
Disposed = 1,
|
|
@@ -345,6 +350,7 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
|
|
|
345
350
|
// @deprecated
|
|
346
351
|
fixRecursiveReference<T extends AllowedTypes>(...types: T): void;
|
|
347
352
|
readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject<unknown> & IFluidLoadable>, IFluidHandle<FluidObject<unknown> & IFluidLoadable>>;
|
|
353
|
+
get identifier(): FieldSchema<FieldKind.Identifier>;
|
|
348
354
|
map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchema<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
|
|
349
355
|
map<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
|
|
350
356
|
namedArray_internal<Name extends TName | string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(name: Name, allowedTypes: T, customizable: boolean, implicitlyConstructable: ImplicitlyConstructable): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Array, TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T>;
|
|
@@ -381,8 +387,9 @@ export const Tree: TreeApi;
|
|
|
381
387
|
|
|
382
388
|
// @public
|
|
383
389
|
export interface TreeApi extends TreeNodeApi {
|
|
390
|
+
contains(node: TreeNode, other: TreeNode): boolean;
|
|
384
391
|
runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback"): void;
|
|
385
|
-
runTransaction<
|
|
392
|
+
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
|
|
386
393
|
}
|
|
387
394
|
|
|
388
395
|
// @public
|
|
@@ -454,6 +461,7 @@ export interface TreeNodeApi {
|
|
|
454
461
|
on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
|
|
455
462
|
parent(node: TreeNode): TreeNode | undefined;
|
|
456
463
|
schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
|
|
464
|
+
shortId(node: TreeNode): number | undefined;
|
|
457
465
|
readonly status: (node: TreeNode) => TreeStatus;
|
|
458
466
|
}
|
|
459
467
|
|
|
@@ -496,18 +504,18 @@ export enum TreeStatus {
|
|
|
496
504
|
}
|
|
497
505
|
|
|
498
506
|
// @public
|
|
499
|
-
export interface TreeView<
|
|
507
|
+
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
500
508
|
readonly error?: SchemaIncompatible;
|
|
501
509
|
readonly events: ISubscribable<TreeViewEvents>;
|
|
502
|
-
|
|
510
|
+
get root(): TreeFieldFromImplicitField<TSchema>;
|
|
511
|
+
set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
|
|
503
512
|
upgradeSchema(): void;
|
|
504
513
|
}
|
|
505
514
|
|
|
506
515
|
// @public
|
|
507
516
|
export interface TreeViewEvents {
|
|
508
517
|
afterBatch(): void;
|
|
509
|
-
commitApplied(data: CommitMetadata, getRevertible?:
|
|
510
|
-
revertibleDisposed(revertible: Revertible): void;
|
|
518
|
+
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
511
519
|
rootChanged(): void;
|
|
512
520
|
}
|
|
513
521
|
|
|
@@ -221,6 +221,9 @@ export declare interface ContainerSchema {
|
|
|
221
221
|
* constructor that will return the type of the `DataObject`.
|
|
222
222
|
*
|
|
223
223
|
* @typeParam T - The class of the `DataObject`.
|
|
224
|
+
* @privateRemarks
|
|
225
|
+
* Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.
|
|
226
|
+
* This may need some refinement.
|
|
224
227
|
* @public
|
|
225
228
|
*/
|
|
226
229
|
export declare type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
|
|
@@ -366,7 +369,13 @@ export declare enum FieldKind {
|
|
|
366
369
|
* @remarks
|
|
367
370
|
* Only allows exactly one child.
|
|
368
371
|
*/
|
|
369
|
-
Required = 1
|
|
372
|
+
Required = 1,
|
|
373
|
+
/**
|
|
374
|
+
* A special field used for node identifiers.
|
|
375
|
+
* @remarks
|
|
376
|
+
* Only allows exactly one child.
|
|
377
|
+
*/
|
|
378
|
+
Identifier = 2
|
|
370
379
|
}
|
|
371
380
|
|
|
372
381
|
/**
|
|
@@ -1008,7 +1017,7 @@ export declare interface ITree extends IChannel {
|
|
|
1008
1017
|
* Additionally, once out of schema content adapters are properly supported (with lazy document updates),
|
|
1009
1018
|
* this initialization could become just another out of schema content adapter and this initialization is no longer a special case.
|
|
1010
1019
|
*/
|
|
1011
|
-
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<
|
|
1020
|
+
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
|
|
1012
1021
|
}
|
|
1013
1022
|
|
|
1014
1023
|
/**
|
|
@@ -1228,15 +1237,36 @@ export declare interface Revertible {
|
|
|
1228
1237
|
*/
|
|
1229
1238
|
readonly status: RevertibleStatus;
|
|
1230
1239
|
/**
|
|
1231
|
-
* Reverts the associated change.
|
|
1240
|
+
* Reverts the associated change and disposes it.
|
|
1232
1241
|
*/
|
|
1233
1242
|
revert(): void;
|
|
1234
1243
|
/**
|
|
1235
|
-
*
|
|
1244
|
+
* Reverts the associated change and optionally disposes it.
|
|
1245
|
+
*
|
|
1246
|
+
* @param dispose - If true, the revertible will be disposed after being reverted.
|
|
1247
|
+
* If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
|
|
1248
|
+
* due to merge conflicts, and one wants to attempt reverting again.
|
|
1249
|
+
*/
|
|
1250
|
+
revert(dispose: boolean): void;
|
|
1251
|
+
/**
|
|
1252
|
+
* Disposes this revertible, allowing associated resources to be released.
|
|
1236
1253
|
*/
|
|
1237
|
-
|
|
1254
|
+
[disposeSymbol](): void;
|
|
1238
1255
|
}
|
|
1239
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* Factory for creating a {@link Revertible}.
|
|
1259
|
+
* Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.
|
|
1260
|
+
*
|
|
1261
|
+
* @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.
|
|
1262
|
+
* This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,
|
|
1263
|
+
* whichever happens first.
|
|
1264
|
+
* This is typically used to clean up any resources associated with the `Revertible` in the host application.
|
|
1265
|
+
*
|
|
1266
|
+
* @public
|
|
1267
|
+
*/
|
|
1268
|
+
export declare type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
|
|
1269
|
+
|
|
1240
1270
|
/**
|
|
1241
1271
|
* The status of a {@link Revertible}.
|
|
1242
1272
|
*
|
|
@@ -1496,6 +1526,10 @@ export declare class SchemaFactory<out TScope extends string | undefined = strin
|
|
|
1496
1526
|
* and allows associating custom {@link FieldProps | properties} with the field.
|
|
1497
1527
|
*/
|
|
1498
1528
|
required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
|
|
1529
|
+
/**
|
|
1530
|
+
* Make a field of type identifier instead of the default which is required.
|
|
1531
|
+
*/
|
|
1532
|
+
get identifier(): FieldSchema<FieldKind.Identifier>;
|
|
1499
1533
|
/**
|
|
1500
1534
|
* Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.
|
|
1501
1535
|
* @remarks
|
|
@@ -1620,7 +1654,23 @@ export declare interface TreeApi extends TreeNodeApi {
|
|
|
1620
1654
|
* Local change events will be emitted for each change as the transaction is being applied.
|
|
1621
1655
|
* If the transaction is cancelled and rolled back, a corresponding change event will also be emitted for the rollback.
|
|
1622
1656
|
*/
|
|
1623
|
-
runTransaction<
|
|
1657
|
+
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
|
|
1658
|
+
/**
|
|
1659
|
+
* Check if the subtree defined by `node` contains `other`.
|
|
1660
|
+
*
|
|
1661
|
+
* @returns true if `other` is an inclusive descendant of `node`, and false otherwise.
|
|
1662
|
+
* @remarks
|
|
1663
|
+
* This includes direct and indirect children:
|
|
1664
|
+
* as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
|
|
1665
|
+
*
|
|
1666
|
+
* `node` is considered to contain itself, so the case where `node === other` returns true.
|
|
1667
|
+
*
|
|
1668
|
+
* This is handy when checking if moving `node` into `other` would create a cycle and thus is invalid.
|
|
1669
|
+
*
|
|
1670
|
+
* This check walks the parents of `other` looking for `node`,
|
|
1671
|
+
* and thus runs in time proportional to the depth of child in the tree.
|
|
1672
|
+
*/
|
|
1673
|
+
contains(node: TreeNode, other: TreeNode): boolean;
|
|
1624
1674
|
}
|
|
1625
1675
|
|
|
1626
1676
|
/**
|
|
@@ -2031,6 +2081,11 @@ export declare interface TreeNodeApi {
|
|
|
2031
2081
|
* Returns the {@link TreeStatus} of the given node.
|
|
2032
2082
|
*/
|
|
2033
2083
|
readonly status: (node: TreeNode) => TreeStatus;
|
|
2084
|
+
/**
|
|
2085
|
+
* If the given node has an identifier specified by a field of kind "identifier" then this returns the compressed form of that identifier.
|
|
2086
|
+
* Otherwise returns undefined.
|
|
2087
|
+
*/
|
|
2088
|
+
shortId(node: TreeNode): number | undefined;
|
|
2034
2089
|
}
|
|
2035
2090
|
|
|
2036
2091
|
/**
|
|
@@ -2161,7 +2216,7 @@ export declare enum TreeStatus {
|
|
|
2161
2216
|
* it could be mitigated by adding a `rootOrError` member and deprecating `root` to give users a warning if they might be missing the error checking.
|
|
2162
2217
|
* @public
|
|
2163
2218
|
*/
|
|
2164
|
-
export declare interface TreeView<
|
|
2219
|
+
export declare interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
2165
2220
|
/**
|
|
2166
2221
|
* The current root of the tree.
|
|
2167
2222
|
*
|
|
@@ -2171,7 +2226,8 @@ export declare interface TreeView<in out TRoot> extends IDisposable {
|
|
|
2171
2226
|
* To get notified about changes to this field (including to it being in an `error` state),
|
|
2172
2227
|
* use {@link TreeViewEvents.rootChanged} via `view.events.on("rootChanged", callback)`.
|
|
2173
2228
|
*/
|
|
2174
|
-
|
|
2229
|
+
get root(): TreeFieldFromImplicitField<TSchema>;
|
|
2230
|
+
set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
|
|
2175
2231
|
/**
|
|
2176
2232
|
* Description of the error state, if any.
|
|
2177
2233
|
* When this is undefined, the view schema and stored schema are compatible, and `root` can be used.
|
|
@@ -2214,12 +2270,6 @@ export declare interface TreeViewEvents {
|
|
|
2214
2270
|
* This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.
|
|
2215
2271
|
*/
|
|
2216
2272
|
rootChanged(): void;
|
|
2217
|
-
/**
|
|
2218
|
-
* Fired when a revertible made on this view is disposed.
|
|
2219
|
-
*
|
|
2220
|
-
* @param revertible - The revertible that was disposed.
|
|
2221
|
-
*/
|
|
2222
|
-
revertibleDisposed(revertible: Revertible): void;
|
|
2223
2273
|
/**
|
|
2224
2274
|
* Fired when:
|
|
2225
2275
|
* - a local commit is applied outside of a transaction
|
|
@@ -2233,7 +2283,7 @@ export declare interface TreeViewEvents {
|
|
|
2233
2283
|
* @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,
|
|
2234
2284
|
* this commit is not revertible.
|
|
2235
2285
|
*/
|
|
2236
|
-
commitApplied(data: CommitMetadata, getRevertible?:
|
|
2286
|
+
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
2237
2287
|
}
|
|
2238
2288
|
|
|
2239
2289
|
/**
|
|
@@ -200,6 +200,9 @@ export declare interface ContainerSchema {
|
|
|
200
200
|
* constructor that will return the type of the `DataObject`.
|
|
201
201
|
*
|
|
202
202
|
* @typeParam T - The class of the `DataObject`.
|
|
203
|
+
* @privateRemarks
|
|
204
|
+
* Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.
|
|
205
|
+
* This may need some refinement.
|
|
203
206
|
* @public
|
|
204
207
|
*/
|
|
205
208
|
export declare type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
|
|
@@ -345,7 +348,13 @@ export declare enum FieldKind {
|
|
|
345
348
|
* @remarks
|
|
346
349
|
* Only allows exactly one child.
|
|
347
350
|
*/
|
|
348
|
-
Required = 1
|
|
351
|
+
Required = 1,
|
|
352
|
+
/**
|
|
353
|
+
* A special field used for node identifiers.
|
|
354
|
+
* @remarks
|
|
355
|
+
* Only allows exactly one child.
|
|
356
|
+
*/
|
|
357
|
+
Identifier = 2
|
|
349
358
|
}
|
|
350
359
|
|
|
351
360
|
/**
|
|
@@ -987,7 +996,7 @@ export declare interface ITree extends IChannel {
|
|
|
987
996
|
* Additionally, once out of schema content adapters are properly supported (with lazy document updates),
|
|
988
997
|
* this initialization could become just another out of schema content adapter and this initialization is no longer a special case.
|
|
989
998
|
*/
|
|
990
|
-
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<
|
|
999
|
+
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
|
|
991
1000
|
}
|
|
992
1001
|
|
|
993
1002
|
/**
|
|
@@ -1207,15 +1216,36 @@ export declare interface Revertible {
|
|
|
1207
1216
|
*/
|
|
1208
1217
|
readonly status: RevertibleStatus;
|
|
1209
1218
|
/**
|
|
1210
|
-
* Reverts the associated change.
|
|
1219
|
+
* Reverts the associated change and disposes it.
|
|
1211
1220
|
*/
|
|
1212
1221
|
revert(): void;
|
|
1213
1222
|
/**
|
|
1214
|
-
*
|
|
1223
|
+
* Reverts the associated change and optionally disposes it.
|
|
1224
|
+
*
|
|
1225
|
+
* @param dispose - If true, the revertible will be disposed after being reverted.
|
|
1226
|
+
* If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
|
|
1227
|
+
* due to merge conflicts, and one wants to attempt reverting again.
|
|
1228
|
+
*/
|
|
1229
|
+
revert(dispose: boolean): void;
|
|
1230
|
+
/**
|
|
1231
|
+
* Disposes this revertible, allowing associated resources to be released.
|
|
1215
1232
|
*/
|
|
1216
|
-
|
|
1233
|
+
[disposeSymbol](): void;
|
|
1217
1234
|
}
|
|
1218
1235
|
|
|
1236
|
+
/**
|
|
1237
|
+
* Factory for creating a {@link Revertible}.
|
|
1238
|
+
* Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.
|
|
1239
|
+
*
|
|
1240
|
+
* @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.
|
|
1241
|
+
* This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,
|
|
1242
|
+
* whichever happens first.
|
|
1243
|
+
* This is typically used to clean up any resources associated with the `Revertible` in the host application.
|
|
1244
|
+
*
|
|
1245
|
+
* @public
|
|
1246
|
+
*/
|
|
1247
|
+
export declare type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
|
|
1248
|
+
|
|
1219
1249
|
/**
|
|
1220
1250
|
* The status of a {@link Revertible}.
|
|
1221
1251
|
*
|
|
@@ -1475,6 +1505,10 @@ export declare class SchemaFactory<out TScope extends string | undefined = strin
|
|
|
1475
1505
|
* and allows associating custom {@link FieldProps | properties} with the field.
|
|
1476
1506
|
*/
|
|
1477
1507
|
required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
|
|
1508
|
+
/**
|
|
1509
|
+
* Make a field of type identifier instead of the default which is required.
|
|
1510
|
+
*/
|
|
1511
|
+
get identifier(): FieldSchema<FieldKind.Identifier>;
|
|
1478
1512
|
/**
|
|
1479
1513
|
* Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.
|
|
1480
1514
|
* @remarks
|
|
@@ -1599,7 +1633,23 @@ export declare interface TreeApi extends TreeNodeApi {
|
|
|
1599
1633
|
* Local change events will be emitted for each change as the transaction is being applied.
|
|
1600
1634
|
* If the transaction is cancelled and rolled back, a corresponding change event will also be emitted for the rollback.
|
|
1601
1635
|
*/
|
|
1602
|
-
runTransaction<
|
|
1636
|
+
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
|
|
1637
|
+
/**
|
|
1638
|
+
* Check if the subtree defined by `node` contains `other`.
|
|
1639
|
+
*
|
|
1640
|
+
* @returns true if `other` is an inclusive descendant of `node`, and false otherwise.
|
|
1641
|
+
* @remarks
|
|
1642
|
+
* This includes direct and indirect children:
|
|
1643
|
+
* as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
|
|
1644
|
+
*
|
|
1645
|
+
* `node` is considered to contain itself, so the case where `node === other` returns true.
|
|
1646
|
+
*
|
|
1647
|
+
* This is handy when checking if moving `node` into `other` would create a cycle and thus is invalid.
|
|
1648
|
+
*
|
|
1649
|
+
* This check walks the parents of `other` looking for `node`,
|
|
1650
|
+
* and thus runs in time proportional to the depth of child in the tree.
|
|
1651
|
+
*/
|
|
1652
|
+
contains(node: TreeNode, other: TreeNode): boolean;
|
|
1603
1653
|
}
|
|
1604
1654
|
|
|
1605
1655
|
/**
|
|
@@ -2010,6 +2060,11 @@ export declare interface TreeNodeApi {
|
|
|
2010
2060
|
* Returns the {@link TreeStatus} of the given node.
|
|
2011
2061
|
*/
|
|
2012
2062
|
readonly status: (node: TreeNode) => TreeStatus;
|
|
2063
|
+
/**
|
|
2064
|
+
* If the given node has an identifier specified by a field of kind "identifier" then this returns the compressed form of that identifier.
|
|
2065
|
+
* Otherwise returns undefined.
|
|
2066
|
+
*/
|
|
2067
|
+
shortId(node: TreeNode): number | undefined;
|
|
2013
2068
|
}
|
|
2014
2069
|
|
|
2015
2070
|
/**
|
|
@@ -2140,7 +2195,7 @@ export declare enum TreeStatus {
|
|
|
2140
2195
|
* it could be mitigated by adding a `rootOrError` member and deprecating `root` to give users a warning if they might be missing the error checking.
|
|
2141
2196
|
* @public
|
|
2142
2197
|
*/
|
|
2143
|
-
export declare interface TreeView<
|
|
2198
|
+
export declare interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
2144
2199
|
/**
|
|
2145
2200
|
* The current root of the tree.
|
|
2146
2201
|
*
|
|
@@ -2150,7 +2205,8 @@ export declare interface TreeView<in out TRoot> extends IDisposable {
|
|
|
2150
2205
|
* To get notified about changes to this field (including to it being in an `error` state),
|
|
2151
2206
|
* use {@link TreeViewEvents.rootChanged} via `view.events.on("rootChanged", callback)`.
|
|
2152
2207
|
*/
|
|
2153
|
-
|
|
2208
|
+
get root(): TreeFieldFromImplicitField<TSchema>;
|
|
2209
|
+
set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
|
|
2154
2210
|
/**
|
|
2155
2211
|
* Description of the error state, if any.
|
|
2156
2212
|
* When this is undefined, the view schema and stored schema are compatible, and `root` can be used.
|
|
@@ -2193,12 +2249,6 @@ export declare interface TreeViewEvents {
|
|
|
2193
2249
|
* This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.
|
|
2194
2250
|
*/
|
|
2195
2251
|
rootChanged(): void;
|
|
2196
|
-
/**
|
|
2197
|
-
* Fired when a revertible made on this view is disposed.
|
|
2198
|
-
*
|
|
2199
|
-
* @param revertible - The revertible that was disposed.
|
|
2200
|
-
*/
|
|
2201
|
-
revertibleDisposed(revertible: Revertible): void;
|
|
2202
2252
|
/**
|
|
2203
2253
|
* Fired when:
|
|
2204
2254
|
* - a local commit is applied outside of a transaction
|
|
@@ -2212,7 +2262,7 @@ export declare interface TreeViewEvents {
|
|
|
2212
2262
|
* @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,
|
|
2213
2263
|
* this commit is not revertible.
|
|
2214
2264
|
*/
|
|
2215
|
-
commitApplied(data: CommitMetadata, getRevertible?:
|
|
2265
|
+
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
2216
2266
|
}
|
|
2217
2267
|
|
|
2218
2268
|
/**
|
|
@@ -200,6 +200,9 @@ export declare interface ContainerSchema {
|
|
|
200
200
|
* constructor that will return the type of the `DataObject`.
|
|
201
201
|
*
|
|
202
202
|
* @typeParam T - The class of the `DataObject`.
|
|
203
|
+
* @privateRemarks
|
|
204
|
+
* Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.
|
|
205
|
+
* This may need some refinement.
|
|
203
206
|
* @public
|
|
204
207
|
*/
|
|
205
208
|
export declare type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
|
|
@@ -345,7 +348,13 @@ export declare enum FieldKind {
|
|
|
345
348
|
* @remarks
|
|
346
349
|
* Only allows exactly one child.
|
|
347
350
|
*/
|
|
348
|
-
Required = 1
|
|
351
|
+
Required = 1,
|
|
352
|
+
/**
|
|
353
|
+
* A special field used for node identifiers.
|
|
354
|
+
* @remarks
|
|
355
|
+
* Only allows exactly one child.
|
|
356
|
+
*/
|
|
357
|
+
Identifier = 2
|
|
349
358
|
}
|
|
350
359
|
|
|
351
360
|
/**
|
|
@@ -987,7 +996,7 @@ export declare interface ITree extends IChannel {
|
|
|
987
996
|
* Additionally, once out of schema content adapters are properly supported (with lazy document updates),
|
|
988
997
|
* this initialization could become just another out of schema content adapter and this initialization is no longer a special case.
|
|
989
998
|
*/
|
|
990
|
-
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<
|
|
999
|
+
schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
|
|
991
1000
|
}
|
|
992
1001
|
|
|
993
1002
|
/**
|
|
@@ -1207,15 +1216,36 @@ export declare interface Revertible {
|
|
|
1207
1216
|
*/
|
|
1208
1217
|
readonly status: RevertibleStatus;
|
|
1209
1218
|
/**
|
|
1210
|
-
* Reverts the associated change.
|
|
1219
|
+
* Reverts the associated change and disposes it.
|
|
1211
1220
|
*/
|
|
1212
1221
|
revert(): void;
|
|
1213
1222
|
/**
|
|
1214
|
-
*
|
|
1223
|
+
* Reverts the associated change and optionally disposes it.
|
|
1224
|
+
*
|
|
1225
|
+
* @param dispose - If true, the revertible will be disposed after being reverted.
|
|
1226
|
+
* If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
|
|
1227
|
+
* due to merge conflicts, and one wants to attempt reverting again.
|
|
1228
|
+
*/
|
|
1229
|
+
revert(dispose: boolean): void;
|
|
1230
|
+
/**
|
|
1231
|
+
* Disposes this revertible, allowing associated resources to be released.
|
|
1215
1232
|
*/
|
|
1216
|
-
|
|
1233
|
+
[disposeSymbol](): void;
|
|
1217
1234
|
}
|
|
1218
1235
|
|
|
1236
|
+
/**
|
|
1237
|
+
* Factory for creating a {@link Revertible}.
|
|
1238
|
+
* Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.
|
|
1239
|
+
*
|
|
1240
|
+
* @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.
|
|
1241
|
+
* This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,
|
|
1242
|
+
* whichever happens first.
|
|
1243
|
+
* This is typically used to clean up any resources associated with the `Revertible` in the host application.
|
|
1244
|
+
*
|
|
1245
|
+
* @public
|
|
1246
|
+
*/
|
|
1247
|
+
export declare type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
|
|
1248
|
+
|
|
1219
1249
|
/**
|
|
1220
1250
|
* The status of a {@link Revertible}.
|
|
1221
1251
|
*
|
|
@@ -1475,6 +1505,10 @@ export declare class SchemaFactory<out TScope extends string | undefined = strin
|
|
|
1475
1505
|
* and allows associating custom {@link FieldProps | properties} with the field.
|
|
1476
1506
|
*/
|
|
1477
1507
|
required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
|
|
1508
|
+
/**
|
|
1509
|
+
* Make a field of type identifier instead of the default which is required.
|
|
1510
|
+
*/
|
|
1511
|
+
get identifier(): FieldSchema<FieldKind.Identifier>;
|
|
1478
1512
|
/**
|
|
1479
1513
|
* Function which can be used for its compile time side-effects to tweak the evaluation order of recursive types to make them compile.
|
|
1480
1514
|
* @remarks
|
|
@@ -1599,7 +1633,23 @@ export declare interface TreeApi extends TreeNodeApi {
|
|
|
1599
1633
|
* Local change events will be emitted for each change as the transaction is being applied.
|
|
1600
1634
|
* If the transaction is cancelled and rolled back, a corresponding change event will also be emitted for the rollback.
|
|
1601
1635
|
*/
|
|
1602
|
-
runTransaction<
|
|
1636
|
+
runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
|
|
1637
|
+
/**
|
|
1638
|
+
* Check if the subtree defined by `node` contains `other`.
|
|
1639
|
+
*
|
|
1640
|
+
* @returns true if `other` is an inclusive descendant of `node`, and false otherwise.
|
|
1641
|
+
* @remarks
|
|
1642
|
+
* This includes direct and indirect children:
|
|
1643
|
+
* as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
|
|
1644
|
+
*
|
|
1645
|
+
* `node` is considered to contain itself, so the case where `node === other` returns true.
|
|
1646
|
+
*
|
|
1647
|
+
* This is handy when checking if moving `node` into `other` would create a cycle and thus is invalid.
|
|
1648
|
+
*
|
|
1649
|
+
* This check walks the parents of `other` looking for `node`,
|
|
1650
|
+
* and thus runs in time proportional to the depth of child in the tree.
|
|
1651
|
+
*/
|
|
1652
|
+
contains(node: TreeNode, other: TreeNode): boolean;
|
|
1603
1653
|
}
|
|
1604
1654
|
|
|
1605
1655
|
/**
|
|
@@ -2010,6 +2060,11 @@ export declare interface TreeNodeApi {
|
|
|
2010
2060
|
* Returns the {@link TreeStatus} of the given node.
|
|
2011
2061
|
*/
|
|
2012
2062
|
readonly status: (node: TreeNode) => TreeStatus;
|
|
2063
|
+
/**
|
|
2064
|
+
* If the given node has an identifier specified by a field of kind "identifier" then this returns the compressed form of that identifier.
|
|
2065
|
+
* Otherwise returns undefined.
|
|
2066
|
+
*/
|
|
2067
|
+
shortId(node: TreeNode): number | undefined;
|
|
2013
2068
|
}
|
|
2014
2069
|
|
|
2015
2070
|
/**
|
|
@@ -2140,7 +2195,7 @@ export declare enum TreeStatus {
|
|
|
2140
2195
|
* it could be mitigated by adding a `rootOrError` member and deprecating `root` to give users a warning if they might be missing the error checking.
|
|
2141
2196
|
* @public
|
|
2142
2197
|
*/
|
|
2143
|
-
export declare interface TreeView<
|
|
2198
|
+
export declare interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
|
2144
2199
|
/**
|
|
2145
2200
|
* The current root of the tree.
|
|
2146
2201
|
*
|
|
@@ -2150,7 +2205,8 @@ export declare interface TreeView<in out TRoot> extends IDisposable {
|
|
|
2150
2205
|
* To get notified about changes to this field (including to it being in an `error` state),
|
|
2151
2206
|
* use {@link TreeViewEvents.rootChanged} via `view.events.on("rootChanged", callback)`.
|
|
2152
2207
|
*/
|
|
2153
|
-
|
|
2208
|
+
get root(): TreeFieldFromImplicitField<TSchema>;
|
|
2209
|
+
set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
|
|
2154
2210
|
/**
|
|
2155
2211
|
* Description of the error state, if any.
|
|
2156
2212
|
* When this is undefined, the view schema and stored schema are compatible, and `root` can be used.
|
|
@@ -2193,12 +2249,6 @@ export declare interface TreeViewEvents {
|
|
|
2193
2249
|
* This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.
|
|
2194
2250
|
*/
|
|
2195
2251
|
rootChanged(): void;
|
|
2196
|
-
/**
|
|
2197
|
-
* Fired when a revertible made on this view is disposed.
|
|
2198
|
-
*
|
|
2199
|
-
* @param revertible - The revertible that was disposed.
|
|
2200
|
-
*/
|
|
2201
|
-
revertibleDisposed(revertible: Revertible): void;
|
|
2202
2252
|
/**
|
|
2203
2253
|
* Fired when:
|
|
2204
2254
|
* - a local commit is applied outside of a transaction
|
|
@@ -2212,7 +2262,7 @@ export declare interface TreeViewEvents {
|
|
|
2212
2262
|
* @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,
|
|
2213
2263
|
* this commit is not revertible.
|
|
2214
2264
|
*/
|
|
2215
|
-
commitApplied(data: CommitMetadata, getRevertible?:
|
|
2265
|
+
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
2216
2266
|
}
|
|
2217
2267
|
|
|
2218
2268
|
/**
|