github microsoft/FluidFramework client_v2.82.0
Fluid Framework v2.82.0 (minor)

9 hours ago

Contents

  • 🌳 SharedTree DDS Changes
    • Add "push" as alias for insertAtEnd on TreeArrayNode (#26260)
    • Adds optional "label" parameter to runTransaction for grouping changes (#25938)
    • Fix bug in multi-step move of array elements (#26344)
    • Promote MinimumVersionForCollab to beta (#26342)
    • Promote TableSchema APIs to beta (#26339)

🌳 SharedTree DDS Changes

Add "push" as alias for insertAtEnd on TreeArrayNode (#26260)

Adds push as an alias to make the API more intuitive and reduce friction for both LLM-generated code and developers familiar with JavaScript array semantics.

Usage

import { TreeArrayNode } from "@fluidframework/tree";

// `inventory` is a TreeArrayNode from your schema.
inventory.push({ name: "Apples", quantity: 3 });

// Insert multiple items in one call.
inventory.push(
  TreeArrayNode.spread([
    { name: "Oranges", quantity: 2 },
    { name: "Bananas", quantity: 5 },
  ]),
);

Change details

Commit: e2ed71b

Affected packages:

  • fluid-framework
  • @fluidframework/tree

⬆️ Table of contents

Adds optional "label" parameter to runTransaction for grouping changes (#25938)

Transaction labels can be used to group multiple changes for undo/redo, where groups of changes with the same label can be undone together. When multiple labels are used in nested transactions, only the outermost label will be used.

The following example demonstrates how to implement label-based undo/redo grouping. It listens to the changed event on the checkout to collect all commits with the same label into a group. When undoLatestGroup() is called, all transactions in that group are reverted together with a single operation.

interface LabeledGroup {
  label: unknown;
  revertibles: { revert(): void }[];
}

const undoGroups: LabeledGroup[] = [];

// The callback on the "changed" event can be used to group the commits.
view.checkout.events.on("changed", (meta, getRevertible) => {
  // Only process local edits, not remote changes or Undo/Redo operations
  if (getRevertible !== undefined && meta.kind === CommitKind.Default) {
    const label = meta.label;
    const revertible = getRevertible();

    // Check if the latest group contains the same label.
    const latestGroup = undoGroups[undoGroups.length - 1];
    if (
      label !== undefined &&
      latestGroup !== undefined &&
      label === latestGroup.label
    ) {
      latestGroup.revertibles.push(revertible);
    } else {
      undoGroups.push({ label, revertibles: [revertible] });
    }
  }
});

const undoLatestGroup = () => {
  const latestGroup =
    undoGroups.pop() ?? fail("There are currently no undo groups.");
  for (const revertible of latestGroup.revertibles.reverse()) {
    revertible.revert();
  }
};

// Group multiple transactions with the same label
view.runTransaction(
  () => {
    view.root.content = 1;
  },
  { label: "EditGroup" },
);
view.runTransaction(
  () => {
    view.root.content = 2;
  },
  { label: "EditGroup" },
);
view.runTransaction(
  () => {
    view.root.content = 3;
  },
  { label: "EditGroup" },
);

// This would undo all three transactions together.
undoLatestGroup();
// view.root.content is now back to 0 (the initial state).

Change details

Commit: cca4db2

Affected packages:

  • fluid-framework
  • @fluidframework/tree

⬆️ Table of contents

Fix bug in multi-step move of array elements (#26344)

A multi-step move can be authored by moving the same array element multiple times within the scope of a single transaction. Such multi-step would lead to errors in the following scenarios:

  • Reverting a multi-step move would fail with error code 0x92a on the peer attempting the revert, thus putting the peer in a broken read-only state without corrupting the document.
  • If the set of pending edits generated by a peer included an edit with a multi-step move, followed by further edits to any of the moved items, reconciling these edits with concurrent edits sequenced earlier could lead to a document corruption with error code 0x9c7.

These operations are now safe.

Change details

Commit: 1bca56c

Affected packages:

  • fluid-framework
  • @fluidframework/tree

⬆️ Table of contents

Promote MinimumVersionForCollab to beta (#26342)

Promotes the MinimumVersionForCollab type to beta, and adds option to configuredSharedTreeBeta for specifying it when creating a new SharedTree.

This allows users to opt into new features and optimizations that are only available when certain minimum version thresholds are guaranteed. For more details, see FluidClientVersion

Example usage

// Configure SharedTree DDS to limit the features it requires of collaborators and future document users to only those available in version `2.80.0` and later, overriding the `MinimumVersionForCollab` provided by the runtime (default: "2.0.0").
// Edits made to this DDS by this client might cause clients older than the specified version to be unable to open the document and/or error out of collaboration sessions.
const SharedTree = configuredSharedTreeBeta({
  minVersionForCollab: FluidClientVersion.v2_80,
});

Change details

Commit: 2bb53c5

Affected packages:

  • fluid-framework
  • @fluidframework/tree

⬆️ Table of contents

Promote TableSchema APIs to beta (#26339)

Promotes the SharedTree TableSchema from alpha to beta. These APIs can now be imported via @fluidframework/tree/beta. Documents from before this are not supported with the beta version of the schema to ensure orphan cell invariants can be guaranteed.

Change details

Commit: 36a625a

Affected packages:

  • fluid-framework
  • @fluidframework/tree

⬆️ Table of contents

🛠️ Start Building Today!

Please continue to engage with us on GitHub Discussion and Issue pages as you adopt Fluid Framework!

Don't miss a new FluidFramework release

NewReleases is sending notifications on new releases.