Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/dds/tree/api-report/tree.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export const ArrayNodeSchema: {
// @alpha
export function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;

// @beta
export function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;

// @alpha @deprecated
export function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;

Expand Down Expand Up @@ -1344,7 +1347,7 @@ export const Tree: Tree;

// @alpha @sealed @system
export interface TreeAlpha {
branch(node: TreeNode): TreeBranch | undefined;
branch(node: TreeNode): TreeBranchAlpha | undefined;
child(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;
children(node: TreeNode): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;
create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
Expand Down Expand Up @@ -1408,14 +1411,20 @@ export interface TreeBeta {
// @beta
export const TreeBeta: TreeBeta;

// @alpha @sealed
export interface TreeBranch extends IDisposable {
// @beta @sealed
export interface TreeBranch {
dispose(error?: Error): void;
readonly events: Listenable_2<TreeBranchEvents>;
fork(): TreeBranch;
hasRootSchema<TSchema extends ImplicitFieldSchema>(schema: TSchema): this is TreeViewAlpha<TSchema>;
merge(branch: TreeBranch, disposeMerged?: boolean): void;
rebaseOnto(branch: TreeBranch): void;
}

// @alpha @sealed
export interface TreeBranchAlpha extends IDisposable, TreeBranch {
readonly events: Listenable_2<TreeBranchEvents>;
// (undocumented)
fork(): TreeBranchAlpha;
hasRootSchema<TSchema extends ImplicitFieldSchema>(schema: TSchema): this is TreeViewAlpha<TSchema>;
runTransaction<TSuccessValue, TFailureValue>(transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>, params?: RunTransactionParams): TransactionResultExt<TSuccessValue, TFailureValue>;
runTransaction(transaction: () => VoidTransactionCallbackStatus | void, params?: RunTransactionParams): TransactionResult;
}
Expand Down Expand Up @@ -1595,7 +1604,7 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
}

// @alpha @sealed
export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeView<ReadSchema<TSchema>>, "root" | "initialize">, TreeBranch {
export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeViewBeta<ReadSchema<TSchema>>, "root" | "initialize" | "fork">, TreeBranchAlpha {
// (undocumented)
readonly events: Listenable_2<TreeViewEvents & TreeBranchEvents>;
// (undocumented)
Expand All @@ -1607,6 +1616,12 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
set root(newRoot: InsertableField<TSchema>);
}

// @beta @sealed
export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
// (undocumented)
fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
}

// @public @sealed
export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
constructor(props: ITreeViewConfiguration<TSchema>);
Expand Down
17 changes: 17 additions & 0 deletions packages/dds/tree/api-report/tree.beta.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boole
Kind
] extends [FieldKind.Required] ? T : [Kind] extends [FieldKind.Optional] ? T | undefined : [Kind] extends [FieldKind.Identifier] ? DefaultsAreOptional extends true ? T | undefined : T : never;

// @beta
export function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;

// @public
export enum CommitKind {
Default = 0,
Expand Down Expand Up @@ -626,6 +629,14 @@ export interface TreeBeta {
// @beta
export const TreeBeta: TreeBeta;

// @beta @sealed
export interface TreeBranch {
dispose(error?: Error): void;
fork(): TreeBranch;
merge(branch: TreeBranch, disposeMerged?: boolean): void;
rebaseOnto(branch: TreeBranch): void;
}

// @public @sealed
export interface TreeChangeEvents {
nodeChanged(unstable?: unknown): void;
Expand Down Expand Up @@ -749,6 +760,12 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
upgradeSchema(): void;
}

// @beta @sealed
export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
// (undocumented)
fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
}

// @public @sealed
export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
constructor(props: ITreeViewConfiguration<TSchema>);
Expand Down
17 changes: 17 additions & 0 deletions packages/dds/tree/api-report/tree.legacy.beta.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boole
Kind
] extends [FieldKind.Required] ? T : [Kind] extends [FieldKind.Optional] ? T | undefined : [Kind] extends [FieldKind.Identifier] ? DefaultsAreOptional extends true ? T | undefined : T : never;

// @beta
export function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;

// @public
export enum CommitKind {
Default = 0,
Expand Down Expand Up @@ -638,6 +641,14 @@ export interface TreeBeta {
// @beta
export const TreeBeta: TreeBeta;

// @beta @sealed
export interface TreeBranch {
dispose(error?: Error): void;
fork(): TreeBranch;
merge(branch: TreeBranch, disposeMerged?: boolean): void;
rebaseOnto(branch: TreeBranch): void;
}

// @public @sealed
export interface TreeChangeEvents {
nodeChanged(unstable?: unknown): void;
Expand Down Expand Up @@ -761,6 +772,12 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
upgradeSchema(): void;
}

// @beta @sealed
export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch {
// (undocumented)
fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
}

// @public @sealed
export class TreeViewConfiguration<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
constructor(props: ITreeViewConfiguration<TSchema>);
Expand Down
11 changes: 11 additions & 0 deletions packages/dds/tree/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {
type TreeView,
type TreeViewAlpha,
type TreeViewBeta,
type ImplicitFieldSchema,
// eslint-disable-next-line import/no-deprecated
asTreeViewAlpha,
Expand All @@ -28,3 +29,13 @@ export function asAlpha<TSchema extends ImplicitFieldSchema>(
// eslint-disable-next-line import/no-deprecated
return asTreeViewAlpha(view);
}

/**
* Retrieve the {@link TreeViewBeta | beta API} for a {@link TreeView}.
* @beta
*/
export function asBeta<TSchema extends ImplicitFieldSchema>(
view: TreeView<TSchema>,
): TreeViewBeta<TSchema> {
return view as TreeViewBeta<TSchema>;
}
4 changes: 3 additions & 1 deletion packages/dds/tree/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export {
singletonSchema,
type UnsafeUnknownSchema,
type TreeViewAlpha,
type TreeViewBeta,
type InsertableField,
type Insertable,
type InsertableContent,
Expand Down Expand Up @@ -234,6 +235,7 @@ export {
type InsertableTreeNodeFromAllowedTypes,
type Input,
type TreeBranch,
type TreeBranchAlpha,
type TreeBranchEvents,
asTreeViewAlpha,
type NodeSchemaOptions,
Expand Down Expand Up @@ -337,4 +339,4 @@ export type { MapNodeInsertableData } from "./simple-tree/index.js";
export { JsonAsTree } from "./jsonDomainSchema.js";
export { FluidSerializableAsTree } from "./serializableDomainSchema.js";
export { TableSchema, type System_TableSchema } from "./tableSchema.js";
export { asAlpha } from "./api.js";
export { asAlpha, asBeta } from "./api.js";
8 changes: 5 additions & 3 deletions packages/dds/tree/src/shared-tree/schematizingTreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import {

import { canInitialize, initialize, initializerFromChunk } from "./schematizeTree.js";
import type { ITreeCheckout, TreeCheckout } from "./treeCheckout.js";
import type { TreeBranchAlpha } from "../simple-tree/index.js";

/**
* Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already
Expand Down Expand Up @@ -510,15 +511,16 @@ export class SchematizingSimpleTreeView<

// #region Branching

public fork(): ReturnType<TreeBranch["fork"]> & SchematizingSimpleTreeView<TRootSchema> {
public fork(): ReturnType<TreeBranchAlpha["fork"]> &
SchematizingSimpleTreeView<TRootSchema> {
return this.checkout.branch().viewWith(this.config);
}

public merge(context: TreeBranch, disposeMerged = true): void {
public merge(context: TreeBranchAlpha, disposeMerged = true): void {
this.checkout.merge(getCheckout(context), disposeMerged);
}

public rebaseOnto(context: TreeBranch): void {
public rebaseOnto(context: TreeBranchAlpha): void {
getCheckout(context).rebase(this.checkout);
}

Expand Down
5 changes: 3 additions & 2 deletions packages/dds/tree/src/shared-tree/treeAlpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import {
} from "../feature-libraries/index.js";
import { independentInitializedView, type ViewContent } from "./independentView.js";
import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
import type { TreeBranchAlpha } from "../simple-tree/index.js";

const identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {
const nodeIdentifier = getIdentifierFromNode(node, "uncompressed");
Expand Down Expand Up @@ -227,7 +228,7 @@ export interface TreeAlpha {
* This does not fork a new branch, but rather retrieves the _existing_ branch for the node.
* To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.
*/
branch(node: TreeNode): TreeBranch | undefined;
branch(node: TreeNode): TreeBranchAlpha | undefined;

/**
* Construct tree content that is compatible with the field defined by the provided `schema`.
Expand Down Expand Up @@ -723,7 +724,7 @@ export const TreeAlpha: TreeAlpha = {
return result;
},

branch(node: TreeNode): TreeBranch | undefined {
branch(node: TreeNode): TreeBranchAlpha | undefined {
const kernel = getKernel(node);
if (!kernel.isHydrated()) {
return undefined;
Expand Down
2 changes: 2 additions & 0 deletions packages/dds/tree/src/simple-tree/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export type {
TreeViewEvents,
SchemaCompatibilityStatus,
TreeViewAlpha,
TreeViewBeta,
TreeBranch,
TreeBranchAlpha,
TreeBranchEvents,
ITreeAlpha,
} from "./tree.js";
Expand Down
Loading
Loading