@fluidframework/map 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
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/.eslintrc.js +12 -11
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +162 -0
- package/README.md +24 -8
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/map.api.md +297 -0
- package/dist/{directory.js → directory.cjs} +749 -228
- package/dist/directory.cjs.map +1 -0
- package/dist/directory.d.ts +567 -34
- package/dist/directory.d.ts.map +1 -1
- package/dist/index.cjs +27 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/{interfaces.js → interfaces.cjs} +1 -1
- package/dist/interfaces.cjs.map +1 -0
- package/dist/interfaces.d.ts +167 -184
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.cjs +7 -0
- package/dist/internalInterfaces.cjs.map +1 -0
- package/dist/internalInterfaces.d.ts +101 -0
- package/dist/internalInterfaces.d.ts.map +1 -0
- package/dist/{localValues.js → localValues.cjs} +15 -3
- package/dist/localValues.cjs.map +1 -0
- package/dist/localValues.d.ts +17 -6
- package/dist/localValues.d.ts.map +1 -1
- package/dist/map-alpha.d.ts +982 -0
- package/dist/map-beta.d.ts +275 -0
- package/dist/map-public.d.ts +275 -0
- package/dist/map-untrimmed.d.ts +996 -0
- package/dist/{map.js → map.cjs} +39 -34
- package/dist/map.cjs.map +1 -0
- package/dist/map.d.ts +10 -17
- package/dist/map.d.ts.map +1 -1
- package/dist/{mapKernel.js → mapKernel.cjs} +122 -79
- package/dist/mapKernel.cjs.map +1 -0
- package/dist/mapKernel.d.ts +17 -48
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/directory.d.mts +902 -0
- package/lib/directory.d.mts.map +1 -0
- package/lib/{directory.js → directory.mjs} +736 -199
- package/lib/directory.mjs.map +1 -0
- package/lib/index.d.mts +9 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +8 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{interfaces.d.ts → interfaces.d.mts} +167 -184
- package/lib/interfaces.d.mts.map +1 -0
- package/lib/{interfaces.js → interfaces.mjs} +1 -1
- package/lib/interfaces.mjs.map +1 -0
- package/lib/internalInterfaces.d.mts +101 -0
- package/lib/internalInterfaces.d.mts.map +1 -0
- package/lib/internalInterfaces.mjs +6 -0
- package/lib/internalInterfaces.mjs.map +1 -0
- package/lib/{localValues.d.ts → localValues.d.mts} +18 -7
- package/lib/localValues.d.mts.map +1 -0
- package/lib/{localValues.js → localValues.mjs} +15 -3
- package/lib/localValues.mjs.map +1 -0
- package/lib/map-alpha.d.mts +982 -0
- package/lib/map-beta.d.mts +275 -0
- package/lib/map-public.d.mts +275 -0
- package/lib/map-untrimmed.d.mts +996 -0
- package/lib/{map.d.ts → map.d.mts} +11 -18
- package/lib/map.d.mts.map +1 -0
- package/lib/{map.js → map.mjs} +40 -35
- package/lib/map.mjs.map +1 -0
- package/lib/{mapKernel.d.ts → mapKernel.d.mts} +18 -49
- package/lib/mapKernel.d.mts.map +1 -0
- package/lib/{mapKernel.js → mapKernel.mjs} +116 -73
- package/lib/mapKernel.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/map.test-files.tar +0 -0
- package/package.json +105 -65
- package/prettier.config.cjs +8 -0
- package/src/directory.ts +2544 -1727
- package/src/index.ts +31 -5
- package/src/interfaces.ts +346 -345
- package/src/internalInterfaces.ts +119 -0
- package/src/localValues.ts +103 -96
- package/src/map.ts +362 -351
- package/src/mapKernel.ts +755 -722
- package/src/packageVersion.ts +1 -1
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -15
- package/dist/directory.js.map +0 -1
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/interfaces.js.map +0 -1
- package/dist/localValues.js.map +0 -1
- package/dist/map.js.map +0 -1
- package/dist/mapKernel.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/lib/directory.d.ts +0 -369
- package/lib/directory.d.ts.map +0 -1
- package/lib/directory.js.map +0 -1
- package/lib/index.d.ts +0 -20
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -20
- package/lib/index.js.map +0 -1
- package/lib/interfaces.d.ts.map +0 -1
- package/lib/interfaces.js.map +0 -1
- package/lib/localValues.d.ts.map +0 -1
- package/lib/localValues.js.map +0 -1
- package/lib/map.d.ts.map +0 -1
- package/lib/map.js.map +0 -1
- package/lib/mapKernel.d.ts.map +0 -1
- package/lib/mapKernel.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `map` library provides interfaces and implementing classes for map-like distributed data structures.
|
|
3
|
+
*
|
|
4
|
+
* @remarks The following distributed data structures are defined in this library:
|
|
5
|
+
*
|
|
6
|
+
* - {@link SharedMap}
|
|
7
|
+
*
|
|
8
|
+
* - {@link SharedDirectory}
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
14
|
+
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
15
|
+
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
16
|
+
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
17
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
18
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
19
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
20
|
+
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
|
|
21
|
+
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
22
|
+
import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
23
|
+
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
24
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
25
|
+
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
26
|
+
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
27
|
+
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
28
|
+
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
|
|
29
|
+
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
30
|
+
|
|
31
|
+
/* Excluded from this release type: DirectoryFactory */
|
|
32
|
+
|
|
33
|
+
/* Excluded from this release type: ICreateInfo */
|
|
34
|
+
|
|
35
|
+
/* Excluded from this release type: IDirectory */
|
|
36
|
+
|
|
37
|
+
/* Excluded from this release type: IDirectoryClearOperation */
|
|
38
|
+
|
|
39
|
+
/* Excluded from this release type: IDirectoryCreateSubDirectoryOperation */
|
|
40
|
+
|
|
41
|
+
/* Excluded from this release type: IDirectoryDataObject */
|
|
42
|
+
|
|
43
|
+
/* Excluded from this release type: IDirectoryDeleteOperation */
|
|
44
|
+
|
|
45
|
+
/* Excluded from this release type: IDirectoryDeleteSubDirectoryOperation */
|
|
46
|
+
|
|
47
|
+
/* Excluded from this release type: IDirectoryEvents */
|
|
48
|
+
|
|
49
|
+
/* Excluded from this release type: IDirectoryKeyOperation */
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: IDirectoryNewStorageFormat */
|
|
52
|
+
|
|
53
|
+
/* Excluded from this release type: IDirectoryOperation */
|
|
54
|
+
|
|
55
|
+
/* Excluded from this release type: IDirectorySetOperation */
|
|
56
|
+
|
|
57
|
+
/* Excluded from this release type: IDirectoryStorageOperation */
|
|
58
|
+
|
|
59
|
+
/* Excluded from this release type: IDirectorySubDirectoryOperation */
|
|
60
|
+
|
|
61
|
+
/* Excluded from this release type: IDirectoryValueChanged */
|
|
62
|
+
|
|
63
|
+
/* Excluded from this release type: ILocalValue */
|
|
64
|
+
|
|
65
|
+
/* Excluded from this release type: ISerializableValue */
|
|
66
|
+
|
|
67
|
+
/* Excluded from this release type: ISerializedValue */
|
|
68
|
+
|
|
69
|
+
/* Excluded from this release type: ISharedDirectory */
|
|
70
|
+
|
|
71
|
+
/* Excluded from this release type: ISharedDirectoryEvents */
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
|
|
75
|
+
* and retrieving values that JavaScript developers are accustomed to with the
|
|
76
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
|
|
77
|
+
* However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
|
|
78
|
+
* {@link @fluidframework/datastore#FluidObjectHandle}.
|
|
79
|
+
*
|
|
80
|
+
* For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
|
|
81
|
+
* @sealed
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export declare interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves the given key from the map if it exists.
|
|
87
|
+
* @param key - Key to retrieve from
|
|
88
|
+
* @returns The stored value, or undefined if the key is not set
|
|
89
|
+
*/
|
|
90
|
+
get<T = any>(key: string): T | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the value stored at key to the provided value.
|
|
93
|
+
* @param key - Key to set
|
|
94
|
+
* @param value - Value to set
|
|
95
|
+
* @returns The {@link ISharedMap} itself
|
|
96
|
+
*/
|
|
97
|
+
set<T = unknown>(key: string, value: T): this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Events emitted in response to changes to the {@link ISharedMap | map} data.
|
|
102
|
+
* @sealed
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare interface ISharedMapEvents extends ISharedObjectEvents {
|
|
106
|
+
/**
|
|
107
|
+
* Emitted when a key is set or deleted.
|
|
108
|
+
*
|
|
109
|
+
* @remarks Listener parameters:
|
|
110
|
+
*
|
|
111
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
112
|
+
*
|
|
113
|
+
* - `local` - Whether the change originated from this client.
|
|
114
|
+
*
|
|
115
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
116
|
+
*/
|
|
117
|
+
(event: "valueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
118
|
+
/**
|
|
119
|
+
* Emitted when the map is cleared.
|
|
120
|
+
*
|
|
121
|
+
* @remarks Listener parameters:
|
|
122
|
+
*
|
|
123
|
+
* - `local` - Whether the clear originated from this client.
|
|
124
|
+
*
|
|
125
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
126
|
+
*/
|
|
127
|
+
(event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Type of "valueChanged" event parameter.
|
|
132
|
+
* @sealed
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare interface IValueChanged {
|
|
136
|
+
/**
|
|
137
|
+
* The key storing the value that changed.
|
|
138
|
+
*/
|
|
139
|
+
key: string;
|
|
140
|
+
/**
|
|
141
|
+
* The value that was stored at the key prior to the change.
|
|
142
|
+
*/
|
|
143
|
+
previousValue: any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Excluded from this release type: LocalValueMaker */
|
|
147
|
+
|
|
148
|
+
/* Excluded from this release type: MapFactory */
|
|
149
|
+
|
|
150
|
+
/* Excluded from this release type: SharedDirectory */
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* {@inheritDoc ISharedMap}
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
|
|
157
|
+
/**
|
|
158
|
+
* Create a new shared map.
|
|
159
|
+
* @param runtime - The data store runtime that the new shared map belongs to.
|
|
160
|
+
* @param id - Optional name of the shared map.
|
|
161
|
+
* @returns Newly created shared map.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* To create a `SharedMap`, call the static create method:
|
|
165
|
+
*
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const myMap = SharedMap.create(this.runtime, id);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
|
|
171
|
+
/**
|
|
172
|
+
* Get a factory for SharedMap to register with the data store.
|
|
173
|
+
* @returns A factory that creates SharedMaps and loads them from storage.
|
|
174
|
+
*/
|
|
175
|
+
static getFactory(): IChannelFactory;
|
|
176
|
+
/**
|
|
177
|
+
* String representation for the class.
|
|
178
|
+
*/
|
|
179
|
+
readonly [Symbol.toStringTag]: string;
|
|
180
|
+
/**
|
|
181
|
+
* MapKernel which manages actual map operations.
|
|
182
|
+
*/
|
|
183
|
+
private readonly kernel;
|
|
184
|
+
/**
|
|
185
|
+
* Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
|
|
186
|
+
*
|
|
187
|
+
* @param id - String identifier.
|
|
188
|
+
* @param runtime - Data store runtime.
|
|
189
|
+
* @param attributes - The attributes for the map.
|
|
190
|
+
*/
|
|
191
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
192
|
+
/**
|
|
193
|
+
* Get an iterator over the keys in this map.
|
|
194
|
+
* @returns The iterator
|
|
195
|
+
*/
|
|
196
|
+
keys(): IterableIterator<string>;
|
|
197
|
+
/**
|
|
198
|
+
* Get an iterator over the entries in this map.
|
|
199
|
+
* @returns The iterator
|
|
200
|
+
*/
|
|
201
|
+
entries(): IterableIterator<[string, any]>;
|
|
202
|
+
/**
|
|
203
|
+
* Get an iterator over the values in this map.
|
|
204
|
+
* @returns The iterator
|
|
205
|
+
*/
|
|
206
|
+
values(): IterableIterator<any>;
|
|
207
|
+
/**
|
|
208
|
+
* Get an iterator over the entries in this map.
|
|
209
|
+
* @returns The iterator
|
|
210
|
+
*/
|
|
211
|
+
[Symbol.iterator](): IterableIterator<[string, any]>;
|
|
212
|
+
/**
|
|
213
|
+
* The number of key/value pairs stored in the map.
|
|
214
|
+
*/
|
|
215
|
+
get size(): number;
|
|
216
|
+
/**
|
|
217
|
+
* Executes the given callback on each entry in the map.
|
|
218
|
+
* @param callbackFn - Callback function
|
|
219
|
+
*/
|
|
220
|
+
forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
|
|
221
|
+
/**
|
|
222
|
+
* {@inheritDoc ISharedMap.get}
|
|
223
|
+
*/
|
|
224
|
+
get<T = any>(key: string): T | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Check if a key exists in the map.
|
|
227
|
+
* @param key - The key to check
|
|
228
|
+
* @returns True if the key exists, false otherwise
|
|
229
|
+
*/
|
|
230
|
+
has(key: string): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* {@inheritDoc ISharedMap.set}
|
|
233
|
+
*/
|
|
234
|
+
set(key: string, value: unknown): this;
|
|
235
|
+
/**
|
|
236
|
+
* Delete a key from the map.
|
|
237
|
+
* @param key - Key to delete
|
|
238
|
+
* @returns True if the key existed and was deleted, false if it did not exist
|
|
239
|
+
*/
|
|
240
|
+
delete(key: string): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Clear all data from the map.
|
|
243
|
+
*/
|
|
244
|
+
clear(): void;
|
|
245
|
+
/**
|
|
246
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
247
|
+
*/
|
|
248
|
+
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
249
|
+
/**
|
|
250
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
251
|
+
*/
|
|
252
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
255
|
+
*/
|
|
256
|
+
protected onDisconnect(): void;
|
|
257
|
+
/**
|
|
258
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
259
|
+
*/
|
|
260
|
+
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
261
|
+
/**
|
|
262
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
263
|
+
*/
|
|
264
|
+
protected applyStashedOp(content: unknown): unknown;
|
|
265
|
+
/**
|
|
266
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
267
|
+
*/
|
|
268
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
269
|
+
/**
|
|
270
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
271
|
+
*/
|
|
272
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export { }
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `map` library provides interfaces and implementing classes for map-like distributed data structures.
|
|
3
|
+
*
|
|
4
|
+
* @remarks The following distributed data structures are defined in this library:
|
|
5
|
+
*
|
|
6
|
+
* - {@link SharedMap}
|
|
7
|
+
*
|
|
8
|
+
* - {@link SharedDirectory}
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
14
|
+
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
15
|
+
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
16
|
+
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
17
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
18
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
19
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
20
|
+
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
|
|
21
|
+
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
22
|
+
import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
23
|
+
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
24
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
25
|
+
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
26
|
+
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
27
|
+
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
28
|
+
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
|
|
29
|
+
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
30
|
+
|
|
31
|
+
/* Excluded from this release type: DirectoryFactory */
|
|
32
|
+
|
|
33
|
+
/* Excluded from this release type: ICreateInfo */
|
|
34
|
+
|
|
35
|
+
/* Excluded from this release type: IDirectory */
|
|
36
|
+
|
|
37
|
+
/* Excluded from this release type: IDirectoryClearOperation */
|
|
38
|
+
|
|
39
|
+
/* Excluded from this release type: IDirectoryCreateSubDirectoryOperation */
|
|
40
|
+
|
|
41
|
+
/* Excluded from this release type: IDirectoryDataObject */
|
|
42
|
+
|
|
43
|
+
/* Excluded from this release type: IDirectoryDeleteOperation */
|
|
44
|
+
|
|
45
|
+
/* Excluded from this release type: IDirectoryDeleteSubDirectoryOperation */
|
|
46
|
+
|
|
47
|
+
/* Excluded from this release type: IDirectoryEvents */
|
|
48
|
+
|
|
49
|
+
/* Excluded from this release type: IDirectoryKeyOperation */
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: IDirectoryNewStorageFormat */
|
|
52
|
+
|
|
53
|
+
/* Excluded from this release type: IDirectoryOperation */
|
|
54
|
+
|
|
55
|
+
/* Excluded from this release type: IDirectorySetOperation */
|
|
56
|
+
|
|
57
|
+
/* Excluded from this release type: IDirectoryStorageOperation */
|
|
58
|
+
|
|
59
|
+
/* Excluded from this release type: IDirectorySubDirectoryOperation */
|
|
60
|
+
|
|
61
|
+
/* Excluded from this release type: IDirectoryValueChanged */
|
|
62
|
+
|
|
63
|
+
/* Excluded from this release type: ILocalValue */
|
|
64
|
+
|
|
65
|
+
/* Excluded from this release type: ISerializableValue */
|
|
66
|
+
|
|
67
|
+
/* Excluded from this release type: ISerializedValue */
|
|
68
|
+
|
|
69
|
+
/* Excluded from this release type: ISharedDirectory */
|
|
70
|
+
|
|
71
|
+
/* Excluded from this release type: ISharedDirectoryEvents */
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
|
|
75
|
+
* and retrieving values that JavaScript developers are accustomed to with the
|
|
76
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
|
|
77
|
+
* However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
|
|
78
|
+
* {@link @fluidframework/datastore#FluidObjectHandle}.
|
|
79
|
+
*
|
|
80
|
+
* For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
|
|
81
|
+
* @sealed
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export declare interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves the given key from the map if it exists.
|
|
87
|
+
* @param key - Key to retrieve from
|
|
88
|
+
* @returns The stored value, or undefined if the key is not set
|
|
89
|
+
*/
|
|
90
|
+
get<T = any>(key: string): T | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the value stored at key to the provided value.
|
|
93
|
+
* @param key - Key to set
|
|
94
|
+
* @param value - Value to set
|
|
95
|
+
* @returns The {@link ISharedMap} itself
|
|
96
|
+
*/
|
|
97
|
+
set<T = unknown>(key: string, value: T): this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Events emitted in response to changes to the {@link ISharedMap | map} data.
|
|
102
|
+
* @sealed
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare interface ISharedMapEvents extends ISharedObjectEvents {
|
|
106
|
+
/**
|
|
107
|
+
* Emitted when a key is set or deleted.
|
|
108
|
+
*
|
|
109
|
+
* @remarks Listener parameters:
|
|
110
|
+
*
|
|
111
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
112
|
+
*
|
|
113
|
+
* - `local` - Whether the change originated from this client.
|
|
114
|
+
*
|
|
115
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
116
|
+
*/
|
|
117
|
+
(event: "valueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
118
|
+
/**
|
|
119
|
+
* Emitted when the map is cleared.
|
|
120
|
+
*
|
|
121
|
+
* @remarks Listener parameters:
|
|
122
|
+
*
|
|
123
|
+
* - `local` - Whether the clear originated from this client.
|
|
124
|
+
*
|
|
125
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
126
|
+
*/
|
|
127
|
+
(event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Type of "valueChanged" event parameter.
|
|
132
|
+
* @sealed
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare interface IValueChanged {
|
|
136
|
+
/**
|
|
137
|
+
* The key storing the value that changed.
|
|
138
|
+
*/
|
|
139
|
+
key: string;
|
|
140
|
+
/**
|
|
141
|
+
* The value that was stored at the key prior to the change.
|
|
142
|
+
*/
|
|
143
|
+
previousValue: any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Excluded from this release type: LocalValueMaker */
|
|
147
|
+
|
|
148
|
+
/* Excluded from this release type: MapFactory */
|
|
149
|
+
|
|
150
|
+
/* Excluded from this release type: SharedDirectory */
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* {@inheritDoc ISharedMap}
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
|
|
157
|
+
/**
|
|
158
|
+
* Create a new shared map.
|
|
159
|
+
* @param runtime - The data store runtime that the new shared map belongs to.
|
|
160
|
+
* @param id - Optional name of the shared map.
|
|
161
|
+
* @returns Newly created shared map.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* To create a `SharedMap`, call the static create method:
|
|
165
|
+
*
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const myMap = SharedMap.create(this.runtime, id);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
|
|
171
|
+
/**
|
|
172
|
+
* Get a factory for SharedMap to register with the data store.
|
|
173
|
+
* @returns A factory that creates SharedMaps and loads them from storage.
|
|
174
|
+
*/
|
|
175
|
+
static getFactory(): IChannelFactory;
|
|
176
|
+
/**
|
|
177
|
+
* String representation for the class.
|
|
178
|
+
*/
|
|
179
|
+
readonly [Symbol.toStringTag]: string;
|
|
180
|
+
/**
|
|
181
|
+
* MapKernel which manages actual map operations.
|
|
182
|
+
*/
|
|
183
|
+
private readonly kernel;
|
|
184
|
+
/**
|
|
185
|
+
* Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
|
|
186
|
+
*
|
|
187
|
+
* @param id - String identifier.
|
|
188
|
+
* @param runtime - Data store runtime.
|
|
189
|
+
* @param attributes - The attributes for the map.
|
|
190
|
+
*/
|
|
191
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
192
|
+
/**
|
|
193
|
+
* Get an iterator over the keys in this map.
|
|
194
|
+
* @returns The iterator
|
|
195
|
+
*/
|
|
196
|
+
keys(): IterableIterator<string>;
|
|
197
|
+
/**
|
|
198
|
+
* Get an iterator over the entries in this map.
|
|
199
|
+
* @returns The iterator
|
|
200
|
+
*/
|
|
201
|
+
entries(): IterableIterator<[string, any]>;
|
|
202
|
+
/**
|
|
203
|
+
* Get an iterator over the values in this map.
|
|
204
|
+
* @returns The iterator
|
|
205
|
+
*/
|
|
206
|
+
values(): IterableIterator<any>;
|
|
207
|
+
/**
|
|
208
|
+
* Get an iterator over the entries in this map.
|
|
209
|
+
* @returns The iterator
|
|
210
|
+
*/
|
|
211
|
+
[Symbol.iterator](): IterableIterator<[string, any]>;
|
|
212
|
+
/**
|
|
213
|
+
* The number of key/value pairs stored in the map.
|
|
214
|
+
*/
|
|
215
|
+
get size(): number;
|
|
216
|
+
/**
|
|
217
|
+
* Executes the given callback on each entry in the map.
|
|
218
|
+
* @param callbackFn - Callback function
|
|
219
|
+
*/
|
|
220
|
+
forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
|
|
221
|
+
/**
|
|
222
|
+
* {@inheritDoc ISharedMap.get}
|
|
223
|
+
*/
|
|
224
|
+
get<T = any>(key: string): T | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Check if a key exists in the map.
|
|
227
|
+
* @param key - The key to check
|
|
228
|
+
* @returns True if the key exists, false otherwise
|
|
229
|
+
*/
|
|
230
|
+
has(key: string): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* {@inheritDoc ISharedMap.set}
|
|
233
|
+
*/
|
|
234
|
+
set(key: string, value: unknown): this;
|
|
235
|
+
/**
|
|
236
|
+
* Delete a key from the map.
|
|
237
|
+
* @param key - Key to delete
|
|
238
|
+
* @returns True if the key existed and was deleted, false if it did not exist
|
|
239
|
+
*/
|
|
240
|
+
delete(key: string): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Clear all data from the map.
|
|
243
|
+
*/
|
|
244
|
+
clear(): void;
|
|
245
|
+
/**
|
|
246
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
247
|
+
*/
|
|
248
|
+
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
249
|
+
/**
|
|
250
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
251
|
+
*/
|
|
252
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
255
|
+
*/
|
|
256
|
+
protected onDisconnect(): void;
|
|
257
|
+
/**
|
|
258
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
259
|
+
*/
|
|
260
|
+
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
261
|
+
/**
|
|
262
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
263
|
+
*/
|
|
264
|
+
protected applyStashedOp(content: unknown): unknown;
|
|
265
|
+
/**
|
|
266
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
267
|
+
*/
|
|
268
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
269
|
+
/**
|
|
270
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
271
|
+
*/
|
|
272
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export { }
|