fluid-framework 2.91.0 → 2.93.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,161 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.93.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `getPresence` from `@fluidframework/presence` is deprecated and will be removed in a future release. ([#26399](https://github.com/microsoft/FluidFramework/pull/26399)) [d533c19c7c](https://github.com/microsoft/FluidFramework/commit/d533c19c7cb25d48ecab1b742e44dfe560d20534)
8
+
9
+ Now `getPresence` is available for import from the `fluid-framework` package.
10
+
11
+ To prepare, make changes following this pattern:
12
+
13
+ ```diff
14
+ -import { getPresence } from "@fluidframework/presence/beta";
15
+ +import { getPresence } from "fluid-framework";
16
+ ```
17
+
18
+ See [issue #26397](https://github.com/microsoft/FluidFramework/issues/26397) for more details.
19
+
20
+ - Add Fluid-controlled map and iterator interfaces ([#26951](https://github.com/microsoft/FluidFramework/pull/26951)) [4735742f15](https://github.com/microsoft/FluidFramework/commit/4735742f15718419e974ead1d5e2e809863d3723)
21
+
22
+ `TreeIndex` now extends `FluidReadonlyMap` instead of the built-in `ReadonlyMap`, and `TreeMapNodeAlpha` which extends `FluidReadonlyMap` instead of the built-in `ReadonlyMap` has been added.
23
+ This works to uncouple Fluid's public API surface to the TypeScript standard library's map types, preventing future breakage when those types change.
24
+
25
+ - Promote tree index APIs from alpha to beta ([#26993](https://github.com/microsoft/FluidFramework/pull/26993)) [37f2f17c118](https://github.com/microsoft/FluidFramework/commit/37f2f17c118baea142b0e842f5b262255d8bb12c)
26
+
27
+ The following APIs have been promoted from `@alpha` to `@beta`:
28
+ - `TreeIndex`
29
+ - `TreeIndexKey`
30
+ - `TreeIndexNodes`
31
+ - `createTreeIndex`
32
+ - `IdentifierIndex`
33
+ - `createIdentifierIndex`
34
+
35
+ Additionally, the following `@fluidframework/core-interfaces` types have been promoted from `@alpha` to `@beta`:
36
+ - `FluidReadonlyMap`
37
+ - `FluidIterable`
38
+ - `FluidIterableIterator`
39
+ - `FluidMap`
40
+
41
+ ## 2.92.0
42
+
43
+ ### Minor Changes
44
+
45
+ - The deprecated getBranch API has been removed ([#26796](https://github.com/microsoft/FluidFramework/pull/26796)) [e80a48e25e](https://github.com/microsoft/FluidFramework/commit/e80a48e25ebab540ce9a0093edc12b9aa5ab03fb)
46
+
47
+ To obtain a branch-like object, create a view from your tree via `viewWith`.
48
+ Or, use `TreeAlpha.context` to get a view from a `TreeNode`.
49
+
50
+ - Array node nodeChanged events now include a delta payload (via TreeAlpha) ([#26677](https://github.com/microsoft/FluidFramework/pull/26677)) [bf02e33aed](https://github.com/microsoft/FluidFramework/commit/bf02e33aed74295840ffa5b6ef889860d58f5654)
51
+
52
+ The `nodeChanged` event for array nodes (accessed via `TreeAlpha.on`) now provides a `delta` field, a sequence of `ArrayNodeDeltaOp` values that describe exactly what changed in the array. This lets you efficiently sync an external representation with tree changes, without taking a snapshot of the old state or diffing the entire array.
53
+
54
+ The delta follows [Quill](https://quilljs.com/docs/)-style semantics: each op covers a contiguous run of positions in the array before the change.
55
+ - `{ type: "retain", count: N }`—N elements stayed in place. Their positions are unchanged, though their contents may have changed (which would fire separate `nodeChanged` events on those elements).
56
+ - `{ type: "insert", count: N }`—N elements were inserted; read their values from the current tree at these positions.
57
+ - `{ type: "remove", count: N }`—N elements were removed.
58
+
59
+ Trailing unchanged elements are not represented by a trailing `"retain"` op.
60
+
61
+ Use `TreeAlpha.on` to subscribe to the richer alpha events. The data passed to the callback is typed as `NodeChangedDataAlpha<TNode>`:
62
+ - Object, map, and record nodes receive `NodeChangedDataProperties` (with a required `changedProperties` set).
63
+ - Array nodes receive `NodeChangedDataDelta` (with a `delta` field).
64
+
65
+ `TreeBeta.on` is unchanged and does not include delta information.
66
+
67
+ #### Example: Applying a Delta to a Plain Array Mirror
68
+
69
+ ```typescript
70
+ // Walk the delta to keep a plain JS array in sync with an array node.
71
+ // retain = advance past unchanged elements,
72
+ // insert = splice in new elements,
73
+ // remove = splice out removed elements.
74
+ const mirror: number[] = [1, 2, 3];
75
+
76
+ TreeAlpha.on(myArrayNode, "nodeChanged", ({ delta }) => {
77
+ let readPos = 0; // position in the current (post-change) tree
78
+ let writePos = 0; // position in the mirror array
79
+
80
+ for (const op of delta ?? []) {
81
+ if (op.type === "retain") {
82
+ writePos += op.count;
83
+ readPos += op.count;
84
+ } else if (op.type === "insert") {
85
+ const newItems = Array.from(
86
+ { length: op.count },
87
+ (_, i) => myArrayNode[readPos + i],
88
+ );
89
+ mirror.splice(writePos, 0, ...newItems);
90
+ writePos += op.count;
91
+ readPos += op.count;
92
+ } else if (op.type === "remove") {
93
+ mirror.splice(writePos, op.count);
94
+ }
95
+ }
96
+ });
97
+ ```
98
+
99
+ #### Example: Narrowing the Union in a Generic Handler
100
+
101
+ ```typescript
102
+ TreeAlpha.on(node as TreeNode, "nodeChanged", (data) => {
103
+ if ("delta" in data) {
104
+ // Array node — data is NodeChangedDataDelta
105
+ console.log("array changed, delta:", data.delta);
106
+ } else {
107
+ // Object/map/record node — data is NodeChangedDataProperties
108
+ console.log("properties changed:", data.changedProperties);
109
+ }
110
+ });
111
+ ```
112
+
113
+ > **Note:** The `delta` value may be `undefined` in two cases:
114
+ >
115
+ > - The node was created locally and has not yet been inserted into a document tree (a known temporary limitation).
116
+ > - The document was updated in a way that required multiple internal change passes in a single operation (for example, a data change combined with a schema upgrade).
117
+
118
+ - Add TreeArrayNodeAlpha with a new splice method ([#26740](https://github.com/microsoft/FluidFramework/pull/26740)) [f2b0cf9176](https://github.com/microsoft/FluidFramework/commit/f2b0cf917609b84952db2b9492867e70e0d57981)
119
+
120
+ Adds a `splice` method on `TreeArrayNodeAlpha` that supports removing and inserting items in a single operation to align with JavaScript's Array splice API.
121
+ Returns the removed items as an array.
122
+ Supports negative `start` indices (wraps from end).
123
+ Optional `deleteCount` (omitting removes everything from `start` onward).
124
+ The alpha API is accessible by an `asAlpha` cast on existing TreeArrayNodes, or using `schemaFactoryAlpha`.
125
+ `arrayAlpha` nodes are accepted wherever `TreeArrayNode` is expected, but not the reverse.
126
+ `asAlpha` is bidirectional since it's the same underlying schema.
127
+
128
+ #### Usage
129
+
130
+ ```typescript
131
+ import {
132
+ SchemaFactory,
133
+ SchemaFactoryAlpha,
134
+ asAlpha,
135
+ } from "@fluidframework/tree";
136
+
137
+ // Using asAlpha to cast an existing TreeArrayNode
138
+ const sf = new SchemaFactory("example");
139
+ const Inventory = sf.array("Inventory", sf.string);
140
+ const inventory = new Inventory(["Apples", "Bananas", "Pears"]);
141
+ const inventoryAlpha = asAlpha(inventory);
142
+
143
+ // Using SchemaFactoryAlpha so splice is available directly
144
+ const sf = new SchemaFactoryAlpha("example");
145
+ const Inventory = sf.arrayAlpha("Inventory", sf.string);
146
+ const inventoryAlpha = new Inventory(["Apples", "Bananas", "Pears"]);
147
+
148
+ // Remove 2 items starting at index 0, insert new items in their place
149
+ const removed = inventoryAlpha.splice(0, 2, "Oranges", "Grapes");
150
+ // removed: ["Apples", "Bananas"]
151
+ // inventory: ["Oranges", "Grapes", "Pears"]
152
+
153
+ // Removed everything from index 1 onward (omitting deleteCount)
154
+ const rest = inventoryAlpha.splice(1);
155
+ // rest: ["Grapes", "Pears"]
156
+ // inventory: ["Oranges"]
157
+ ```
158
+
3
159
  ## 2.91.0
4
160
 
5
161
  ### Minor Changes
package/README.md CHANGED
@@ -91,7 +91,7 @@ When making such a request please include if the configuration already works (an
91
91
 
92
92
  ### Supported Runtimes
93
93
 
94
- - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
94
+ - NodeJs ^22.22.2 except that we will drop support for it [when NodeJs 22 loses its upstream support on 2027-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS at least 1 year before 22 is end-of-life.
95
95
  - Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
96
96
  - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
97
97
 
package/alpha.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/alpha.js";