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