fluid-framework 2.0.0-dev-rc.3.0.0.250606 → 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.
@@ -22,9 +22,6 @@ export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
22
22
  // @public
23
23
  export type ApplyKind<T, Kind extends FieldKind> = Kind extends FieldKind.Required ? T : undefined | T;
24
24
 
25
- // @public
26
- export type ArrayToUnion<T extends readonly unknown[]> = T[number];
27
-
28
25
  // @public
29
26
  export enum AttachState {
30
27
  Attached = "Attached",
@@ -41,8 +38,8 @@ export enum CommitKind {
41
38
 
42
39
  // @public
43
40
  export interface CommitMetadata {
44
- isLocal: boolean;
45
- kind: CommitKind;
41
+ readonly isLocal: boolean;
42
+ readonly kind: CommitKind;
46
43
  }
47
44
 
48
45
  // @public
@@ -89,7 +86,7 @@ export interface ContainerSchema {
89
86
  // @public
90
87
  export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
91
88
  readonly factory: {
92
- IFluidDataStoreFactory: DataObjectClass<T>["factory"];
89
+ readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"];
93
90
  };
94
91
  } & (new (...args: any[]) => T);
95
92
 
@@ -131,17 +128,26 @@ export type ExtractItemType<Item extends LazyItem> = Item extends () => infer Re
131
128
 
132
129
  // @public
133
130
  export enum FieldKind {
131
+ Identifier = 2,
134
132
  Optional = 0,
135
133
  Required = 1
136
134
  }
137
135
 
136
+ // @public
137
+ export interface FieldProps {
138
+ readonly key?: string;
139
+ }
140
+
138
141
  // @public @sealed
139
142
  export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
140
- constructor(kind: Kind, allowedTypes: Types);
141
- // (undocumented)
143
+ constructor(
144
+ kind: Kind,
145
+ allowedTypes: Types,
146
+ props?: FieldProps | undefined);
142
147
  readonly allowedTypes: Types;
143
- // (undocumented)
148
+ get allowedTypeSet(): ReadonlySet<TreeNodeSchema>;
144
149
  readonly kind: Kind;
150
+ readonly props?: FieldProps | undefined;
145
151
  protected _typeCheck?: MakeNominal;
146
152
  }
147
153
 
@@ -149,12 +155,12 @@ export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types exten
149
155
  export type FlexList<Item = unknown> = readonly LazyItem<Item>[];
150
156
 
151
157
  // @public
152
- export type FlexListToUnion<TList extends FlexList> = ExtractItemType<ArrayToUnion<TList>>;
158
+ export type FlexListToUnion<TList extends FlexList> = ExtractItemType<TList[number]>;
153
159
 
154
160
  // @public
155
161
  export interface IConnection {
156
- id: string;
157
- mode: "write" | "read";
162
+ readonly id: string;
163
+ readonly mode: "write" | "read";
158
164
  }
159
165
 
160
166
  // @public
@@ -190,8 +196,8 @@ export interface IFluidContainerEvents extends IEvent {
190
196
 
191
197
  // @public
192
198
  export interface IMember {
193
- connections: IConnection[];
194
- userId: string;
199
+ readonly connections: IConnection[];
200
+ readonly userId: string;
195
201
  }
196
202
 
197
203
  // @public
@@ -223,7 +229,7 @@ export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
223
229
 
224
230
  // @public
225
231
  export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
226
- getMembers(): Map<string, M>;
232
+ getMembers(): ReadonlyMap<string, M>;
227
233
  getMyself(): Myself<M> | undefined;
228
234
  }
229
235
 
@@ -264,13 +270,13 @@ export class IterableTreeArrayContent<T> implements Iterable<T> {
264
270
 
265
271
  // @public
266
272
  export interface ITree extends IChannel {
267
- schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TreeFieldFromImplicitField<TRoot>>;
273
+ schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
268
274
  }
269
275
 
270
276
  // @public @sealed
271
277
  export interface IValueChanged {
272
- key: string;
273
- previousValue: any;
278
+ readonly key: string;
279
+ readonly previousValue: any;
274
280
  }
275
281
 
276
282
  // @public
@@ -291,7 +297,7 @@ export type MemberChangedListener<M extends IMember> = (clientId: string, member
291
297
 
292
298
  // @public
293
299
  export type Myself<M extends IMember = IMember> = M & {
294
- currentConnection: string;
300
+ readonly currentConnection: string;
295
301
  };
296
302
 
297
303
  // @public
@@ -320,11 +326,15 @@ export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
320
326
 
321
327
  // @public
322
328
  export interface Revertible {
323
- release(): void;
329
+ [disposeSymbol](): void;
324
330
  revert(): void;
331
+ revert(dispose: boolean): void;
325
332
  readonly status: RevertibleStatus;
326
333
  }
327
334
 
335
+ // @public
336
+ export type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
337
+
328
338
  // @public
329
339
  export enum RevertibleStatus {
330
340
  Disposed = 1,
@@ -339,15 +349,17 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
339
349
  readonly boolean: TreeNodeSchema<"com.fluidframework.leaf.boolean", NodeKind.Leaf, boolean, boolean>;
340
350
  // @deprecated
341
351
  fixRecursiveReference<T extends AllowedTypes>(...types: T): void;
342
- readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject & IFluidLoadable>, IFluidHandle<FluidObject & IFluidLoadable>>;
352
+ readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject<unknown> & IFluidLoadable>, IFluidHandle<FluidObject<unknown> & IFluidLoadable>>;
353
+ get identifier(): FieldSchema<FieldKind.Identifier>;
343
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>;
344
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>;
345
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>;
346
357
  namedMap_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.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, ImplicitlyConstructable, T>;
347
358
  readonly null: TreeNodeSchema<"com.fluidframework.leaf.null", NodeKind.Leaf, null, null>;
348
359
  readonly number: TreeNodeSchema<"com.fluidframework.leaf.number", NodeKind.Leaf, number, number>;
349
- object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, t: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeNode & ObjectFromSchemaRecord<T> & WithType<ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
350
- optional<const T extends ImplicitAllowedTypes>(t: T): FieldSchema<FieldKind.Optional, T>;
360
+ object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, fields: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
361
+ optional<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Optional, T>;
362
+ required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
351
363
  // (undocumented)
352
364
  readonly scope: TScope;
353
365
  readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
@@ -375,8 +387,9 @@ export const Tree: TreeApi;
375
387
 
376
388
  // @public
377
389
  export interface TreeApi extends TreeNodeApi {
390
+ contains(node: TreeNode, other: TreeNode): boolean;
378
391
  runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback"): void;
379
- runTransaction<TRoot>(tree: TreeView<TRoot>, transaction: (root: TRoot) => void | "rollback"): void;
392
+ runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
380
393
  }
381
394
 
382
395
  // @public
@@ -409,6 +422,12 @@ export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends Readonl
409
422
  removeRange(start?: number, end?: number): void;
410
423
  }
411
424
 
425
+ // @public
426
+ export interface TreeChangeEvents {
427
+ nodeChanged(): void;
428
+ treeChanged(): void;
429
+ }
430
+
412
431
  // @public
413
432
  export class TreeConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {
414
433
  constructor(schema: TSchema, initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>);
@@ -439,17 +458,13 @@ export abstract class TreeNode implements WithType {
439
458
  export interface TreeNodeApi {
440
459
  is<TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema): value is NodeFromSchema<TSchema>;
441
460
  key(node: TreeNode): string | number;
442
- on<K extends keyof TreeNodeEvents>(node: TreeNode, eventName: K, listener: TreeNodeEvents[K]): () => void;
461
+ on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
443
462
  parent(node: TreeNode): TreeNode | undefined;
444
463
  schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
464
+ shortId(node: TreeNode): number | undefined;
445
465
  readonly status: (node: TreeNode) => TreeStatus;
446
466
  }
447
467
 
448
- // @public
449
- export interface TreeNodeEvents {
450
- afterChange(): void;
451
- }
452
-
453
468
  // @public
454
469
  export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
455
470
 
@@ -478,6 +493,9 @@ export interface TreeNodeSchemaNonClass<out Name extends string = string, out Ki
478
493
  create(data: TInsertable): TNode;
479
494
  }
480
495
 
496
+ // @public
497
+ export type TreeObjectNode<T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName>;
498
+
481
499
  // @public
482
500
  export enum TreeStatus {
483
501
  Deleted = 2,
@@ -486,18 +504,18 @@ export enum TreeStatus {
486
504
  }
487
505
 
488
506
  // @public
489
- export interface TreeView<in out TRoot> extends IDisposable {
507
+ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
490
508
  readonly error?: SchemaIncompatible;
491
509
  readonly events: ISubscribable<TreeViewEvents>;
492
- readonly root: TRoot;
510
+ get root(): TreeFieldFromImplicitField<TSchema>;
511
+ set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
493
512
  upgradeSchema(): void;
494
513
  }
495
514
 
496
515
  // @public
497
516
  export interface TreeViewEvents {
498
517
  afterBatch(): void;
499
- commitApplied(data: CommitMetadata, getRevertible?: () => Revertible): void;
500
- revertibleDisposed(revertible: Revertible): void;
518
+ commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
501
519
  rootChanged(): void;
502
520
  }
503
521