@fluidframework/map 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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 -14
- package/.mocharc.js +2 -2
- package/README.md +3 -3
- package/api-extractor.json +2 -2
- package/dist/directory.d.ts +38 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +285 -88
- package/dist/directory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +27 -17
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts +39 -0
- package/dist/internalInterfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.js.map +1 -1
- package/dist/localValues.d.ts +12 -3
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +10 -0
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +5 -5
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +15 -2
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +5 -5
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +58 -33
- 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/lib/directory.d.ts +38 -5
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +287 -90
- package/lib/directory.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +27 -17
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts +39 -0
- package/lib/internalInterfaces.d.ts.map +1 -1
- package/lib/internalInterfaces.js.map +1 -1
- package/lib/localValues.d.ts +12 -3
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +10 -0
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +5 -5
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +16 -3
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +5 -5
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +59 -34
- 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/package.json +60 -59
- package/prettier.config.cjs +1 -1
- package/src/directory.ts +2207 -1848
- package/src/index.ts +1 -0
- package/src/interfaces.ts +309 -288
- package/src/internalInterfaces.ts +83 -38
- package/src/localValues.ts +95 -93
- package/src/map.ts +364 -345
- package/src/mapKernel.ts +729 -676
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +5 -5
- package/tsconfig.json +9 -15
package/src/interfaces.ts
CHANGED
|
@@ -4,97 +4,110 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
IDisposable,
|
|
9
|
+
IEvent,
|
|
10
|
+
IEventProvider,
|
|
11
|
+
IEventThisPlaceHolder,
|
|
12
|
+
} from "@fluidframework/common-definitions";
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Type of "valueChanged" event parameter.
|
|
11
16
|
*/
|
|
12
17
|
export interface IValueChanged {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The key storing the value that changed.
|
|
20
|
+
*/
|
|
21
|
+
key: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The value that was stored at the key prior to the change.
|
|
25
|
+
*/
|
|
26
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
previousValue: any;
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
/**
|
|
25
32
|
* Interface describing actions on a directory.
|
|
26
33
|
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* When used as a Map, operates on its keys.
|
|
34
|
+
* @remarks When used as a Map, operates on its keys.
|
|
29
35
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
36
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
export interface IDirectory
|
|
39
|
+
extends Map<string, any>,
|
|
40
|
+
IEventProvider<IDirectoryEvents>,
|
|
41
|
+
Partial<IDisposable> {
|
|
42
|
+
/**
|
|
43
|
+
* The absolute path of the directory.
|
|
44
|
+
*/
|
|
45
|
+
readonly absolutePath: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the value stored at the given key from the directory.
|
|
49
|
+
* @param key - Key to retrieve from
|
|
50
|
+
* @returns The stored value, or undefined if the key is not set
|
|
51
|
+
*/
|
|
52
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
get<T = any>(key: string): T | undefined;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Sets the value stored at key to the provided value.
|
|
58
|
+
* @param key - Key to set at
|
|
59
|
+
* @param value - Value to set
|
|
60
|
+
* @returns The IDirectory itself
|
|
61
|
+
*/
|
|
62
|
+
set<T = unknown>(key: string, value: T): this;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the number of sub directory within the directory.
|
|
66
|
+
* @returns The number of sub directory within a directory.
|
|
67
|
+
*/
|
|
68
|
+
countSubDirectory?(): number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the
|
|
72
|
+
* same name already exists.
|
|
73
|
+
* @param subdirName - Name of the new child directory to create
|
|
74
|
+
* @returns The IDirectory child that was created or retrieved
|
|
75
|
+
*/
|
|
76
|
+
createSubDirectory(subdirName: string): IDirectory;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Gets an IDirectory child of this IDirectory, if it exists.
|
|
80
|
+
* @param subdirName - Name of the child directory to get
|
|
81
|
+
* @returns The requested IDirectory
|
|
82
|
+
*/
|
|
83
|
+
getSubDirectory(subdirName: string): IDirectory | undefined;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Checks whether this directory has a child directory with the given name.
|
|
87
|
+
* @param subdirName - Name of the child directory to check
|
|
88
|
+
* @returns True if it exists, false otherwise
|
|
89
|
+
*/
|
|
90
|
+
hasSubDirectory(subdirName: string): boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.
|
|
94
|
+
* @param subdirName - Name of the child directory to delete
|
|
95
|
+
* @returns True if the IDirectory existed and was deleted, false if it did not exist
|
|
96
|
+
*/
|
|
97
|
+
deleteSubDirectory(subdirName: string): boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Gets an iterator over the IDirectory children of this IDirectory.
|
|
101
|
+
* @returns The IDirectory iterator
|
|
102
|
+
*/
|
|
103
|
+
subdirectories(): IterableIterator<[string, IDirectory]>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get an IDirectory within the directory, in order to use relative paths from that location.
|
|
107
|
+
* @param relativePath - Path of the IDirectory to get, relative to this IDirectory
|
|
108
|
+
* @returns The requested IDirectory
|
|
109
|
+
*/
|
|
110
|
+
getWorkingDirectory(relativePath: string): IDirectory | undefined;
|
|
98
111
|
}
|
|
99
112
|
|
|
100
113
|
/**
|
|
@@ -102,147 +115,150 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
102
115
|
* These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
|
|
103
116
|
*/
|
|
104
117
|
export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
local: boolean,
|
|
172
|
-
target: IEventThisPlaceHolder,
|
|
173
|
-
) => void);
|
|
118
|
+
/**
|
|
119
|
+
* Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
|
|
120
|
+
* subdirectory.
|
|
121
|
+
*
|
|
122
|
+
* @remarks Listener parameters:
|
|
123
|
+
*
|
|
124
|
+
* - `changed` - Information on the key that changed, its value prior to the change, and the path to the
|
|
125
|
+
* key that changed.
|
|
126
|
+
*
|
|
127
|
+
* - `local` - Whether the change originated from this client.
|
|
128
|
+
*
|
|
129
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
130
|
+
*/
|
|
131
|
+
(
|
|
132
|
+
event: "valueChanged",
|
|
133
|
+
listener: (
|
|
134
|
+
changed: IDirectoryValueChanged,
|
|
135
|
+
local: boolean,
|
|
136
|
+
target: IEventThisPlaceHolder,
|
|
137
|
+
) => void,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Emitted when the {@link ISharedDirectory} is cleared.
|
|
142
|
+
*
|
|
143
|
+
* @remarks Listener parameters:
|
|
144
|
+
*
|
|
145
|
+
* - `local` - Whether the clear originated from this client.
|
|
146
|
+
*
|
|
147
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
148
|
+
*/
|
|
149
|
+
(event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Emitted when a subdirectory is created.
|
|
153
|
+
*
|
|
154
|
+
* @remarks Listener parameters:
|
|
155
|
+
*
|
|
156
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
157
|
+
* It is relative from the object which raises the event.
|
|
158
|
+
*
|
|
159
|
+
* - `local` - Whether the create originated from the this client.
|
|
160
|
+
*
|
|
161
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
162
|
+
*/
|
|
163
|
+
(
|
|
164
|
+
event: "subDirectoryCreated",
|
|
165
|
+
listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Emitted when a subdirectory is deleted.
|
|
170
|
+
*
|
|
171
|
+
* @remarks Listener parameters:
|
|
172
|
+
*
|
|
173
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
174
|
+
* It is relative from the object which raises the event.
|
|
175
|
+
*
|
|
176
|
+
* - `local` - Whether the delete originated from the this client.
|
|
177
|
+
*
|
|
178
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
179
|
+
*/
|
|
180
|
+
(
|
|
181
|
+
event: "subDirectoryDeleted",
|
|
182
|
+
listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
183
|
+
);
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
/**
|
|
177
187
|
* Events emitted in response to changes to the directory data.
|
|
178
188
|
*/
|
|
179
189
|
export interface IDirectoryEvents extends IEvent {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Emitted when a key is set or deleted. As opposed to the
|
|
192
|
+
* {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly
|
|
193
|
+
* contains the key.
|
|
194
|
+
*
|
|
195
|
+
* @remarks Listener parameters:
|
|
196
|
+
*
|
|
197
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
198
|
+
*
|
|
199
|
+
* - `local` - Whether the change originated from this client.
|
|
200
|
+
*
|
|
201
|
+
* - `target` - The {@link IDirectory} itself.
|
|
202
|
+
*/
|
|
203
|
+
(
|
|
204
|
+
event: "containedValueChanged",
|
|
205
|
+
listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Emitted when a subdirectory is created. Also emitted when a delete
|
|
210
|
+
* of a subdirectory is rolled back.
|
|
211
|
+
*
|
|
212
|
+
* @remarks Listener parameters:
|
|
213
|
+
*
|
|
214
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
215
|
+
* It is relative from the object which raises the event.
|
|
216
|
+
*
|
|
217
|
+
* - `local` - Whether the creation originated from the this client.
|
|
218
|
+
*
|
|
219
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
220
|
+
*/
|
|
221
|
+
(
|
|
222
|
+
event: "subDirectoryCreated",
|
|
223
|
+
listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Emitted when a subdirectory is deleted.
|
|
228
|
+
*
|
|
229
|
+
* @remarks Listener parameters:
|
|
230
|
+
*
|
|
231
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
232
|
+
* It is relative from the object which raises the event.
|
|
233
|
+
*
|
|
234
|
+
* - `local` - Whether the delete originated from the this client.
|
|
235
|
+
*
|
|
236
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
237
|
+
*/
|
|
238
|
+
(
|
|
239
|
+
event: "subDirectoryDeleted",
|
|
240
|
+
listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Emitted when this sub directory is deleted.
|
|
245
|
+
*
|
|
246
|
+
* @remarks Listener parameters:
|
|
247
|
+
*
|
|
248
|
+
* - `target` - The {@link IDirectory} itself.
|
|
249
|
+
*/
|
|
250
|
+
(event: "disposed", listener: (target: IEventThisPlaceHolder) => void);
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Emitted when this previously deleted sub directory is restored.
|
|
254
|
+
* This event only needs to be handled in the case of rollback. If your application does
|
|
255
|
+
* not use the local rollback feature, you can ignore this event.
|
|
256
|
+
*
|
|
257
|
+
* @remarks Listener parameters:
|
|
258
|
+
*
|
|
259
|
+
* - `target` - The {@link IDirectory} itself.
|
|
260
|
+
*/
|
|
261
|
+
(event: "undisposed", listener: (target: IEventThisPlaceHolder) => void);
|
|
246
262
|
}
|
|
247
263
|
|
|
248
264
|
/**
|
|
@@ -250,57 +266,57 @@ export interface IDirectoryEvents extends IEvent {
|
|
|
250
266
|
* The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
|
|
251
267
|
* SubDirectories can be retrieved for use as working directories.
|
|
252
268
|
*/
|
|
253
|
-
export interface ISharedDirectory
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
269
|
+
export interface ISharedDirectory
|
|
270
|
+
extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>,
|
|
271
|
+
Omit<IDirectory, "on" | "once" | "off"> {
|
|
272
|
+
// The Omit type excludes symbols, which we don't want to exclude. Adding them back here manually.
|
|
273
|
+
// https://github.com/microsoft/TypeScript/issues/31671
|
|
274
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
+
[Symbol.iterator](): IterableIterator<[string, any]>;
|
|
277
|
+
readonly [Symbol.toStringTag]: string;
|
|
260
278
|
}
|
|
261
279
|
|
|
262
280
|
/**
|
|
263
281
|
* Type of "valueChanged" event parameter for {@link ISharedDirectory}
|
|
264
282
|
*/
|
|
265
283
|
export interface IDirectoryValueChanged extends IValueChanged {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
/**
|
|
285
|
+
* The absolute path to the IDirectory storing the key which changed.
|
|
286
|
+
*/
|
|
287
|
+
path: string;
|
|
270
288
|
}
|
|
271
289
|
|
|
272
290
|
/**
|
|
273
291
|
* Events emitted in response to changes to the {@link ISharedMap | map} data.
|
|
274
292
|
*/
|
|
275
293
|
export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
local: boolean,
|
|
303
|
-
target: IEventThisPlaceHolder) => void);
|
|
294
|
+
/**
|
|
295
|
+
* Emitted when a key is set or deleted.
|
|
296
|
+
*
|
|
297
|
+
* @remarks Listener parameters:
|
|
298
|
+
*
|
|
299
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
300
|
+
*
|
|
301
|
+
* - `local` - Whether the change originated from this client.
|
|
302
|
+
*
|
|
303
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
304
|
+
*/
|
|
305
|
+
(
|
|
306
|
+
event: "valueChanged",
|
|
307
|
+
listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Emitted when the map is cleared.
|
|
312
|
+
*
|
|
313
|
+
* @remarks Listener parameters:
|
|
314
|
+
*
|
|
315
|
+
* - `local` - Whether the clear originated from this client.
|
|
316
|
+
*
|
|
317
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
318
|
+
*/
|
|
319
|
+
(event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void);
|
|
304
320
|
}
|
|
305
321
|
|
|
306
322
|
/**
|
|
@@ -312,21 +328,25 @@ export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
|
312
328
|
*
|
|
313
329
|
* For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
|
|
314
330
|
*/
|
|
331
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
315
333
|
export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
334
|
+
/**
|
|
335
|
+
* Retrieves the given key from the map if it exists.
|
|
336
|
+
* @param key - Key to retrieve from
|
|
337
|
+
* @returns The stored value, or undefined if the key is not set
|
|
338
|
+
*/
|
|
339
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
+
get<T = any>(key: string): T | undefined;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Sets the value stored at key to the provided value.
|
|
345
|
+
* @param key - Key to set
|
|
346
|
+
* @param value - Value to set
|
|
347
|
+
* @returns The {@link ISharedMap} itself
|
|
348
|
+
*/
|
|
349
|
+
set<T = unknown>(key: string, value: T): this;
|
|
330
350
|
}
|
|
331
351
|
|
|
332
352
|
/**
|
|
@@ -353,30 +373,31 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
|
|
|
353
373
|
* @deprecated This type is legacy and deprecated.
|
|
354
374
|
*/
|
|
355
375
|
export interface ISerializableValue {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
376
|
+
/**
|
|
377
|
+
* A type annotation to help indicate how the value serializes.
|
|
378
|
+
*/
|
|
379
|
+
type: string;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The JSONable representation of the value.
|
|
383
|
+
*/
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
385
|
+
value: any;
|
|
365
386
|
}
|
|
366
387
|
|
|
367
388
|
/**
|
|
368
389
|
* Serialized {@link ISerializableValue} counterpart.
|
|
369
390
|
*/
|
|
370
391
|
export interface ISerializedValue {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
392
|
+
/**
|
|
393
|
+
* A type annotation to help indicate how the value serializes.
|
|
394
|
+
*/
|
|
395
|
+
type: string;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* String representation of the value.
|
|
399
|
+
*
|
|
400
|
+
* @remarks Will be undefined if the original value was undefined.
|
|
401
|
+
*/
|
|
402
|
+
value: string | undefined;
|
|
382
403
|
}
|