@fluidframework/map 0.54.2 → 0.56.0-49831
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 +1 -1
- package/dist/directory.d.ts +5 -9
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +7 -34
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +0 -12
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/localValues.d.ts +2 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +5 -9
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +8 -16
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +2 -5
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +0 -21
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +5 -9
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +7 -34
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +0 -12
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/localValues.d.ts +2 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +5 -9
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +9 -17
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +2 -5
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +0 -21
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +20 -18
- package/src/directory.ts +10 -42
- package/src/interfaces.ts +0 -14
- package/src/localValues.ts +1 -3
- package/src/map.ts +11 -23
- package/src/mapKernel.ts +2 -26
- package/src/packageVersion.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0-49831",
|
|
4
4
|
"description": "Distributed map",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
24
24
|
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
25
25
|
"eslint": "eslint --format stylish src",
|
|
26
|
-
"eslint:fix": "eslint --format stylish src --fix",
|
|
26
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
27
27
|
"lint": "npm run eslint",
|
|
28
28
|
"lint:fix": "npm run eslint:fix",
|
|
29
29
|
"test": "npm run test:mocha",
|
|
@@ -57,35 +57,37 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
59
59
|
"@fluidframework/common-utils": "^0.32.1",
|
|
60
|
-
"@fluidframework/core-interfaces": "^0.
|
|
61
|
-
"@fluidframework/datastore-definitions": "
|
|
62
|
-
"@fluidframework/driver-utils": "
|
|
63
|
-
"@fluidframework/protocol-base": "^0.1034.0",
|
|
60
|
+
"@fluidframework/core-interfaces": "^0.42.0-0",
|
|
61
|
+
"@fluidframework/datastore-definitions": "0.56.0-49831",
|
|
62
|
+
"@fluidframework/driver-utils": "0.56.0-49831",
|
|
64
63
|
"@fluidframework/protocol-definitions": "^0.1026.0",
|
|
65
|
-
"@fluidframework/
|
|
64
|
+
"@fluidframework/runtime-definitions": "0.56.0-49831",
|
|
65
|
+
"@fluidframework/runtime-utils": "0.56.0-49831",
|
|
66
|
+
"@fluidframework/shared-object-base": "0.56.0-49831",
|
|
66
67
|
"path-browserify": "^1.0.1"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@fluid-internal/test-dds-utils": "
|
|
70
|
+
"@fluid-internal/test-dds-utils": "0.56.0-49831",
|
|
70
71
|
"@fluidframework/build-common": "^0.23.0",
|
|
71
|
-
"@fluidframework/eslint-config-fluid": "^0.
|
|
72
|
-
"@fluidframework/mocha-test-setup": "
|
|
73
|
-
"@fluidframework/test-runtime-utils": "
|
|
72
|
+
"@fluidframework/eslint-config-fluid": "^0.25.0",
|
|
73
|
+
"@fluidframework/mocha-test-setup": "0.56.0-49831",
|
|
74
|
+
"@fluidframework/test-runtime-utils": "0.56.0-49831",
|
|
74
75
|
"@microsoft/api-extractor": "^7.16.1",
|
|
76
|
+
"@rushstack/eslint-config": "^2.5.1",
|
|
75
77
|
"@types/mocha": "^8.2.2",
|
|
76
78
|
"@types/node": "^14.18.0",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "~
|
|
78
|
-
"@typescript-eslint/parser": "~
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "~5.9.0",
|
|
80
|
+
"@typescript-eslint/parser": "~5.9.0",
|
|
79
81
|
"concurrently": "^6.2.0",
|
|
80
82
|
"copyfiles": "^2.1.0",
|
|
81
83
|
"cross-env": "^7.0.2",
|
|
82
|
-
"eslint": "~
|
|
84
|
+
"eslint": "~8.6.0",
|
|
85
|
+
"eslint-plugin-editorconfig": "~3.2.0",
|
|
83
86
|
"eslint-plugin-eslint-comments": "~3.2.0",
|
|
84
|
-
"eslint-plugin-import": "~2.
|
|
87
|
+
"eslint-plugin-import": "~2.25.4",
|
|
85
88
|
"eslint-plugin-no-null": "~1.0.2",
|
|
86
|
-
"eslint-plugin-
|
|
87
|
-
"eslint-plugin-
|
|
88
|
-
"eslint-plugin-unicorn": "~26.0.1",
|
|
89
|
+
"eslint-plugin-react": "~7.28.0",
|
|
90
|
+
"eslint-plugin-unicorn": "~40.0.0",
|
|
89
91
|
"mocha": "^8.4.0",
|
|
90
92
|
"nyc": "^15.0.0",
|
|
91
93
|
"rimraf": "^2.6.2",
|
package/src/directory.ts
CHANGED
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert,TypedEventEmitter } from "@fluidframework/common-utils";
|
|
7
|
-
import { IFluidSerializer } from "@fluidframework/core-interfaces";
|
|
8
7
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
9
|
-
import { addBlobToTree } from "@fluidframework/protocol-base";
|
|
10
8
|
import {
|
|
11
9
|
ISequencedDocumentMessage,
|
|
12
|
-
ITree,
|
|
13
10
|
MessageType,
|
|
14
11
|
} from "@fluidframework/protocol-definitions";
|
|
15
12
|
import {
|
|
@@ -19,7 +16,9 @@ import {
|
|
|
19
16
|
IChannelServices,
|
|
20
17
|
IChannelFactory,
|
|
21
18
|
} from "@fluidframework/datastore-definitions";
|
|
22
|
-
import {
|
|
19
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
20
|
+
import { IFluidSerializer, SharedObject, ValueType } from "@fluidframework/shared-object-base";
|
|
21
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
23
22
|
import * as path from "path-browserify";
|
|
24
23
|
import {
|
|
25
24
|
IDirectory,
|
|
@@ -204,10 +203,10 @@ export interface IDirectoryNewStorageFormat {
|
|
|
204
203
|
content: IDirectoryDataObject;
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
function serializeDirectory(root: SubDirectory, serializer: IFluidSerializer):
|
|
206
|
+
function serializeDirectory(root: SubDirectory, serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
208
207
|
const MinValueSizeSeparateSnapshotBlob = 8 * 1024;
|
|
209
208
|
|
|
210
|
-
const
|
|
209
|
+
const builder = new SummaryTreeBuilder();
|
|
211
210
|
let counter = 0;
|
|
212
211
|
const blobs: string[] = [];
|
|
213
212
|
|
|
@@ -241,7 +240,7 @@ function serializeDirectory(root: SubDirectory, serializer: IFluidSerializer): I
|
|
|
241
240
|
const blobName = `blob${counter}`;
|
|
242
241
|
counter++;
|
|
243
242
|
blobs.push(blobName);
|
|
244
|
-
|
|
243
|
+
builder.addBlob(blobName, JSON.stringify(extraContent));
|
|
245
244
|
} else {
|
|
246
245
|
currentSubDirObject.storage[key] = result;
|
|
247
246
|
}
|
|
@@ -261,9 +260,9 @@ function serializeDirectory(root: SubDirectory, serializer: IFluidSerializer): I
|
|
|
261
260
|
blobs,
|
|
262
261
|
content,
|
|
263
262
|
};
|
|
264
|
-
|
|
263
|
+
builder.addBlob(snapshotFileName, JSON.stringify(newFormat));
|
|
265
264
|
|
|
266
|
-
return
|
|
265
|
+
return builder.getSummaryTree();
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
/**
|
|
@@ -417,13 +416,6 @@ export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implem
|
|
|
417
416
|
return this.root.get<T>(key);
|
|
418
417
|
}
|
|
419
418
|
|
|
420
|
-
/**
|
|
421
|
-
* {@inheritDoc IDirectory.wait}
|
|
422
|
-
*/
|
|
423
|
-
public async wait<T = any>(key: string): Promise<T> {
|
|
424
|
-
return this.root.wait<T>(key);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
419
|
/**
|
|
428
420
|
* {@inheritDoc IDirectory.set}
|
|
429
421
|
*/
|
|
@@ -560,10 +552,10 @@ export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implem
|
|
|
560
552
|
}
|
|
561
553
|
|
|
562
554
|
/**
|
|
563
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.
|
|
555
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
564
556
|
* @internal
|
|
565
557
|
*/
|
|
566
|
-
protected
|
|
558
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
567
559
|
return serializeDirectory(this.root, serializer);
|
|
568
560
|
}
|
|
569
561
|
|
|
@@ -899,30 +891,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
899
891
|
return this._storage.get(key)?.value as T | undefined;
|
|
900
892
|
}
|
|
901
893
|
|
|
902
|
-
/**
|
|
903
|
-
* {@inheritDoc IDirectory.wait}
|
|
904
|
-
*/
|
|
905
|
-
public async wait<T = any>(key: string): Promise<T> {
|
|
906
|
-
// Return immediately if the value already exists
|
|
907
|
-
if (this._storage.has(key)) {
|
|
908
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
909
|
-
return this._storage.get(key)!.value as T;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// Otherwise subscribe to changes
|
|
913
|
-
return new Promise<T>((resolve, reject) => {
|
|
914
|
-
const callback = (changed: IDirectoryValueChanged) => {
|
|
915
|
-
if (this.absolutePath === changed.path && key === changed.key) {
|
|
916
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
917
|
-
resolve(this._storage.get(key)!.value as T);
|
|
918
|
-
this.directory.removeListener("valueChanged", callback);
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
this.directory.on("valueChanged", callback);
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
|
|
926
894
|
/**
|
|
927
895
|
* {@inheritDoc IDirectory.set}
|
|
928
896
|
*/
|
package/src/interfaces.ts
CHANGED
|
@@ -40,13 +40,6 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
40
40
|
*/
|
|
41
41
|
get<T = any>(key: string): T | undefined;
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* A form of get except it will only resolve the promise once the key exists in the directory.
|
|
45
|
-
* @param key - Key to retrieve from
|
|
46
|
-
* @returns The stored value once available
|
|
47
|
-
*/
|
|
48
|
-
wait<T = any>(key: string): Promise<T>;
|
|
49
|
-
|
|
50
43
|
/**
|
|
51
44
|
* Sets the value stored at key to the provided value.
|
|
52
45
|
* @param key - Key to set at
|
|
@@ -264,13 +257,6 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
|
|
|
264
257
|
*/
|
|
265
258
|
get<T = any>(key: string): T | undefined;
|
|
266
259
|
|
|
267
|
-
/**
|
|
268
|
-
* A form of get except it will only resolve the promise once the key exists in the map.
|
|
269
|
-
* @param key - Key to retrieve from
|
|
270
|
-
* @returns The stored value once available
|
|
271
|
-
*/
|
|
272
|
-
wait<T = any>(key: string): Promise<T>;
|
|
273
|
-
|
|
274
260
|
/**
|
|
275
261
|
* Sets the value stored at key to the provided value.
|
|
276
262
|
* @param key - Key to set at
|
package/src/localValues.ts
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
7
|
import {
|
|
7
|
-
IFluidHandle,
|
|
8
8
|
IFluidSerializer,
|
|
9
9
|
ISerializedHandle,
|
|
10
|
-
} from "@fluidframework/core-interfaces";
|
|
11
|
-
import {
|
|
12
10
|
parseHandles,
|
|
13
11
|
serializeHandles,
|
|
14
12
|
SharedObject,
|
package/src/map.ts
CHANGED
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { addBlobToTree } from "@fluidframework/protocol-base";
|
|
8
|
-
import {
|
|
9
|
-
ISequencedDocumentMessage,
|
|
10
|
-
ITree,
|
|
11
|
-
MessageType,
|
|
12
|
-
} from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
13
7
|
import {
|
|
14
8
|
IChannelAttributes,
|
|
15
9
|
IFluidDataStoreRuntime,
|
|
@@ -17,10 +11,13 @@ import {
|
|
|
17
11
|
IChannelServices,
|
|
18
12
|
IChannelFactory,
|
|
19
13
|
} from "@fluidframework/datastore-definitions";
|
|
14
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
20
15
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
21
16
|
import {
|
|
17
|
+
IFluidSerializer,
|
|
22
18
|
SharedObject,
|
|
23
19
|
} from "@fluidframework/shared-object-base";
|
|
20
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
24
21
|
import {
|
|
25
22
|
ISharedMap,
|
|
26
23
|
ISharedMapEvents,
|
|
@@ -211,13 +208,6 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
211
208
|
return this.kernel.get<T>(key);
|
|
212
209
|
}
|
|
213
210
|
|
|
214
|
-
/**
|
|
215
|
-
* {@inheritDoc ISharedMap.wait}
|
|
216
|
-
*/
|
|
217
|
-
public async wait<T = any>(key: string): Promise<T> {
|
|
218
|
-
return this.kernel.wait<T>(key);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
211
|
/**
|
|
222
212
|
* Check if a key exists in the map.
|
|
223
213
|
* @param key - The key to check
|
|
@@ -252,18 +242,16 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
252
242
|
}
|
|
253
243
|
|
|
254
244
|
/**
|
|
255
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.
|
|
245
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
256
246
|
* @internal
|
|
257
247
|
*/
|
|
258
|
-
protected
|
|
248
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
259
249
|
let currentSize = 0;
|
|
260
250
|
let counter = 0;
|
|
261
251
|
let headerBlob: IMapDataObjectSerializable = {};
|
|
262
252
|
const blobs: string[] = [];
|
|
263
253
|
|
|
264
|
-
const
|
|
265
|
-
entries: [],
|
|
266
|
-
};
|
|
254
|
+
const builder = new SummaryTreeBuilder();
|
|
267
255
|
|
|
268
256
|
const data = this.kernel.getSerializedStorage(serializer);
|
|
269
257
|
|
|
@@ -296,7 +284,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
296
284
|
value: JSON.parse(value.value),
|
|
297
285
|
},
|
|
298
286
|
};
|
|
299
|
-
|
|
287
|
+
builder.addBlob(blobName, JSON.stringify(content));
|
|
300
288
|
} else {
|
|
301
289
|
currentSize += value.type.length + 21; // Approximation cost of property header
|
|
302
290
|
if (value.value) {
|
|
@@ -307,7 +295,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
307
295
|
const blobName = `blob${counter}`;
|
|
308
296
|
counter++;
|
|
309
297
|
blobs.push(blobName);
|
|
310
|
-
|
|
298
|
+
builder.addBlob(blobName, JSON.stringify(headerBlob));
|
|
311
299
|
headerBlob = {};
|
|
312
300
|
currentSize = 0;
|
|
313
301
|
}
|
|
@@ -322,9 +310,9 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
322
310
|
blobs,
|
|
323
311
|
content: headerBlob,
|
|
324
312
|
};
|
|
325
|
-
|
|
313
|
+
builder.addBlob(snapshotFileName, JSON.stringify(header));
|
|
326
314
|
|
|
327
|
-
return
|
|
315
|
+
return builder.getSummaryTree();
|
|
328
316
|
}
|
|
329
317
|
|
|
330
318
|
/**
|
package/src/mapKernel.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IFluidHandle
|
|
7
|
-
import { ValueType } from "@fluidframework/shared-object-base";
|
|
6
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { IFluidSerializer, ValueType } from "@fluidframework/shared-object-base";
|
|
8
8
|
import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
9
9
|
import {
|
|
10
10
|
ISerializableValue,
|
|
@@ -260,30 +260,6 @@ export class MapKernel {
|
|
|
260
260
|
return localValue.value as T;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
/**
|
|
264
|
-
* {@inheritDoc ISharedMap.wait}
|
|
265
|
-
*/
|
|
266
|
-
public async wait<T = any>(key: string): Promise<T> {
|
|
267
|
-
// Return immediately if the value already exists
|
|
268
|
-
if (this.has(key)) {
|
|
269
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
270
|
-
return this.get<T>(key)!;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Otherwise subscribe to changes
|
|
274
|
-
return new Promise<T>((resolve) => {
|
|
275
|
-
const callback = (changed: IValueChanged) => {
|
|
276
|
-
if (key === changed.key) {
|
|
277
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
278
|
-
resolve(this.get<T>(changed.key)!);
|
|
279
|
-
this.eventEmitter.removeListener("valueChanged", callback);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
this.eventEmitter.on("valueChanged", callback);
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
263
|
/**
|
|
288
264
|
* Check if a key exists in the map.
|
|
289
265
|
* @param key - The key to check
|
package/src/packageVersion.ts
CHANGED