@fluidframework/map 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.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 +44 -0
- package/api-report/map.api.md +17 -158
- package/dist/directory.d.ts +7 -51
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +39 -107
- package/dist/directory.js.map +1 -1
- package/dist/directoryFactory.d.ts +54 -0
- package/dist/directoryFactory.d.ts.map +1 -0
- package/dist/directoryFactory.js +91 -0
- package/dist/directoryFactory.js.map +1 -0
- package/dist/index.d.ts +3 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -55
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +7 -57
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts +50 -1
- package/dist/internalInterfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.js.map +1 -1
- package/dist/legacy.d.ts +25 -0
- package/dist/localValues.d.ts +1 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +6 -6
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +4 -36
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +9 -60
- package/dist/map.js.map +1 -1
- package/dist/mapFactory.d.ts +52 -0
- package/dist/mapFactory.d.ts.map +1 -0
- package/dist/mapFactory.js +71 -0
- package/dist/mapFactory.js.map +1 -0
- package/dist/mapKernel.d.ts +3 -3
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +14 -14
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +12 -0
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/directory.d.ts +7 -51
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +6 -73
- package/lib/directory.js.map +1 -1
- package/lib/directoryFactory.d.ts +54 -0
- package/lib/directoryFactory.d.ts.map +1 -0
- package/lib/directoryFactory.js +87 -0
- package/lib/directoryFactory.js.map +1 -0
- package/lib/index.d.ts +3 -45
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -50
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +7 -57
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts +50 -1
- package/lib/internalInterfaces.d.ts.map +1 -1
- package/lib/internalInterfaces.js.map +1 -1
- package/lib/legacy.d.ts +25 -0
- package/lib/localValues.d.ts +1 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +4 -36
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +4 -54
- package/lib/map.js.map +1 -1
- package/lib/mapFactory.d.ts +52 -0
- package/lib/mapFactory.d.ts.map +1 -0
- package/lib/mapFactory.js +67 -0
- package/lib/mapFactory.js.map +1 -0
- package/lib/mapKernel.d.ts +3 -3
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +2 -2
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +12 -0
- package/package.json +105 -59
- package/src/directory.ts +16 -100
- package/src/directoryFactory.ts +120 -0
- package/src/index.ts +2 -73
- package/src/interfaces.ts +7 -62
- package/src/internalInterfaces.ts +55 -2
- package/src/localValues.ts +6 -5
- package/src/map.ts +8 -71
- package/src/mapFactory.ts +101 -0
- package/src/mapKernel.ts +13 -9
- package/src/packageVersion.ts +1 -1
- package/api-extractor-cjs.json +0 -8
- package/dist/map-alpha.d.ts +0 -898
- package/dist/map-beta.d.ts +0 -195
- package/dist/map-public.d.ts +0 -195
- package/dist/map-untrimmed.d.ts +0 -912
- package/lib/map-alpha.d.ts +0 -898
- package/lib/map-beta.d.ts +0 -195
- package/lib/map-public.d.ts +0 -195
- package/lib/map-untrimmed.d.ts +0 -912
- package/lib/test/memory/directory.spec.js +0 -71
- package/lib/test/memory/directory.spec.js.map +0 -1
- package/lib/test/memory/map.spec.js +0 -71
- package/lib/test/memory/map.spec.js.map +0 -1
- package/lib/test/mocha/directory.order.spec.js +0 -422
- package/lib/test/mocha/directory.order.spec.js.map +0 -1
- package/lib/test/mocha/directory.snapshot.spec.js +0 -111
- package/lib/test/mocha/directory.snapshot.spec.js.map +0 -1
- package/lib/test/mocha/directory.spec.js +0 -1406
- package/lib/test/mocha/directory.spec.js.map +0 -1
- package/lib/test/mocha/directoryEquivalenceUtils.js +0 -36
- package/lib/test/mocha/directoryEquivalenceUtils.js.map +0 -1
- package/lib/test/mocha/directoryFuzzTests.spec.js +0 -337
- package/lib/test/mocha/directoryFuzzTests.spec.js.map +0 -1
- package/lib/test/mocha/dirname.cjs +0 -16
- package/lib/test/mocha/dirname.cjs.map +0 -1
- package/lib/test/mocha/map.fuzz.spec.js +0 -114
- package/lib/test/mocha/map.fuzz.spec.js.map +0 -1
- package/lib/test/mocha/map.spec.js +0 -685
- package/lib/test/mocha/map.spec.js.map +0 -1
- package/lib/test/mocha/rebasing.spec.js +0 -158
- package/lib/test/mocha/rebasing.spec.js.map +0 -1
- package/lib/test/mocha/reconnection.spec.js +0 -327
- package/lib/test/mocha/reconnection.spec.js.map +0 -1
- package/lib/test/types/validateMapPrevious.generated.js +0 -66
- package/lib/test/types/validateMapPrevious.generated.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/src/directory.ts
CHANGED
|
@@ -3,41 +3,38 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
7
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
8
|
-
import {
|
|
9
|
-
import { readAndParse } from "@fluidframework/driver-utils";
|
|
10
|
-
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
11
8
|
import {
|
|
12
9
|
IChannelAttributes,
|
|
13
|
-
IFluidDataStoreRuntime,
|
|
14
10
|
IChannelStorageService,
|
|
15
|
-
|
|
16
|
-
IChannelFactory,
|
|
11
|
+
IFluidDataStoreRuntime,
|
|
17
12
|
} from "@fluidframework/datastore-definitions";
|
|
13
|
+
import { readAndParse } from "@fluidframework/driver-utils/internal";
|
|
14
|
+
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
|
|
15
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
18
16
|
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "@fluidframework/shared-object-base";
|
|
25
|
-
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
17
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
|
|
18
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
19
|
+
import { SharedObject, ValueType, parseHandles } from "@fluidframework/shared-object-base/internal";
|
|
20
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
21
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
26
22
|
import path from "path-browserify";
|
|
27
|
-
|
|
23
|
+
|
|
28
24
|
import {
|
|
29
25
|
IDirectory,
|
|
30
26
|
IDirectoryEvents,
|
|
31
27
|
IDirectoryValueChanged,
|
|
32
|
-
// eslint-disable-next-line import/no-deprecated
|
|
33
|
-
ISerializableValue,
|
|
34
|
-
ISerializedValue,
|
|
35
28
|
ISharedDirectory,
|
|
36
29
|
ISharedDirectoryEvents,
|
|
37
30
|
IValueChanged,
|
|
38
31
|
} from "./interfaces.js";
|
|
32
|
+
import {
|
|
33
|
+
// eslint-disable-next-line import/no-deprecated
|
|
34
|
+
ISerializableValue,
|
|
35
|
+
ISerializedValue,
|
|
36
|
+
} from "./internalInterfaces.js";
|
|
39
37
|
import { ILocalValue, LocalValueMaker, makeSerializable } from "./localValues.js";
|
|
40
|
-
import { pkgVersion } from "./packageVersion.js";
|
|
41
38
|
|
|
42
39
|
// We use path-browserify since this code can run safely on the server or the browser.
|
|
43
40
|
// We standardize on using posix slashes everywhere.
|
|
@@ -268,67 +265,6 @@ export interface IDirectoryNewStorageFormat {
|
|
|
268
265
|
content: IDirectoryDataObject;
|
|
269
266
|
}
|
|
270
267
|
|
|
271
|
-
/**
|
|
272
|
-
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.
|
|
273
|
-
*
|
|
274
|
-
* @sealed
|
|
275
|
-
* @alpha
|
|
276
|
-
*/
|
|
277
|
-
export class DirectoryFactory implements IChannelFactory<ISharedDirectory> {
|
|
278
|
-
/**
|
|
279
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
280
|
-
*/
|
|
281
|
-
public static readonly Type = "https://graph.microsoft.com/types/directory";
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
285
|
-
*/
|
|
286
|
-
public static readonly Attributes: IChannelAttributes = {
|
|
287
|
-
type: DirectoryFactory.Type,
|
|
288
|
-
snapshotFormatVersion: "0.1",
|
|
289
|
-
packageVersion: pkgVersion,
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
294
|
-
*/
|
|
295
|
-
public get type(): string {
|
|
296
|
-
return DirectoryFactory.Type;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
301
|
-
*/
|
|
302
|
-
public get attributes(): IChannelAttributes {
|
|
303
|
-
return DirectoryFactory.Attributes;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
308
|
-
*/
|
|
309
|
-
public async load(
|
|
310
|
-
runtime: IFluidDataStoreRuntime,
|
|
311
|
-
id: string,
|
|
312
|
-
services: IChannelServices,
|
|
313
|
-
attributes: IChannelAttributes,
|
|
314
|
-
): Promise<ISharedDirectory> {
|
|
315
|
-
const directory = new SharedDirectory(id, runtime, attributes);
|
|
316
|
-
await directory.load(services);
|
|
317
|
-
|
|
318
|
-
return directory;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
323
|
-
*/
|
|
324
|
-
public create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory {
|
|
325
|
-
const directory = new SharedDirectory(id, runtime, DirectoryFactory.Attributes);
|
|
326
|
-
directory.initializeLocal();
|
|
327
|
-
|
|
328
|
-
return directory;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
268
|
/**
|
|
333
269
|
* The comparator essentially performs the following procedure to determine the order of subdirectory creation:
|
|
334
270
|
* 1. If subdirectory A has a non-negative 'seq' and subdirectory B has a negative 'seq', subdirectory A is always placed first due to
|
|
@@ -460,26 +396,6 @@ export class SharedDirectory
|
|
|
460
396
|
extends SharedObject<ISharedDirectoryEvents>
|
|
461
397
|
implements ISharedDirectory
|
|
462
398
|
{
|
|
463
|
-
/**
|
|
464
|
-
* Create a new shared directory
|
|
465
|
-
*
|
|
466
|
-
* @param runtime - Data store runtime the new shared directory belongs to
|
|
467
|
-
* @param id - Optional name of the shared directory
|
|
468
|
-
* @returns Newly create shared directory (but not attached yet)
|
|
469
|
-
*/
|
|
470
|
-
public static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedDirectory {
|
|
471
|
-
return runtime.createChannel(id, DirectoryFactory.Type) as ISharedDirectory;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Get a factory for SharedDirectory to register with the data store.
|
|
476
|
-
*
|
|
477
|
-
* @returns A factory that creates and load SharedDirectory
|
|
478
|
-
*/
|
|
479
|
-
public static getFactory(): IChannelFactory<ISharedDirectory> {
|
|
480
|
-
return new DirectoryFactory();
|
|
481
|
-
}
|
|
482
|
-
|
|
483
399
|
/**
|
|
484
400
|
* String representation for the class.
|
|
485
401
|
*/
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IChannelAttributes,
|
|
8
|
+
IChannelFactory,
|
|
9
|
+
IChannelServices,
|
|
10
|
+
IFluidDataStoreRuntime,
|
|
11
|
+
} from "@fluidframework/datastore-definitions";
|
|
12
|
+
import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
|
|
13
|
+
|
|
14
|
+
import { SharedDirectory as SharedDirectoryInternal } from "./directory.js";
|
|
15
|
+
import type { ISharedDirectory } from "./interfaces.js";
|
|
16
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedDirectory}.
|
|
20
|
+
*
|
|
21
|
+
* @sealed
|
|
22
|
+
* @alpha
|
|
23
|
+
*/
|
|
24
|
+
export class DirectoryFactory implements IChannelFactory<ISharedDirectory> {
|
|
25
|
+
/**
|
|
26
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
27
|
+
*/
|
|
28
|
+
public static readonly Type = "https://graph.microsoft.com/types/directory";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
32
|
+
*/
|
|
33
|
+
public static readonly Attributes: IChannelAttributes = {
|
|
34
|
+
type: DirectoryFactory.Type,
|
|
35
|
+
snapshotFormatVersion: "0.1",
|
|
36
|
+
packageVersion: pkgVersion,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
41
|
+
*/
|
|
42
|
+
public get type(): string {
|
|
43
|
+
return DirectoryFactory.Type;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
48
|
+
*/
|
|
49
|
+
public get attributes(): IChannelAttributes {
|
|
50
|
+
return DirectoryFactory.Attributes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
55
|
+
*/
|
|
56
|
+
public async load(
|
|
57
|
+
runtime: IFluidDataStoreRuntime,
|
|
58
|
+
id: string,
|
|
59
|
+
services: IChannelServices,
|
|
60
|
+
attributes: IChannelAttributes,
|
|
61
|
+
): Promise<ISharedDirectory> {
|
|
62
|
+
const directory = new SharedDirectoryInternal(id, runtime, attributes);
|
|
63
|
+
await directory.load(services);
|
|
64
|
+
|
|
65
|
+
return directory;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
70
|
+
*/
|
|
71
|
+
public create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory {
|
|
72
|
+
const directory = new SharedDirectoryInternal(id, runtime, DirectoryFactory.Attributes);
|
|
73
|
+
directory.initializeLocal();
|
|
74
|
+
|
|
75
|
+
return directory;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Entrypoint for {@link ISharedDirectory} creation.
|
|
81
|
+
* @sealed
|
|
82
|
+
* @alpha
|
|
83
|
+
*/
|
|
84
|
+
export const SharedDirectory: ISharedObjectKind<ISharedDirectory> = {
|
|
85
|
+
/**
|
|
86
|
+
* Create a new shared directory
|
|
87
|
+
*
|
|
88
|
+
* @param runtime - Data store runtime the new shared directory belongs to
|
|
89
|
+
* @param id - Optional name of the shared directory
|
|
90
|
+
* @returns Newly create shared directory (but not attached yet)
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* To create a `SharedDirectory`, call the static create method:
|
|
94
|
+
*
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const myDirectory = SharedDirectory.create(this.runtime, id);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
create(runtime: IFluidDataStoreRuntime, id?: string): ISharedDirectory {
|
|
100
|
+
return runtime.createChannel(id, DirectoryFactory.Type) as ISharedDirectory;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get a factory for SharedDirectory to register with the data store.
|
|
105
|
+
*
|
|
106
|
+
* @returns A factory that creates and load SharedDirectory
|
|
107
|
+
*/
|
|
108
|
+
getFactory(): IChannelFactory<ISharedDirectory> {
|
|
109
|
+
return new DirectoryFactory();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Entrypoint for {@link ISharedDirectory} creation.
|
|
115
|
+
* @alpha
|
|
116
|
+
* @deprecated Use ISharedDirectory instead.
|
|
117
|
+
* @privateRemarks
|
|
118
|
+
* This alias is for legacy compat from when the SharedDirectory class was exported as public.
|
|
119
|
+
*/
|
|
120
|
+
export type SharedDirectory = ISharedDirectory;
|
package/src/index.ts
CHANGED
|
@@ -15,86 +15,15 @@
|
|
|
15
15
|
* @packageDocumentation
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
export {
|
|
19
|
-
DirectoryFactory,
|
|
20
|
-
ICreateInfo,
|
|
21
|
-
IDirectoryClearOperation,
|
|
22
|
-
IDirectoryCreateSubDirectoryOperation,
|
|
23
|
-
IDirectoryDataObject,
|
|
24
|
-
IDirectoryDeleteOperation,
|
|
25
|
-
IDirectoryDeleteSubDirectoryOperation,
|
|
26
|
-
IDirectoryKeyOperation,
|
|
27
|
-
IDirectoryNewStorageFormat,
|
|
28
|
-
IDirectoryOperation,
|
|
29
|
-
IDirectorySetOperation,
|
|
30
|
-
IDirectoryStorageOperation,
|
|
31
|
-
IDirectorySubDirectoryOperation,
|
|
32
|
-
SharedDirectory,
|
|
33
|
-
} from "./directory.js";
|
|
34
18
|
export {
|
|
35
19
|
IDirectory,
|
|
36
20
|
IDirectoryEvents,
|
|
37
21
|
IDirectoryValueChanged,
|
|
38
|
-
ISerializableValue,
|
|
39
|
-
ISerializedValue,
|
|
40
22
|
ISharedDirectory,
|
|
41
23
|
ISharedDirectoryEvents,
|
|
42
24
|
ISharedMap,
|
|
43
25
|
ISharedMapEvents,
|
|
44
26
|
IValueChanged,
|
|
45
27
|
} from "./interfaces.js";
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
|
|
49
|
-
import type {
|
|
50
|
-
IChannelFactory,
|
|
51
|
-
IFluidDataStoreRuntime,
|
|
52
|
-
} from "@fluidframework/datastore-definitions";
|
|
53
|
-
import { MapFactory } from "./map.js";
|
|
54
|
-
import { ISharedMap } from "./interfaces.js";
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* {@inheritDoc ISharedMap}
|
|
58
|
-
* @public
|
|
59
|
-
* @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.
|
|
60
|
-
*/
|
|
61
|
-
export const SharedMap = {
|
|
62
|
-
/**
|
|
63
|
-
* Get a factory for SharedMap to register with the data store.
|
|
64
|
-
* @returns A factory that creates SharedMaps and loads them from storage.
|
|
65
|
-
*/
|
|
66
|
-
getFactory(): IChannelFactory<ISharedMap> {
|
|
67
|
-
return new MapFactory();
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Create a new shared map.
|
|
72
|
-
* @param runtime - The data store runtime that the new shared map belongs to.
|
|
73
|
-
* @param id - Optional name of the shared map.
|
|
74
|
-
* @returns Newly created shared map.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* To create a `SharedMap`, call the static create method:
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const myMap = SharedMap.create(this.runtime, id);
|
|
81
|
-
* ```
|
|
82
|
-
* @privateRemarks
|
|
83
|
-
* TODO:
|
|
84
|
-
* Clarify how this differs from `MapFactory.create`.
|
|
85
|
-
* They are different since making this forward to MapFactory.create breaks some things,
|
|
86
|
-
* but the difference is unclear from the documentation.
|
|
87
|
-
*/
|
|
88
|
-
create(runtime: IFluidDataStoreRuntime, id?: string): ISharedMap {
|
|
89
|
-
return runtime.createChannel(id, MapFactory.Type) as ISharedMap;
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* {@inheritDoc ISharedMap}
|
|
95
|
-
* @public
|
|
96
|
-
* @deprecated Use ISharedMap instead.
|
|
97
|
-
* @privateRemarks
|
|
98
|
-
* This alias is for legacy compat from when the SharedMap class was exported as public.
|
|
99
|
-
*/
|
|
100
|
-
export type SharedMap = ISharedMap;
|
|
28
|
+
export { MapFactory, SharedMap } from "./mapFactory.js";
|
|
29
|
+
export { DirectoryFactory, SharedDirectory } from "./directoryFactory.js";
|
package/src/interfaces.ts
CHANGED
|
@@ -3,31 +3,31 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
6
|
import {
|
|
8
7
|
IDisposable,
|
|
9
8
|
IEvent,
|
|
10
9
|
IEventProvider,
|
|
11
10
|
IEventThisPlaceHolder,
|
|
12
11
|
} from "@fluidframework/core-interfaces";
|
|
12
|
+
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Type of "valueChanged" event parameter.
|
|
16
16
|
* @sealed
|
|
17
|
-
* @
|
|
17
|
+
* @alpha
|
|
18
18
|
*/
|
|
19
19
|
export interface IValueChanged {
|
|
20
20
|
/**
|
|
21
21
|
* The key storing the value that changed.
|
|
22
22
|
*/
|
|
23
|
-
key: string;
|
|
23
|
+
readonly key: string;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The value that was stored at the key prior to the change.
|
|
27
27
|
*/
|
|
28
28
|
// TODO: Use `unknown` instead (breaking change).
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
-
previousValue: any;
|
|
30
|
+
readonly previousValue: any;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -196,7 +196,7 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
|
196
196
|
export interface IDirectoryEvents extends IEvent {
|
|
197
197
|
/**
|
|
198
198
|
* Emitted when a key is set or deleted. As opposed to the
|
|
199
|
-
* {@link
|
|
199
|
+
* {@link ISharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly
|
|
200
200
|
* contains the key.
|
|
201
201
|
*
|
|
202
202
|
* @remarks Listener parameters:
|
|
@@ -299,7 +299,7 @@ export interface IDirectoryValueChanged extends IValueChanged {
|
|
|
299
299
|
/**
|
|
300
300
|
* Events emitted in response to changes to the {@link ISharedMap | map} data.
|
|
301
301
|
* @sealed
|
|
302
|
-
* @
|
|
302
|
+
* @alpha
|
|
303
303
|
*/
|
|
304
304
|
export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
305
305
|
/**
|
|
@@ -339,7 +339,7 @@ export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
|
339
339
|
*
|
|
340
340
|
* For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
|
|
341
341
|
* @sealed
|
|
342
|
-
* @
|
|
342
|
+
* @alpha
|
|
343
343
|
*/
|
|
344
344
|
// TODO: Use `unknown` instead (breaking change).
|
|
345
345
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -361,58 +361,3 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
|
|
|
361
361
|
*/
|
|
362
362
|
set<T = unknown>(key: string, value: T): this;
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
|
|
367
|
-
* {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
|
|
368
|
-
* a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
|
|
369
|
-
*
|
|
370
|
-
* @remarks
|
|
371
|
-
*
|
|
372
|
-
* Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with
|
|
373
|
-
* the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
|
|
374
|
-
* JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
|
|
375
|
-
* and ops (set).
|
|
376
|
-
*
|
|
377
|
-
* If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will
|
|
378
|
-
* just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
|
|
379
|
-
* that are ISerializedHandle (the serialized form of a handle).
|
|
380
|
-
*
|
|
381
|
-
* If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
|
|
382
|
-
* to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
|
|
383
|
-
* If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
|
|
384
|
-
* channel ID.
|
|
385
|
-
*
|
|
386
|
-
* @deprecated This type is legacy and deprecated.
|
|
387
|
-
* @alpha
|
|
388
|
-
*/
|
|
389
|
-
export interface ISerializableValue {
|
|
390
|
-
/**
|
|
391
|
-
* A type annotation to help indicate how the value serializes.
|
|
392
|
-
*/
|
|
393
|
-
type: string;
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* The JSONable representation of the value.
|
|
397
|
-
*/
|
|
398
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
399
|
-
value: any;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Serialized {@link ISerializableValue} counterpart.
|
|
404
|
-
* @alpha
|
|
405
|
-
*/
|
|
406
|
-
export interface ISerializedValue {
|
|
407
|
-
/**
|
|
408
|
-
* A type annotation to help indicate how the value serializes.
|
|
409
|
-
*/
|
|
410
|
-
type: string;
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* String representation of the value.
|
|
414
|
-
*
|
|
415
|
-
* @remarks Will be undefined if the original value was undefined.
|
|
416
|
-
*/
|
|
417
|
-
value: string | undefined;
|
|
418
|
-
}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line import/no-deprecated
|
|
7
|
-
import { ISerializableValue } from "./interfaces.js";
|
|
8
6
|
import { ILocalValue } from "./localValues.js";
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -117,3 +115,58 @@ export type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocal
|
|
|
117
115
|
* Metadata for a local operation.
|
|
118
116
|
*/
|
|
119
117
|
export type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
|
|
121
|
+
* {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
|
|
122
|
+
* a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
*
|
|
126
|
+
* Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with
|
|
127
|
+
* the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
|
|
128
|
+
* JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
|
|
129
|
+
* and ops (set).
|
|
130
|
+
*
|
|
131
|
+
* If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will
|
|
132
|
+
* just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
|
|
133
|
+
* that are ISerializedHandle (the serialized form of a handle).
|
|
134
|
+
*
|
|
135
|
+
* If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
|
|
136
|
+
* to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
|
|
137
|
+
* If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
|
|
138
|
+
* channel ID.
|
|
139
|
+
*
|
|
140
|
+
* @deprecated This type is legacy and deprecated.
|
|
141
|
+
* @alpha
|
|
142
|
+
*/
|
|
143
|
+
export interface ISerializableValue {
|
|
144
|
+
/**
|
|
145
|
+
* A type annotation to help indicate how the value serializes.
|
|
146
|
+
*/
|
|
147
|
+
type: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The JSONable representation of the value.
|
|
151
|
+
*/
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
+
value: any;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Serialized {@link ISerializableValue} counterpart.
|
|
158
|
+
* @alpha
|
|
159
|
+
*/
|
|
160
|
+
export interface ISerializedValue {
|
|
161
|
+
/**
|
|
162
|
+
* A type annotation to help indicate how the value serializes.
|
|
163
|
+
*/
|
|
164
|
+
type: string;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* String representation of the value.
|
|
168
|
+
*
|
|
169
|
+
* @remarks Will be undefined if the original value was undefined.
|
|
170
|
+
*/
|
|
171
|
+
value: string | undefined;
|
|
172
|
+
}
|
package/src/localValues.ts
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { ISerializedHandle } from "@fluidframework/runtime-utils/internal";
|
|
8
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
7
9
|
import {
|
|
8
|
-
|
|
10
|
+
ValueType,
|
|
9
11
|
parseHandles,
|
|
10
12
|
serializeHandles,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { ISerializedHandle } from "@fluidframework/runtime-utils";
|
|
13
|
+
} from "@fluidframework/shared-object-base/internal";
|
|
14
|
+
|
|
14
15
|
// eslint-disable-next-line import/no-deprecated
|
|
15
|
-
import { ISerializableValue, ISerializedValue } from "./
|
|
16
|
+
import { ISerializableValue, ISerializedValue } from "./internalInterfaces.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* A local value to be stored in a container type Distributed Data Store (DDS).
|
package/src/map.ts
CHANGED
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
7
6
|
import {
|
|
8
7
|
IChannelAttributes,
|
|
9
|
-
IFluidDataStoreRuntime,
|
|
10
8
|
IChannelStorageService,
|
|
11
|
-
|
|
12
|
-
IChannelFactory,
|
|
9
|
+
IFluidDataStoreRuntime,
|
|
13
10
|
} from "@fluidframework/datastore-definitions";
|
|
11
|
+
import { readAndParse } from "@fluidframework/driver-utils/internal";
|
|
12
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
14
13
|
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
15
|
-
import {
|
|
16
|
-
import { IFluidSerializer
|
|
17
|
-
import {
|
|
14
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
|
|
15
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
16
|
+
import { SharedObject } from "@fluidframework/shared-object-base/internal";
|
|
17
|
+
|
|
18
18
|
import { ISharedMap, ISharedMapEvents } from "./interfaces.js";
|
|
19
19
|
import { IMapDataObjectSerializable, IMapOperation, MapKernel } from "./mapKernel.js";
|
|
20
|
-
import { pkgVersion } from "./packageVersion.js";
|
|
21
20
|
|
|
22
21
|
interface IMapSerializationFormat {
|
|
23
22
|
blobs?: string[];
|
|
@@ -26,71 +25,9 @@ interface IMapSerializationFormat {
|
|
|
26
25
|
|
|
27
26
|
const snapshotFileName = "header";
|
|
28
27
|
|
|
29
|
-
/**
|
|
30
|
-
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMap}.
|
|
31
|
-
*
|
|
32
|
-
* @sealed
|
|
33
|
-
* @alpha
|
|
34
|
-
*/
|
|
35
|
-
export class MapFactory implements IChannelFactory<ISharedMap> {
|
|
36
|
-
/**
|
|
37
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
38
|
-
*/
|
|
39
|
-
public static readonly Type = "https://graph.microsoft.com/types/map";
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
43
|
-
*/
|
|
44
|
-
public static readonly Attributes: IChannelAttributes = {
|
|
45
|
-
type: MapFactory.Type,
|
|
46
|
-
snapshotFormatVersion: "0.2",
|
|
47
|
-
packageVersion: pkgVersion,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
52
|
-
*/
|
|
53
|
-
public get type(): string {
|
|
54
|
-
return MapFactory.Type;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
59
|
-
*/
|
|
60
|
-
public get attributes(): IChannelAttributes {
|
|
61
|
-
return MapFactory.Attributes;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
66
|
-
*/
|
|
67
|
-
public async load(
|
|
68
|
-
runtime: IFluidDataStoreRuntime,
|
|
69
|
-
id: string,
|
|
70
|
-
services: IChannelServices,
|
|
71
|
-
attributes: IChannelAttributes,
|
|
72
|
-
): Promise<ISharedMap> {
|
|
73
|
-
const map = new SharedMap(id, runtime, attributes);
|
|
74
|
-
await map.load(services);
|
|
75
|
-
|
|
76
|
-
return map;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
81
|
-
*/
|
|
82
|
-
public create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap {
|
|
83
|
-
const map = new SharedMap(id, runtime, MapFactory.Attributes);
|
|
84
|
-
map.initializeLocal();
|
|
85
|
-
|
|
86
|
-
return map;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
28
|
/**
|
|
91
29
|
* {@inheritDoc ISharedMap}
|
|
92
|
-
* @
|
|
93
|
-
* @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.
|
|
30
|
+
* @alpha
|
|
94
31
|
*/
|
|
95
32
|
export class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
|
|
96
33
|
/**
|