fluid-framework 2.90.0 → 2.92.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,370 @@
1
1
  # fluid-framework
2
2
 
3
+ ## 2.92.0
4
+
5
+ ### Minor Changes
6
+
7
+ - The deprecated getBranch API has been removed ([#26796](https://github.com/microsoft/FluidFramework/pull/26796)) [e80a48e25e](https://github.com/microsoft/FluidFramework/commit/e80a48e25ebab540ce9a0093edc12b9aa5ab03fb)
8
+
9
+ To obtain a branch-like object, create a view from your tree via `viewWith`.
10
+ Or, use `TreeAlpha.context` to get a view from a `TreeNode`.
11
+
12
+ - 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)
13
+
14
+ 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.
15
+
16
+ The delta follows [Quill](https://quilljs.com/docs/)-style semantics: each op covers a contiguous run of positions in the array before the change.
17
+ - `{ 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).
18
+ - `{ type: "insert", count: N }`—N elements were inserted; read their values from the current tree at these positions.
19
+ - `{ type: "remove", count: N }`—N elements were removed.
20
+
21
+ Trailing unchanged elements are not represented by a trailing `"retain"` op.
22
+
23
+ Use `TreeAlpha.on` to subscribe to the richer alpha events. The data passed to the callback is typed as `NodeChangedDataAlpha<TNode>`:
24
+ - Object, map, and record nodes receive `NodeChangedDataProperties` (with a required `changedProperties` set).
25
+ - Array nodes receive `NodeChangedDataDelta` (with a `delta` field).
26
+
27
+ `TreeBeta.on` is unchanged and does not include delta information.
28
+
29
+ #### Example: Applying a Delta to a Plain Array Mirror
30
+
31
+ ```typescript
32
+ // Walk the delta to keep a plain JS array in sync with an array node.
33
+ // retain = advance past unchanged elements,
34
+ // insert = splice in new elements,
35
+ // remove = splice out removed elements.
36
+ const mirror: number[] = [1, 2, 3];
37
+
38
+ TreeAlpha.on(myArrayNode, "nodeChanged", ({ delta }) => {
39
+ let readPos = 0; // position in the current (post-change) tree
40
+ let writePos = 0; // position in the mirror array
41
+
42
+ for (const op of delta ?? []) {
43
+ if (op.type === "retain") {
44
+ writePos += op.count;
45
+ readPos += op.count;
46
+ } else if (op.type === "insert") {
47
+ const newItems = Array.from(
48
+ { length: op.count },
49
+ (_, i) => myArrayNode[readPos + i],
50
+ );
51
+ mirror.splice(writePos, 0, ...newItems);
52
+ writePos += op.count;
53
+ readPos += op.count;
54
+ } else if (op.type === "remove") {
55
+ mirror.splice(writePos, op.count);
56
+ }
57
+ }
58
+ });
59
+ ```
60
+
61
+ #### Example: Narrowing the Union in a Generic Handler
62
+
63
+ ```typescript
64
+ TreeAlpha.on(node as TreeNode, "nodeChanged", (data) => {
65
+ if ("delta" in data) {
66
+ // Array node — data is NodeChangedDataDelta
67
+ console.log("array changed, delta:", data.delta);
68
+ } else {
69
+ // Object/map/record node — data is NodeChangedDataProperties
70
+ console.log("properties changed:", data.changedProperties);
71
+ }
72
+ });
73
+ ```
74
+
75
+ > **Note:** The `delta` value may be `undefined` in two cases:
76
+ >
77
+ > - The node was created locally and has not yet been inserted into a document tree (a known temporary limitation).
78
+ > - 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).
79
+
80
+ - Add TreeArrayNodeAlpha with a new splice method ([#26740](https://github.com/microsoft/FluidFramework/pull/26740)) [f2b0cf9176](https://github.com/microsoft/FluidFramework/commit/f2b0cf917609b84952db2b9492867e70e0d57981)
81
+
82
+ Adds a `splice` method on `TreeArrayNodeAlpha` that supports removing and inserting items in a single operation to align with JavaScript's Array splice API.
83
+ Returns the removed items as an array.
84
+ Supports negative `start` indices (wraps from end).
85
+ Optional `deleteCount` (omitting removes everything from `start` onward).
86
+ The alpha API is accessible by an `asAlpha` cast on existing TreeArrayNodes, or using `schemaFactoryAlpha`.
87
+ `arrayAlpha` nodes are accepted wherever `TreeArrayNode` is expected, but not the reverse.
88
+ `asAlpha` is bidirectional since it's the same underlying schema.
89
+
90
+ #### Usage
91
+
92
+ ```typescript
93
+ import {
94
+ SchemaFactory,
95
+ SchemaFactoryAlpha,
96
+ asAlpha,
97
+ } from "@fluidframework/tree";
98
+
99
+ // Using asAlpha to cast an existing TreeArrayNode
100
+ const sf = new SchemaFactory("example");
101
+ const Inventory = sf.array("Inventory", sf.string);
102
+ const inventory = new Inventory(["Apples", "Bananas", "Pears"]);
103
+ const inventoryAlpha = asAlpha(inventory);
104
+
105
+ // Using SchemaFactoryAlpha so splice is available directly
106
+ const sf = new SchemaFactoryAlpha("example");
107
+ const Inventory = sf.arrayAlpha("Inventory", sf.string);
108
+ const inventoryAlpha = new Inventory(["Apples", "Bananas", "Pears"]);
109
+
110
+ // Remove 2 items starting at index 0, insert new items in their place
111
+ const removed = inventoryAlpha.splice(0, 2, "Oranges", "Grapes");
112
+ // removed: ["Apples", "Bananas"]
113
+ // inventory: ["Oranges", "Grapes", "Pears"]
114
+
115
+ // Removed everything from index 1 onward (omitting deleteCount)
116
+ const rest = inventoryAlpha.splice(1);
117
+ // rest: ["Grapes", "Pears"]
118
+ // inventory: ["Oranges"]
119
+ ```
120
+
121
+ ## 2.91.0
122
+
123
+ ### Minor Changes
124
+
125
+ - Adds withDefault API to allow defining default values for required and optional fields ([#26502](https://github.com/microsoft/FluidFramework/pull/26502)) [44fdd9421e4](https://github.com/microsoft/FluidFramework/commit/44fdd9421e4d0bfa3cdfa9ab3672ebf3c0ad20a6)
126
+
127
+ The `withDefault` API is now available on `SchemaFactoryAlpha`. It allows you to specify default values for fields,
128
+ making them optional in constructors even when the field is marked as required in the schema.
129
+ This provides a better developer experience by reducing boilerplate when creating objects.
130
+
131
+ The `withDefault` API wraps a field schema and defines a default value to use when the field is not provided during
132
+ construction. The default value must be of an allowed type of the field. You can provide defaults in two ways:
133
+ - **A value**: When a value is provided directly, the data is copied for each use to ensure independence between instances
134
+ - **A generator function**: A function that is called each time to produce a fresh value
135
+
136
+ Defaults are evaluated eagerly during node construction.
137
+
138
+ #### Required fields with defaults
139
+
140
+ ```typescript
141
+ import { SchemaFactoryAlpha, TreeAlpha } from "@fluidframework/tree/alpha";
142
+
143
+ const sf = new SchemaFactoryAlpha("example");
144
+
145
+ class Person extends sf.objectAlpha("Person", {
146
+ name: sf.required(sf.string),
147
+ age: sf.withDefault(sf.required(sf.number), -1),
148
+ role: sf.withDefault(sf.required(sf.string), "guest"),
149
+ }) {}
150
+
151
+ // Before: all fields were required
152
+ // const person = new Person({ name: "Alice", age: -1, role: "guest" });
153
+
154
+ // After: fields with defaults are optional
155
+ const person = new Person({ name: "Alice" });
156
+ // person.age === -1
157
+ // person.role === "guest"
158
+
159
+ // You can still provide values to override the defaults
160
+ const admin = new Person({ name: "Bob", age: 30, role: "admin" });
161
+ ```
162
+
163
+ #### Optional fields with custom defaults
164
+
165
+ Optional fields (`sf.optional`) already default to `undefined`, but `withDefault` allows you to specify a different
166
+ default value:
167
+
168
+ ```typescript
169
+ class Config extends sf.object("Config", {
170
+ timeout: sf.withDefault(sf.optional(sf.number), 5000),
171
+ retries: sf.withDefault(sf.optional(sf.number), 3),
172
+ }) {}
173
+
174
+ // All fields are optional, using custom defaults when not provided
175
+ const config = new Config({});
176
+ // config.timeout === 5000
177
+ // config.retries === 3
178
+
179
+ const customConfig = new Config({ timeout: 10000 });
180
+ // customConfig.timeout === 10000
181
+ // customConfig.retries === 3
182
+ ```
183
+
184
+ #### Value defaults vs function defaults
185
+
186
+ When you provide a value directly, the data is copied for each use, ensuring each instance is independent:
187
+
188
+ ```typescript
189
+ class Metadata extends sf.object("Metadata", {
190
+ tags: sf.array(sf.string),
191
+ version: sf.number,
192
+ }) {}
193
+
194
+ class Article extends sf.object("Article", {
195
+ title: sf.required(sf.string),
196
+
197
+ // a node is provided directly, it is copied for each use
198
+ metadata: sf.withDefault(
199
+ sf.optional(Metadata),
200
+ new Metadata({ tags: [], version: 1 }),
201
+ ),
202
+
203
+ // also works with arrays
204
+ authors: sf.withDefault(sf.optional(sf.array(sf.string)), []),
205
+ }) {}
206
+
207
+ const article1 = new Article({ title: "First" });
208
+ const article2 = new Article({ title: "Second" });
209
+
210
+ // each article gets its own independent copy
211
+ assert(article1.metadata !== article2.metadata);
212
+ article1.metadata.version = 2; // Doesn't affect article2
213
+ assert(article2.metadata.version === 1);
214
+ ```
215
+
216
+ Alternatively, you can use generator functions to explicitly create new instances:
217
+
218
+ ```typescript
219
+ class Article extends sf.object("Article", {
220
+ title: sf.required(sf.string),
221
+
222
+ // generators are called each time to create a new instance
223
+ metadata: sf.withDefault(
224
+ sf.optional(Metadata),
225
+ () => new Metadata({ tags: [], version: 1 }),
226
+ ),
227
+ authors: sf.withDefault(sf.optional(sf.array(sf.string)), () => []),
228
+ }) {}
229
+ ```
230
+
231
+ Insertable object literals, arrays, and map objects can be used in place of node instances in both static defaults
232
+ and generator functions:
233
+
234
+ ```typescript
235
+ class Article extends sf.object("Article", {
236
+ title: sf.required(sf.string),
237
+
238
+ // plain object literal instead of new Metadata(...)
239
+ metadata: sf.withDefault(sf.optional(Metadata), () => ({
240
+ tags: [],
241
+ version: 1,
242
+ })),
243
+
244
+ // plain array instead of new ArrayNode(...)
245
+ authors: sf.withDefault(sf.optional(sf.array(sf.string)), () => [
246
+ "anonymous",
247
+ ]),
248
+ }) {}
249
+ ```
250
+
251
+ ##### Dynamic defaults
252
+
253
+ Generator functions are called each time a new node is created, enabling dynamic defaults:
254
+
255
+ ```typescript
256
+ class Document extends sf.object("Document", {
257
+ id: sf.withDefault(sf.required(sf.string), () => crypto.randomUUID()),
258
+ title: sf.required(sf.string),
259
+ }) {}
260
+
261
+ const doc1 = new Document({ title: "First Document" });
262
+ const doc2 = new Document({ title: "Second Document" });
263
+ // doc1.id !== doc2.id (each gets a unique UUID)
264
+ ```
265
+
266
+ Generator functions also work with primitive types:
267
+
268
+ ```typescript
269
+ let counter = 0;
270
+
271
+ class GameState extends sf.object("GameState", {
272
+ playerId: sf.withDefault(
273
+ sf.required(sf.string),
274
+ () => `player-${counter++}`,
275
+ ),
276
+ score: sf.withDefault(sf.required(sf.number), () =>
277
+ Math.floor(Math.random() * 100),
278
+ ),
279
+ isActive: sf.withDefault(sf.required(sf.boolean), () => counter % 2 === 0),
280
+ }) {}
281
+ ```
282
+
283
+ #### Recursive types
284
+
285
+ `withDefaultRecursive` is available for use inside recursive schemas. Use `objectRecursiveAlpha` (rather than
286
+ `objectRecursive`) when defining recursive schemas with defaults, as it correctly makes defaulted fields optional in
287
+ the constructor for all field kinds including `requiredRecursive`. It works the same as `withDefault` but is
288
+ necessary to avoid TypeScript's circular reference limitations.
289
+
290
+ ```typescript
291
+ class TreeNode extends sf.objectRecursiveAlpha("TreeNode", {
292
+ value: sf.number,
293
+ label: SchemaFactoryAlpha.withDefaultRecursive(
294
+ sf.optional(sf.string),
295
+ "untitled",
296
+ ),
297
+ child: sf.optionalRecursive([() => TreeNode]),
298
+ }) {}
299
+
300
+ // `label` is optional in the constructor — the default is used when omitted
301
+ const leaf = new TreeNode({ value: 1 });
302
+ // leaf.label === "untitled"
303
+
304
+ const root = new TreeNode({ value: 0, label: "root", child: leaf });
305
+ // root.label === "root"
306
+ // root.child.label === "untitled"
307
+ ```
308
+
309
+ > **Warning:** Be careful about using the recursive type itself as a default value — this is likely to cause
310
+ > infinite recursion at construction time, since creating the default value would trigger the same default again.
311
+ > Instead, use a primitive or a separate node type as the default:
312
+ >
313
+ > ```typescript
314
+ > const DefaultTag = sf.objectRecursiveAlpha("Tag", {
315
+ > id: sf.number,
316
+ > child: sf.optionalRecursive([() => TreeNode]),
317
+ > });
318
+ >
319
+ > class TreeNode extends sf.objectRecursiveAlpha("TreeNode", {
320
+ > value: sf.number,
321
+ > // ✅ Safe: default is a non-recursive node
322
+ > tag: SchemaFactoryAlpha.withDefaultRecursive(
323
+ > sf.optional(DefaultTag),
324
+ > () => new DefaultTag({ id: 0, child: new DefaultTag({ id: 1 }) }),
325
+ > ),
326
+ > child: sf.optionalRecursive([() => TreeNode]),
327
+ > }) {}
328
+ > ```
329
+ >
330
+ > The following definition for child would cause infinite recursion at construction time:
331
+ >
332
+ > ```typescript
333
+ > child: SchemaFactoryAlpha.withDefaultRecursive(
334
+ > sf.optionalRecursive([() => TreeNode]),
335
+ > () => new TreeNode({ value: 0 }),
336
+ > );
337
+ > ```
338
+
339
+ > The infinite recursion can be solved by passing in undefined explicitly but it is
340
+ > recommended to not use defaults in this case:
341
+ >
342
+ > ```typescript
343
+ > child: SchemaFactoryAlpha.withDefaultRecursive(
344
+ > sf.optionalRecursive([() => TreeNode]),
345
+ > () => new TreeNode({ value: 0, child: undefined }),
346
+ > );
347
+ > ```
348
+
349
+ #### Type safety
350
+
351
+ The default value (or the value returned by a generator function) must be of an allowed type for the field. TypeScript
352
+ enforces this at compile time:
353
+
354
+ ```typescript
355
+ // ✅ Valid: number default for number field
356
+ sf.withDefault(sf.optional(sf.number), 8080);
357
+
358
+ // ✅ Valid: generator returns string for string field
359
+ sf.withDefault(sf.optional(sf.string), () => "localhost");
360
+
361
+ // ❌ TypeScript error: string default for number field
362
+ sf.withDefault(sf.optional(sf.number), "8080");
363
+
364
+ // ❌ TypeScript error: generator returns number for string field
365
+ sf.withDefault(sf.optional(sf.string), () => 8080);
366
+ ```
367
+
3
368
  ## 2.90.0
4
369
 
5
370
  ### Minor Changes
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";
@@ -96,16 +96,47 @@ Kind
96
96
  export interface ArrayNodeCustomizableSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Array, TreeArrayNode<T> & WithType<TName, NodeKind.Array, T>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T, undefined, TCustomMetadata>, SimpleArrayNodeSchema<SchemaType.View, TCustomMetadata> {
97
97
  }
98
98
 
99
+ // @alpha @sealed @system
100
+ export interface ArrayNodeCustomizableSchemaAlpha<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Array, TreeArrayNodeAlpha<T> & WithType<TName, NodeKind.Array, T>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T, undefined, TCustomMetadata>, SimpleArrayNodeSchema<SchemaType.View, TCustomMetadata> {
101
+ }
102
+
99
103
  // @alpha @sealed @system
100
104
  export interface ArrayNodeCustomizableSchemaUnsafe<out TName extends string, in out T extends System_Unsafe.ImplicitAllowedTypesUnsafe, out TCustomMetadata> extends TreeNodeSchemaClass<TName, NodeKind.Array, System_Unsafe.TreeArrayNodeUnsafe<T> & WithType<TName, NodeKind.Array, T>, {
101
105
  [Symbol.iterator](): Iterator<System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
102
106
  }, false, T, undefined, TCustomMetadata>, SimpleArrayNodeSchema<SchemaType.View, TCustomMetadata> {
103
107
  }
104
108
 
109
+ // @alpha @sealed
110
+ export type ArrayNodeDeltaOp = ArrayNodeRetainOp | ArrayNodeInsertOp | ArrayNodeRemoveOp;
111
+
112
+ // @alpha @sealed
113
+ export interface ArrayNodeInsertOp {
114
+ // (undocumented)
115
+ readonly count: number;
116
+ // (undocumented)
117
+ readonly type: "insert";
118
+ }
119
+
105
120
  // @alpha @sealed @system
106
121
  export interface ArrayNodePojoEmulationSchema<out TName extends string = string, in out T extends ImplicitAllowedTypes = ImplicitAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaNonClass<TName, NodeKind.Array, TreeArrayNode<T> & WithType<TName, NodeKind.Array, T>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T, undefined, TCustomMetadata>, SimpleArrayNodeSchema<SchemaType.View, TCustomMetadata> {
107
122
  }
108
123
 
124
+ // @alpha @sealed
125
+ export interface ArrayNodeRemoveOp {
126
+ // (undocumented)
127
+ readonly count: number;
128
+ // (undocumented)
129
+ readonly type: "remove";
130
+ }
131
+
132
+ // @alpha @sealed
133
+ export interface ArrayNodeRetainOp {
134
+ // (undocumented)
135
+ readonly count: number;
136
+ // (undocumented)
137
+ readonly type: "retain";
138
+ }
139
+
109
140
  // @alpha
110
141
  export type ArrayNodeSchema = ArrayNodeCustomizableSchema | ArrayNodePojoEmulationSchema;
111
142
 
@@ -125,6 +156,9 @@ export function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSch
125
156
  // @alpha
126
157
  export function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeViewConfiguration<TSchema>): TreeViewConfigurationAlpha<TSchema>;
127
158
 
159
+ // @alpha
160
+ export function asAlpha<TAllowedTypes extends ImplicitAllowedTypes>(node: TreeArrayNode<TAllowedTypes>): TreeArrayNodeAlpha<TAllowedTypes>;
161
+
128
162
  // @beta
129
163
  export function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;
130
164
 
@@ -138,14 +172,6 @@ export enum AttachState {
138
172
  Detached = "Detached"
139
173
  }
140
174
 
141
- // @alpha @sealed
142
- export interface BranchableTree extends ViewableTree {
143
- branch(): TreeBranchFork;
144
- merge(branch: TreeBranchFork): void;
145
- merge(branch: TreeBranchFork, disposeMerged: boolean): void;
146
- rebase(branch: TreeBranchFork): void;
147
- }
148
-
149
175
  // @alpha @sealed
150
176
  export type ChangeMetadata = LocalChangeMetadata | RemoteChangeMetadata;
151
177
 
@@ -307,6 +333,15 @@ export abstract class ErasedBaseType<out Name = unknown> {
307
333
  protected abstract brand(dummy: never): Name;
308
334
  }
309
335
 
336
+ // @alpha
337
+ export type ErasedNode<TExtra, Identifier extends string> = TExtra & TreeNode & WithType<Identifier>;
338
+
339
+ // @alpha
340
+ export type ErasedSchema<NodeType extends TreeNode> = TreeNodeSchema<NodeType extends WithType<infer Identifier> ? Identifier : string, NodeKind, NodeType, never, false>;
341
+
342
+ // @alpha
343
+ export type ErasedSchemaSubclassable<TExtra, Identifier extends string> = TreeNodeSchemaClass<Identifier, NodeKind, ErasedNode<TExtra, Identifier>, never, false>;
344
+
310
345
  // @public @sealed
311
346
  export abstract class ErasedType<out Name = unknown> {
312
347
  static [Symbol.hasInstance](value: never): value is never;
@@ -356,6 +391,18 @@ type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [
356
391
  FieldSchema<FieldKind.Optional | FieldKind.Identifier>
357
392
  ] ? true : false;
358
393
 
394
+ // @alpha @system
395
+ export type FieldHasDefaultAlpha<T extends ImplicitFieldSchema> = [
396
+ T
397
+ ] extends [FieldSchemaAlpha<infer Kind, infer _Types, infer _Meta, infer TProps>] ? Kind extends FieldKind.Optional | FieldKind.Identifier ? true : TProps extends {
398
+ defaultProvider: DefaultProvider;
399
+ } ? true : false : FieldHasDefault<T>;
400
+
401
+ // @alpha @sealed @system
402
+ export type FieldHasDefaultAlphaUnsafe<T extends System_Unsafe.ImplicitFieldSchemaUnsafe> = T extends FieldSchemaAlphaUnsafe<infer Kind, System_Unsafe.ImplicitAllowedTypesUnsafe, unknown, infer TProps> ? Kind extends FieldKind.Optional | FieldKind.Identifier ? true : TProps extends {
403
+ defaultProvider: DefaultProvider;
404
+ } ? true : false : System_Unsafe.FieldHasDefaultUnsafe<T>;
405
+
359
406
  // @public
360
407
  export enum FieldKind {
361
408
  Identifier = 2,
@@ -391,7 +438,7 @@ export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types exten
391
438
  }
392
439
 
393
440
  // @alpha @sealed
394
- export class FieldSchemaAlpha<Kind extends FieldKind = FieldKind, Types extends ImplicitAllowedTypes = ImplicitAllowedTypes, TCustomMetadata = unknown> extends FieldSchema<Kind, Types, TCustomMetadata> implements SimpleFieldSchema<SchemaType.View> {
441
+ export class FieldSchemaAlpha<Kind extends FieldKind = FieldKind, Types extends ImplicitAllowedTypes = ImplicitAllowedTypes, TCustomMetadata = unknown, TProps extends FieldPropsAlpha<TCustomMetadata> | undefined = FieldPropsAlpha<TCustomMetadata> | undefined> extends FieldSchema<Kind, Types, TCustomMetadata> implements SimpleFieldSchema<SchemaType.View> {
395
442
  protected constructor(kind: Kind, types: Types, props?: FieldPropsAlpha<TCustomMetadata>);
396
443
  readonly allowedTypesFull: AllowedTypesFull;
397
444
  // (undocumented)
@@ -403,7 +450,7 @@ export class FieldSchemaAlpha<Kind extends FieldKind = FieldKind, Types extends
403
450
  }
404
451
 
405
452
  // @alpha @sealed @system
406
- export interface FieldSchemaAlphaUnsafe<out Kind extends FieldKind, out Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, out TCustomMetadata = unknown> extends FieldSchemaAlpha<Kind, any, TCustomMetadata>, System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata> {
453
+ export interface FieldSchemaAlphaUnsafe<out Kind extends FieldKind, out Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, out TCustomMetadata = unknown, out TProps extends FieldPropsAlpha<TCustomMetadata> | undefined = undefined> extends FieldSchemaAlpha<Kind, any, TCustomMetadata, TProps>, System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata> {
407
454
  readonly allowedTypes: Types;
408
455
  }
409
456
 
@@ -503,12 +550,6 @@ export type FormatVersion = number | string | undefined;
503
550
  // @alpha
504
551
  export function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema;
505
552
 
506
- // @alpha @deprecated
507
- export function getBranch(tree: ITree): BranchableTree;
508
-
509
- // @alpha @deprecated
510
- export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(view: TreeViewAlpha<T>): BranchableTree;
511
-
512
553
  // @alpha
513
554
  export function getJsonSchema(schema: ImplicitAllowedTypes, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;
514
555
 
@@ -838,6 +879,22 @@ type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<Implicit
838
879
  readonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
839
880
  }>;
840
881
 
882
+ // @alpha @system
883
+ export type InsertableObjectFromSchemaRecordAlpha<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = RestrictiveStringRecord<ImplicitFieldSchema> extends T ? {
884
+ arbitraryKey: "arbitraryValue";
885
+ } extends T ? Record<string, never> : never : FlattenKeys<{
886
+ readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property & string]>;
887
+ } & {
888
+ readonly [Property in keyof T as FieldHasDefaultAlpha<T[Property & string]> extends false ? Property : never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;
889
+ }>;
890
+
891
+ // @alpha @system
892
+ export type InsertableObjectFromSchemaRecordAlphaUnsafe<T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>> = {
893
+ readonly [Property in keyof T as FieldHasDefaultAlphaUnsafe<T[Property & string]> extends false ? Property : never]: System_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;
894
+ } & {
895
+ readonly [Property in keyof T as FieldHasDefaultAlphaUnsafe<T[Property & string]> extends true ? Property : never]?: System_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<T[Property & string]>;
896
+ };
897
+
841
898
  // @public
842
899
  export type InsertableTreeFieldFromImplicitField<TSchemaInput extends ImplicitFieldSchema, TSchema = UnionToIntersection<TSchemaInput>> = [TSchema] extends [FieldSchema<infer Kind, infer Types>] ? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : [TSchema] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
843
900
 
@@ -1149,6 +1206,19 @@ export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
1149
1206
  readonly changedProperties?: ReadonlySet<TNode extends WithType<string, NodeKind.Object, infer TInfo> ? string & keyof TInfo : string>;
1150
1207
  }
1151
1208
 
1209
+ // @alpha
1210
+ export type NodeChangedDataAlpha<TNode extends TreeNode = TreeNode> = TNode extends WithType<string, NodeKind.Array> ? NodeChangedDataDelta : TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record> ? NodeChangedDataProperties<TNode> : NodeChangedDataProperties<TNode> | NodeChangedDataDelta;
1211
+
1212
+ // @alpha @sealed
1213
+ export interface NodeChangedDataDelta {
1214
+ readonly delta: readonly ArrayNodeDeltaOp[] | undefined;
1215
+ }
1216
+
1217
+ // @alpha @sealed
1218
+ export interface NodeChangedDataProperties<TNode extends TreeNode = TreeNode> {
1219
+ readonly changedProperties: ReadonlySet<TNode extends WithType<string, NodeKind.Object, infer TInfo> ? string & keyof TInfo : string>;
1220
+ }
1221
+
1152
1222
  // @public
1153
1223
  export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<string, NodeKind, infer TNode> ? TNode : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode> ? TNode : never;
1154
1224
 
@@ -1169,6 +1239,9 @@ export enum NodeKind {
1169
1239
  Record = 4
1170
1240
  }
1171
1241
 
1242
+ // @alpha @sealed
1243
+ export type NodeProvider<T> = T | (() => T);
1244
+
1172
1245
  // @public @sealed
1173
1246
  export interface NodeSchemaMetadata<out TCustomMetadata = unknown> {
1174
1247
  readonly custom?: TCustomMetadata | undefined;
@@ -1199,7 +1272,7 @@ export type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFie
1199
1272
  };
1200
1273
 
1201
1274
  // @alpha @sealed
1202
- export interface ObjectNodeSchema<out TName extends string = string, in out T extends RestrictiveStringRecord<ImplicitFieldSchema> = RestrictiveStringRecord<ImplicitFieldSchema>, ImplicitlyConstructable extends boolean = boolean, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Object, TreeObjectNode<T, TName>, InsertableObjectFromSchemaRecord<T>, ImplicitlyConstructable, T, never, TCustomMetadata>, SimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> {
1275
+ export interface ObjectNodeSchema<out TName extends string = string, in out T extends RestrictiveStringRecord<ImplicitFieldSchema> = RestrictiveStringRecord<ImplicitFieldSchema>, ImplicitlyConstructable extends boolean = boolean, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Object, TreeObjectNode<T, TName>, object & InsertableObjectFromSchemaRecordAlpha<T>, ImplicitlyConstructable, T, never, TCustomMetadata>, SimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> {
1203
1276
  readonly fields: ReadonlyMap<string, FieldSchemaAlpha & SimpleObjectFieldSchema>;
1204
1277
  }
1205
1278
 
@@ -1208,6 +1281,11 @@ export const ObjectNodeSchema: {
1208
1281
  readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ObjectNodeSchema<string, RestrictiveStringRecord<ImplicitFieldSchema>, boolean, unknown>;
1209
1282
  };
1210
1283
 
1284
+ // @alpha @sealed
1285
+ export type ObjectNodeSchemaWorkaround<TName extends string = string, T extends RestrictiveStringRecord<ImplicitFieldSchema> = RestrictiveStringRecord<ImplicitFieldSchema>, ImplicitlyConstructable extends boolean = boolean, TCustomMetadata = unknown> = ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> & {
1286
+ readonly createFromInsertable: unknown;
1287
+ };
1288
+
1211
1289
  // @beta @input
1212
1290
  export interface ObjectSchemaOptions<TCustomMetadata = unknown> extends NodeSchemaOptions<TCustomMetadata> {
1213
1291
  readonly allowUnknownOptionalFields?: boolean;
@@ -1391,30 +1469,41 @@ export const SchemaFactory_base: SchemaStatics & (new () => SchemaStatics);
1391
1469
 
1392
1470
  // @alpha
1393
1471
  export class SchemaFactoryAlpha<out TScope extends string | undefined = string | undefined, TName extends number | string = string> extends SchemaFactoryBeta<TScope, TName> {
1394
- arrayAlpha<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
1472
+ arrayAlpha<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): ArrayNodeCustomizableSchemaAlpha<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
1395
1473
  arrayRecursive<const Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): ArrayNodeCustomizableSchemaUnsafe<ScopedSchemaName<TScope, Name>, T, TCustomMetadata>;
1396
- static readonly identifier: <const TCustomMetadata = unknown>(props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Identifier, LeafSchema<"string", string> & SimpleLeafNodeSchema<SchemaType>, TCustomMetadata>;
1474
+ static readonly identifier: <const TCustomMetadata = unknown>(props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Identifier, LeafSchema<"string", string> & SimpleLeafNodeSchema<SchemaType>, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1397
1475
  static readonly leaves: readonly [LeafSchema<"string", string> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"number", number> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"boolean", boolean> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"null", null> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"handle", IFluidHandle_2<unknown>> & SimpleLeafNodeSchema<SchemaType>];
1398
1476
  readonly leaves: readonly [LeafSchema<"string", string> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"number", number> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"boolean", boolean> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"null", null> & SimpleLeafNodeSchema<SchemaType>, LeafSchema<"handle", IFluidHandle_2<unknown>> & SimpleLeafNodeSchema<SchemaType>];
1399
1477
  mapAlpha<Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
1400
1478
  mapRecursive<Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): MapNodeCustomizableSchemaUnsafe<ScopedSchemaName<TScope, Name>, T, TCustomMetadata>;
1401
- objectAlpha<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: ObjectSchemaOptionsAlpha<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {
1402
- readonly createFromInsertable: unknown;
1403
- };
1479
+ objectAlpha<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: ObjectSchemaOptionsAlpha<TCustomMetadata>): ObjectNodeSchemaWorkaround<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
1404
1480
  objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: ObjectSchemaOptionsAlpha<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, System_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata> & SimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> & Pick<ObjectNodeSchema, "fields">;
1405
- static readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;
1406
- readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata>;
1407
- static readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
1408
- readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
1481
+ objectRecursiveAlpha<const Name extends TName, const T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: ObjectSchemaOptionsAlpha<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, System_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordAlphaUnsafe<T>, false, T, never, TCustomMetadata> & SimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> & Pick<ObjectNodeSchema, "fields">;
1482
+ static readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1483
+ readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1484
+ static readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1485
+ readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1409
1486
  recordAlpha<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
1410
1487
  recordRecursive<Name extends TName, const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Record, TreeRecordNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record, unknown>, {
1411
1488
  readonly [x: string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
1412
1489
  }, false, T, undefined, TCustomMetadata>;
1413
- static readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;
1414
- readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata>;
1415
- static readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata>;
1416
- readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata>;
1490
+ static readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1491
+ readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Required, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1492
+ static readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1493
+ readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Required, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
1417
1494
  scopedFactoryAlpha<const T extends TName, TNameInner extends number | string = string>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner>;
1495
+ readonly withDefault: <Kind extends FieldKind, Types extends ImplicitAllowedTypes, TCustomMetadata = unknown>(fieldSchema: FieldSchema<Kind, Types, TCustomMetadata>, defaultValue: NodeProvider<ApplyKindInput_2<InsertableTreeNodeFromImplicitAllowedTypes_2<Types>, Kind, true>>) => FieldSchemaAlpha<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1496
+ defaultProvider: DefaultProvider;
1497
+ }>;
1498
+ static readonly withDefault: <Kind extends FieldKind, Types extends ImplicitAllowedTypes, TCustomMetadata = unknown>(fieldSchema: FieldSchema<Kind, Types, TCustomMetadata>, defaultValue: NodeProvider<ApplyKindInput_2<InsertableTreeNodeFromImplicitAllowedTypes_2<Types>, Kind, true>>) => FieldSchemaAlpha<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1499
+ defaultProvider: DefaultProvider;
1500
+ }>;
1501
+ readonly withDefaultRecursive: <Kind extends FieldKind, Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, TCustomMetadata = unknown>(fieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>, defaultValue: unknown) => FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1502
+ defaultProvider: DefaultProvider;
1503
+ }>;
1504
+ static readonly withDefaultRecursive: <Kind extends FieldKind, Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, TCustomMetadata = unknown>(fieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>, defaultValue: unknown) => FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1505
+ defaultProvider: DefaultProvider;
1506
+ }>;
1418
1507
  }
1419
1508
 
1420
1509
  // @beta
@@ -1458,6 +1547,16 @@ export interface SchemaStatics {
1458
1547
  readonly string: LeafSchema<"string", string>;
1459
1548
  }
1460
1549
 
1550
+ // @alpha @sealed @system
1551
+ export interface SchemaStaticsAlpha {
1552
+ readonly withDefault: <Kind extends FieldKind, Types extends ImplicitAllowedTypes, TCustomMetadata = unknown>(fieldSchema: FieldSchema<Kind, Types, TCustomMetadata>, defaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>) => FieldSchemaAlpha<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1553
+ defaultProvider: DefaultProvider;
1554
+ }>;
1555
+ withDefaultRecursive: <Kind extends FieldKind, Types extends System_Unsafe.ImplicitAllowedTypesUnsafe, TCustomMetadata = unknown>(fieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>, defaultValue: Unenforced<NodeProvider<System_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<System_Unsafe.FieldSchemaUnsafe<Kind, Types>>>>) => FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
1556
+ defaultProvider: DefaultProvider;
1557
+ }>;
1558
+ }
1559
+
1461
1560
  // @beta @sealed @system
1462
1561
  export interface SchemaStaticsBeta {
1463
1562
  readonly staged: <const T extends LazyItem<TreeNodeSchema>>(t: T | AnnotatedAllowedType<T>) => AnnotatedAllowedType<T>;
@@ -1936,6 +2035,7 @@ export interface TreeAlpha {
1936
2035
  importConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: ConciseTree | undefined): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
1937
2036
  importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: TreeParsingOptions): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
1938
2037
  key2(node: TreeNode): string | number | undefined;
2038
+ on<K extends keyof TreeChangeEventsAlpha<TNode>, TNode extends TreeNode>(node: TNode, eventName: K, listener: NoInfer<TreeChangeEventsAlpha<TNode>[K]>): () => void;
1939
2039
  tagContentSchema<TSchema extends TreeNodeSchema, TContent extends InsertableField<TSchema>>(schema: TSchema, content: TContent): TContent;
1940
2040
  trackObservations<TResult>(onInvalidation: () => void, trackDuring: () => TResult): ObservationResults<TResult>;
1941
2041
  trackObservationsOnce<TResult>(onInvalidation: () => void, trackDuring: () => TResult): ObservationResults<TResult>;
@@ -1972,6 +2072,11 @@ export const TreeArrayNode: {
1972
2072
  readonly spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>;
1973
2073
  };
1974
2074
 
2075
+ // @alpha @sealed
2076
+ export interface TreeArrayNodeAlpha<TAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe = ImplicitAllowedTypes, out T = [TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, in TNew = [TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>> extends TreeArrayNode<TAllowedTypes, T, TNew> {
2077
+ splice(start: number, deleteCount?: number, ...items: readonly (TNew | IterableTreeArrayContent<TNew>)[]): T[];
2078
+ }
2079
+
1975
2080
  // @beta @sealed
1976
2081
  export interface TreeBeta {
1977
2082
  clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
@@ -2007,14 +2112,8 @@ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
2007
2112
  }
2008
2113
 
2009
2114
  // @alpha @sealed
2010
- export interface TreeBranchEvents extends Omit<TreeViewEvents, "commitApplied"> {
2115
+ export interface TreeBranchEvents {
2011
2116
  changed(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;
2012
- commitApplied(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;
2013
- }
2014
-
2015
- // @alpha @sealed
2016
- export interface TreeBranchFork extends BranchableTree, IDisposable {
2017
- rebaseOnto(branch: BranchableTree): void;
2018
2117
  }
2019
2118
 
2020
2119
  // @public @sealed
@@ -2023,6 +2122,11 @@ export interface TreeChangeEvents {
2023
2122
  treeChanged(): void;
2024
2123
  }
2025
2124
 
2125
+ // @alpha @sealed
2126
+ export interface TreeChangeEventsAlpha<TNode extends TreeNode = TreeNode> extends TreeChangeEvents {
2127
+ nodeChanged: (data: NodeChangedDataAlpha<TNode>) => void;
2128
+ }
2129
+
2026
2130
  // @beta @sealed
2027
2131
  export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode> extends TreeChangeEvents {
2028
2132
  nodeChanged: (data: NodeChangedData<TNode> & (TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record> ? Required<Pick<NodeChangedData<TNode>, "changedProperties">> : unknown)) => void;
package/beta.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/beta.js";
package/dist/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 --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  /**
@@ -198,19 +198,28 @@ export {
198
198
  // #region @alpha APIs
199
199
  AllowedTypesFullUnsafe,
200
200
  ArrayNodeCustomizableSchema,
201
+ ArrayNodeCustomizableSchemaAlpha,
201
202
  ArrayNodeCustomizableSchemaUnsafe,
203
+ ArrayNodeDeltaOp,
204
+ ArrayNodeInsertOp,
202
205
  ArrayNodePojoEmulationSchema,
206
+ ArrayNodeRemoveOp,
207
+ ArrayNodeRetainOp,
203
208
  ArrayNodeSchema,
204
209
  ArrayPlaceAnchor,
205
- BranchableTree,
206
210
  ChangeMetadata,
207
211
  CodecName,
208
212
  CodecWriteOptions,
209
213
  CreateIndependentTreeAlphaOptions,
210
214
  DirtyTreeMap,
211
215
  DirtyTreeStatus,
216
+ ErasedNode,
217
+ ErasedSchema,
218
+ ErasedSchemaSubclassable,
212
219
  FactoryContent,
213
220
  FactoryContentObject,
221
+ FieldHasDefaultAlpha,
222
+ FieldHasDefaultAlphaUnsafe,
214
223
  FieldPropsAlpha,
215
224
  FieldSchemaAlpha,
216
225
  FieldSchemaAlphaUnsafe,
@@ -228,6 +237,8 @@ export {
228
237
  Insertable,
229
238
  InsertableContent,
230
239
  InsertableField,
240
+ InsertableObjectFromSchemaRecordAlpha,
241
+ InsertableObjectFromSchemaRecordAlphaUnsafe,
231
242
  JsonArrayNodeSchema,
232
243
  JsonAsTree,
233
244
  JsonCompatibleReadOnly,
@@ -253,8 +264,13 @@ export {
253
264
  MapNodePojoEmulationSchema,
254
265
  MapNodeSchema,
255
266
  NoChangeConstraint,
267
+ NodeChangedDataAlpha,
268
+ NodeChangedDataDelta,
269
+ NodeChangedDataProperties,
270
+ NodeProvider,
256
271
  NodeSchemaOptionsAlpha,
257
272
  ObjectNodeSchema,
273
+ ObjectNodeSchemaWorkaround,
258
274
  ObjectSchemaOptionsAlpha,
259
275
  ObservationResults,
260
276
  ReadSchema,
@@ -267,6 +283,7 @@ export {
267
283
  RevertibleAlphaFactory,
268
284
  RunTransactionParams,
269
285
  SchemaFactoryAlpha,
286
+ SchemaStaticsAlpha,
270
287
  SchemaType,
271
288
  SharedTreeFormatOptions,
272
289
  SharedTreeOptions,
@@ -290,9 +307,10 @@ export {
290
307
  TransactionResultFailed,
291
308
  TransactionResultSuccess,
292
309
  TreeAlpha,
310
+ TreeArrayNodeAlpha,
293
311
  TreeBranchAlpha,
294
312
  TreeBranchEvents,
295
- TreeBranchFork,
313
+ TreeChangeEventsAlpha,
296
314
  TreeCompressionStrategy,
297
315
  TreeContextAlpha,
298
316
  TreeIdentifierUtils,
@@ -332,7 +350,6 @@ export {
332
350
  exportCompatibilitySchemaSnapshot,
333
351
  extractPersistedSchema,
334
352
  generateSchemaFromSimpleSchema,
335
- getBranch,
336
353
  getJsonSchema,
337
354
  getSimpleSchema,
338
355
  importCompatibilitySchemaSnapshot,
package/dist/beta.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 --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  /**
package/dist/legacy.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 --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  /**
package/dist/public.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 --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  /**
package/legacy.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/legacy.js";
package/lib/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
  /**
@@ -198,19 +198,28 @@ export {
198
198
  // #region @alpha APIs
199
199
  AllowedTypesFullUnsafe,
200
200
  ArrayNodeCustomizableSchema,
201
+ ArrayNodeCustomizableSchemaAlpha,
201
202
  ArrayNodeCustomizableSchemaUnsafe,
203
+ ArrayNodeDeltaOp,
204
+ ArrayNodeInsertOp,
202
205
  ArrayNodePojoEmulationSchema,
206
+ ArrayNodeRemoveOp,
207
+ ArrayNodeRetainOp,
203
208
  ArrayNodeSchema,
204
209
  ArrayPlaceAnchor,
205
- BranchableTree,
206
210
  ChangeMetadata,
207
211
  CodecName,
208
212
  CodecWriteOptions,
209
213
  CreateIndependentTreeAlphaOptions,
210
214
  DirtyTreeMap,
211
215
  DirtyTreeStatus,
216
+ ErasedNode,
217
+ ErasedSchema,
218
+ ErasedSchemaSubclassable,
212
219
  FactoryContent,
213
220
  FactoryContentObject,
221
+ FieldHasDefaultAlpha,
222
+ FieldHasDefaultAlphaUnsafe,
214
223
  FieldPropsAlpha,
215
224
  FieldSchemaAlpha,
216
225
  FieldSchemaAlphaUnsafe,
@@ -228,6 +237,8 @@ export {
228
237
  Insertable,
229
238
  InsertableContent,
230
239
  InsertableField,
240
+ InsertableObjectFromSchemaRecordAlpha,
241
+ InsertableObjectFromSchemaRecordAlphaUnsafe,
231
242
  JsonArrayNodeSchema,
232
243
  JsonAsTree,
233
244
  JsonCompatibleReadOnly,
@@ -253,8 +264,13 @@ export {
253
264
  MapNodePojoEmulationSchema,
254
265
  MapNodeSchema,
255
266
  NoChangeConstraint,
267
+ NodeChangedDataAlpha,
268
+ NodeChangedDataDelta,
269
+ NodeChangedDataProperties,
270
+ NodeProvider,
256
271
  NodeSchemaOptionsAlpha,
257
272
  ObjectNodeSchema,
273
+ ObjectNodeSchemaWorkaround,
258
274
  ObjectSchemaOptionsAlpha,
259
275
  ObservationResults,
260
276
  ReadSchema,
@@ -267,6 +283,7 @@ export {
267
283
  RevertibleAlphaFactory,
268
284
  RunTransactionParams,
269
285
  SchemaFactoryAlpha,
286
+ SchemaStaticsAlpha,
270
287
  SchemaType,
271
288
  SharedTreeFormatOptions,
272
289
  SharedTreeOptions,
@@ -290,9 +307,10 @@ export {
290
307
  TransactionResultFailed,
291
308
  TransactionResultSuccess,
292
309
  TreeAlpha,
310
+ TreeArrayNodeAlpha,
293
311
  TreeBranchAlpha,
294
312
  TreeBranchEvents,
295
- TreeBranchFork,
313
+ TreeChangeEventsAlpha,
296
314
  TreeCompressionStrategy,
297
315
  TreeContextAlpha,
298
316
  TreeIdentifierUtils,
@@ -332,7 +350,6 @@ export {
332
350
  exportCompatibilitySchemaSnapshot,
333
351
  extractPersistedSchema,
334
352
  generateSchemaFromSimpleSchema,
335
- getBranch,
336
353
  getJsonSchema,
337
354
  getSimpleSchema,
338
355
  importCompatibilitySchemaSnapshot,
package/lib/beta.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
  /**
package/lib/legacy.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
  /**
package/lib/public.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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-framework",
3
- "version": "2.90.0",
3
+ "version": "2.92.0",
4
4
  "description": "The main entry point into Fluid Framework public packages",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -57,25 +57,25 @@
57
57
  "main": "lib/index.js",
58
58
  "types": "lib/public.d.ts",
59
59
  "dependencies": {
60
- "@fluidframework/container-definitions": "~2.90.0",
61
- "@fluidframework/container-loader": "~2.90.0",
62
- "@fluidframework/core-interfaces": "~2.90.0",
63
- "@fluidframework/core-utils": "~2.90.0",
64
- "@fluidframework/driver-definitions": "~2.90.0",
65
- "@fluidframework/fluid-static": "~2.90.0",
66
- "@fluidframework/map": "~2.90.0",
67
- "@fluidframework/runtime-utils": "~2.90.0",
68
- "@fluidframework/sequence": "~2.90.0",
69
- "@fluidframework/shared-object-base": "~2.90.0",
70
- "@fluidframework/tree": "~2.90.0"
60
+ "@fluidframework/container-definitions": "~2.92.0",
61
+ "@fluidframework/container-loader": "~2.92.0",
62
+ "@fluidframework/core-interfaces": "~2.92.0",
63
+ "@fluidframework/core-utils": "~2.92.0",
64
+ "@fluidframework/driver-definitions": "~2.92.0",
65
+ "@fluidframework/fluid-static": "~2.92.0",
66
+ "@fluidframework/map": "~2.92.0",
67
+ "@fluidframework/runtime-utils": "~2.92.0",
68
+ "@fluidframework/sequence": "~2.92.0",
69
+ "@fluidframework/shared-object-base": "~2.92.0",
70
+ "@fluidframework/tree": "~2.92.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@arethetypeswrong/cli": "^0.18.2",
74
- "@biomejs/biome": "~1.9.3",
75
- "@fluid-tools/build-cli": "^0.63.0",
74
+ "@biomejs/biome": "~2.4.5",
75
+ "@fluid-tools/build-cli": "^0.64.0",
76
76
  "@fluidframework/build-common": "^2.0.3",
77
- "@fluidframework/build-tools": "^0.63.0",
78
- "@fluidframework/eslint-config-fluid": "~2.90.0",
77
+ "@fluidframework/build-tools": "^0.64.0",
78
+ "@fluidframework/eslint-config-fluid": "^9.0.0",
79
79
  "@microsoft/api-extractor": "7.52.11",
80
80
  "@types/node": "~20.19.30",
81
81
  "concurrently": "^9.2.1",
@@ -85,24 +85,9 @@
85
85
  "rimraf": "^6.1.3",
86
86
  "typescript": "~5.4.5"
87
87
  },
88
- "fluidBuild": {
89
- "tasks": {
90
- "build:esnext": [
91
- "...",
92
- "typetests:gen"
93
- ],
94
- "tsc": [
95
- "...",
96
- "typetests:gen"
97
- ]
98
- }
99
- },
100
- "typeValidation": {
101
- "disabled": true
102
- },
103
88
  "scripts": {
104
89
  "api": "fluid-build . --task api",
105
- "api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
90
+ "api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
106
91
  "api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
107
92
  "build": "fluid-build . --task build",
108
93
  "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
@@ -136,8 +121,6 @@
136
121
  "format:biome": "biome check . --write",
137
122
  "lint": "fluid-build . --task lint",
138
123
  "lint:fix": "fluid-build . --task eslint:fix --task format",
139
- "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
140
- "typetests:gen": "flub generate typetests --dir . -v",
141
- "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
124
+ "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist"
142
125
  }
143
126
  }