@fluidframework/map 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.3.1.0.125672
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 +6 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +68 -30
- package/dist/directory.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 +6 -5
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +70 -32
- package/lib/directory.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 +24 -21
- package/prettier.config.cjs +1 -1
- package/src/directory.ts +1957 -1848
- 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/.eslintrc.js
CHANGED
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
13
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
14
|
+
|
|
15
|
+
// TODO: consider re-enabling once we have addressed how this rule conflicts with our error codes.
|
|
16
|
+
"unicorn/numeric-separators-style": "off",
|
|
17
|
+
},
|
|
18
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/README.md
CHANGED
|
@@ -27,11 +27,11 @@ when the key becomes available.
|
|
|
27
27
|
|
|
28
28
|
### Eventing
|
|
29
29
|
|
|
30
|
-
`SharedMap` is an `EventEmitter`, and will emit events when other clients make modifications.
|
|
30
|
+
`SharedMap` is an `EventEmitter`, and will emit events when other clients make modifications. You should register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted in response to a `set` or `delete`, and provide the key and previous value that was stored at that key. `clear` will be emitted in response to a `clear`.
|
|
31
31
|
|
|
32
32
|
## SharedDirectory and IDirectory
|
|
33
33
|
|
|
34
|
-
A `SharedDirectory` is a map-like DDS that additionally supports storing key/value pairs within a tree of subdirectories.
|
|
34
|
+
A `SharedDirectory` is a map-like DDS that additionally supports storing key/value pairs within a tree of subdirectories. This subdirectory tree can be used to give hierarchical structure to stored key/value pairs rather than storing them on a flat map. Both the `SharedDirectory` and any subdirectories are `IDirectories`.
|
|
35
35
|
|
|
36
36
|
### Creation
|
|
37
37
|
|
|
@@ -43,7 +43,7 @@ const myDirectory = SharedDirectory.create(this.runtime, id);
|
|
|
43
43
|
|
|
44
44
|
### Usage
|
|
45
45
|
|
|
46
|
-
The map operations on an `IDirectory` refer to the key/value pairs stored in that `IDirectory`, and function just like `SharedMap` including the same extra functionality and restrictions on keys and values.
|
|
46
|
+
The map operations on an `IDirectory` refer to the key/value pairs stored in that `IDirectory`, and function just like `SharedMap` including the same extra functionality and restrictions on keys and values. To operate on the subdirectory structure, use the corresponding subdirectory methods.
|
|
47
47
|
|
|
48
48
|
#### `getWorkingDirectory()`
|
|
49
49
|
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-strict.json"
|
|
4
4
|
}
|
package/dist/directory.d.ts
CHANGED
|
@@ -239,7 +239,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
239
239
|
/**
|
|
240
240
|
* {@inheritDoc IDirectory.set}
|
|
241
241
|
*/
|
|
242
|
-
set<T =
|
|
242
|
+
set<T = unknown>(key: string, value: T): this;
|
|
243
243
|
dispose(error?: Error): void;
|
|
244
244
|
get disposed(): boolean;
|
|
245
245
|
/**
|
|
@@ -337,7 +337,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
337
337
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
338
338
|
* @internal
|
|
339
339
|
*/
|
|
340
|
-
protected reSubmitCore(content:
|
|
340
|
+
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
341
341
|
/**
|
|
342
342
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
343
343
|
* @internal
|
|
@@ -357,8 +357,8 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
357
357
|
/**
|
|
358
358
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
359
359
|
* @internal
|
|
360
|
-
|
|
361
|
-
protected rollback(content:
|
|
360
|
+
*/
|
|
361
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
362
362
|
/**
|
|
363
363
|
* Converts the given relative path to absolute against the root.
|
|
364
364
|
* @param relativePath - The path to convert
|
|
@@ -380,9 +380,10 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
380
380
|
*/
|
|
381
381
|
private setMessageHandlers;
|
|
382
382
|
/**
|
|
383
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
383
384
|
* @internal
|
|
384
385
|
*/
|
|
385
|
-
protected applyStashedOp(op:
|
|
386
|
+
protected applyStashedOp(op: unknown): unknown;
|
|
386
387
|
private serializeDirectory;
|
|
387
388
|
}
|
|
388
389
|
//# sourceMappingURL=directory.d.ts.map
|
package/dist/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAa,MAAM,oCAAoC,CAAC;AAG/F,OAAO,EACN,UAAU,EAGV,kBAAkB,EAElB,gBAAgB,EAChB,sBAAsB,EAEtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAe,eAAe,EAAoB,MAAM,eAAe,CAAC;AAgC/E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AAC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OAGG;IACH,SAAS,CAAC,aAAa,CACtB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAIxB;;;;;;OAMG;IACI,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAItF;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAOxE;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAqCpD;;;OAGG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IASP;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAQpE;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAajB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmH1B;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO;IAQ9C,OAAO,CAAC,kBAAkB;CAgE1B"}
|
package/dist/directory.js
CHANGED
|
@@ -160,6 +160,8 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
160
160
|
/**
|
|
161
161
|
* {@inheritDoc IDirectory.get}
|
|
162
162
|
*/
|
|
163
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
165
|
get(key) {
|
|
164
166
|
return this.root.get(key);
|
|
165
167
|
}
|
|
@@ -208,13 +210,18 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
208
210
|
* Issue a callback on each entry under this IDirectory.
|
|
209
211
|
* @param callback - Callback to issue
|
|
210
212
|
*/
|
|
213
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
215
|
forEach(callback) {
|
|
216
|
+
// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference
|
|
212
217
|
this.root.forEach(callback);
|
|
213
218
|
}
|
|
214
219
|
/**
|
|
215
220
|
* Get an iterator over the entries under this IDirectory.
|
|
216
221
|
* @returns The iterator
|
|
217
222
|
*/
|
|
223
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
225
|
[(_a = Symbol.toStringTag, Symbol.iterator)]() {
|
|
219
226
|
return this.root[Symbol.iterator]();
|
|
220
227
|
}
|
|
@@ -222,6 +229,8 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
222
229
|
* Get an iterator over the entries under this IDirectory.
|
|
223
230
|
* @returns The iterator
|
|
224
231
|
*/
|
|
232
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
234
|
entries() {
|
|
226
235
|
return this.root.entries();
|
|
227
236
|
}
|
|
@@ -242,6 +251,8 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
242
251
|
* Get an iterator over the values under this IDirectory.
|
|
243
252
|
* @returns The iterator
|
|
244
253
|
*/
|
|
254
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
245
256
|
values() {
|
|
246
257
|
return this.root.values();
|
|
247
258
|
}
|
|
@@ -284,7 +295,7 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
284
295
|
return this.root;
|
|
285
296
|
}
|
|
286
297
|
let currentSubDir = this.root;
|
|
287
|
-
const subdirs = absolutePath.
|
|
298
|
+
const subdirs = absolutePath.slice(1).split(posix.sep);
|
|
288
299
|
for (const subdir of subdirs) {
|
|
289
300
|
currentSubDir = currentSubDir.getSubDirectory(subdir);
|
|
290
301
|
if (!currentSubDir) {
|
|
@@ -389,7 +400,7 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
389
400
|
/**
|
|
390
401
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
391
402
|
* @internal
|
|
392
|
-
|
|
403
|
+
*/
|
|
393
404
|
rollback(content, localOpMetadata) {
|
|
394
405
|
const op = content;
|
|
395
406
|
const subdir = this.getWorkingDirectory(op.path);
|
|
@@ -415,7 +426,8 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
415
426
|
* @returns The local value that was produced
|
|
416
427
|
*/
|
|
417
428
|
makeLocal(key, absolutePath, serializable) {
|
|
418
|
-
(0, common_utils_1.assert)(serializable.type === shared_object_base_1.ValueType[shared_object_base_1.ValueType.Plain] ||
|
|
429
|
+
(0, common_utils_1.assert)(serializable.type === shared_object_base_1.ValueType[shared_object_base_1.ValueType.Plain] ||
|
|
430
|
+
serializable.type === shared_object_base_1.ValueType[shared_object_base_1.ValueType.Shared], 0x1e4 /* "Unexpected serializable type" */);
|
|
419
431
|
return this.localValueMaker.fromSerializable(serializable);
|
|
420
432
|
}
|
|
421
433
|
/**
|
|
@@ -498,7 +510,6 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
498
510
|
parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);
|
|
499
511
|
}
|
|
500
512
|
},
|
|
501
|
-
// eslint-disable-next-line max-len
|
|
502
513
|
applyStashedOp: (op) => {
|
|
503
514
|
const parentSubdir = this.getWorkingDirectory(op.path);
|
|
504
515
|
if (parentSubdir) {
|
|
@@ -520,7 +531,6 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
520
531
|
parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);
|
|
521
532
|
}
|
|
522
533
|
},
|
|
523
|
-
// eslint-disable-next-line max-len
|
|
524
534
|
applyStashedOp: (op) => {
|
|
525
535
|
const parentSubdir = this.getWorkingDirectory(op.path);
|
|
526
536
|
if (parentSubdir) {
|
|
@@ -530,6 +540,7 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
530
540
|
});
|
|
531
541
|
}
|
|
532
542
|
/**
|
|
543
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
533
544
|
* @internal
|
|
534
545
|
*/
|
|
535
546
|
applyStashedOp(op) {
|
|
@@ -556,14 +567,13 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
556
567
|
}
|
|
557
568
|
const result = {
|
|
558
569
|
type: value.type,
|
|
559
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
560
570
|
value: value.value && JSON.parse(value.value),
|
|
561
571
|
};
|
|
562
572
|
if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {
|
|
563
573
|
const extraContent = {};
|
|
564
574
|
let largeContent = extraContent;
|
|
565
575
|
if (currentSubDir.absolutePath !== posix.sep) {
|
|
566
|
-
for (const dir of currentSubDir.absolutePath.
|
|
576
|
+
for (const dir of currentSubDir.absolutePath.slice(1).split(posix.sep)) {
|
|
567
577
|
const subDataObject = {};
|
|
568
578
|
largeContent.subdirectories = { [dir]: subDataObject };
|
|
569
579
|
largeContent = subDataObject;
|
|
@@ -597,24 +607,33 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
597
607
|
}
|
|
598
608
|
}
|
|
599
609
|
exports.SharedDirectory = SharedDirectory;
|
|
610
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
600
611
|
function isKeyEditLocalOpMetadata(metadata) {
|
|
601
|
-
return metadata !== undefined &&
|
|
612
|
+
return (metadata !== undefined &&
|
|
613
|
+
typeof metadata.pendingMessageId === "number" &&
|
|
614
|
+
metadata.type === "edit");
|
|
602
615
|
}
|
|
603
616
|
function isClearLocalOpMetadata(metadata) {
|
|
604
|
-
return metadata !== undefined &&
|
|
605
|
-
|
|
617
|
+
return (metadata !== undefined &&
|
|
618
|
+
metadata.type === "clear" &&
|
|
619
|
+
typeof metadata.pendingMessageId === "number" &&
|
|
620
|
+
typeof metadata.previousStorage === "object");
|
|
606
621
|
}
|
|
607
622
|
function isSubDirLocalOpMetadata(metadata) {
|
|
608
|
-
return metadata !== undefined &&
|
|
623
|
+
return (metadata !== undefined &&
|
|
624
|
+
typeof metadata.pendingMessageId === "number" &&
|
|
609
625
|
((metadata.type === "createSubDir" && typeof metadata.previouslyExisted === "boolean") ||
|
|
610
|
-
metadata.type === "deleteSubDir");
|
|
626
|
+
metadata.type === "deleteSubDir"));
|
|
611
627
|
}
|
|
612
628
|
function isDirectoryLocalOpMetadata(metadata) {
|
|
613
|
-
return metadata !== undefined &&
|
|
614
|
-
|
|
629
|
+
return (metadata !== undefined &&
|
|
630
|
+
typeof metadata.pendingMessageId === "number" &&
|
|
631
|
+
(metadata.type === "edit" ||
|
|
632
|
+
metadata.type === "deleteSubDir" ||
|
|
615
633
|
(metadata.type === "clear" && typeof metadata.previousStorage === "object") ||
|
|
616
|
-
(metadata.type === "createSubDir" && typeof metadata.previouslyExisted === "boolean"));
|
|
634
|
+
(metadata.type === "createSubDir" && typeof metadata.previouslyExisted === "boolean")));
|
|
617
635
|
}
|
|
636
|
+
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
618
637
|
/**
|
|
619
638
|
* Node of the directory tree.
|
|
620
639
|
* @sealed
|
|
@@ -671,10 +690,11 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
671
690
|
this.emit("disposed", this);
|
|
672
691
|
}
|
|
673
692
|
/**
|
|
674
|
-
* Unmark the deleted property when rolling back delete.
|
|
693
|
+
* Unmark the deleted property only when rolling back delete.
|
|
675
694
|
*/
|
|
676
695
|
undispose() {
|
|
677
696
|
this._deleted = false;
|
|
697
|
+
this.emit("undisposed", this);
|
|
678
698
|
}
|
|
679
699
|
get disposed() {
|
|
680
700
|
return this._deleted;
|
|
@@ -854,6 +874,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
854
874
|
*/
|
|
855
875
|
forEach(callback) {
|
|
856
876
|
this.throwIfDisposed();
|
|
877
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
857
878
|
this._storage.forEach((localValue, key, map) => {
|
|
858
879
|
callback(localValue.value, key, map);
|
|
859
880
|
});
|
|
@@ -981,7 +1002,11 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
981
1002
|
this.throwIfDisposed();
|
|
982
1003
|
const previousValue = this.deleteCore(op.key, true);
|
|
983
1004
|
const pendingMessageId = this.getKeyMessageId(op);
|
|
984
|
-
const localMetadata = {
|
|
1005
|
+
const localMetadata = {
|
|
1006
|
+
type: "edit",
|
|
1007
|
+
pendingMessageId,
|
|
1008
|
+
previousValue,
|
|
1009
|
+
};
|
|
985
1010
|
return localMetadata;
|
|
986
1011
|
}
|
|
987
1012
|
/**
|
|
@@ -1013,7 +1038,11 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1013
1038
|
const previousValue = this.setCore(op.key, context, true);
|
|
1014
1039
|
// Create metadata
|
|
1015
1040
|
const pendingMessageId = this.getKeyMessageId(op);
|
|
1016
|
-
const localMetadata = {
|
|
1041
|
+
const localMetadata = {
|
|
1042
|
+
type: "edit",
|
|
1043
|
+
pendingMessageId,
|
|
1044
|
+
previousValue,
|
|
1045
|
+
};
|
|
1017
1046
|
return localMetadata;
|
|
1018
1047
|
}
|
|
1019
1048
|
/**
|
|
@@ -1142,7 +1171,8 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1142
1171
|
(0, common_utils_1.assert)(isKeyEditLocalOpMetadata(localOpMetadata), 0x32d /* Invalid localOpMetadata in submit */);
|
|
1143
1172
|
// clear the old pending message id
|
|
1144
1173
|
const pendingMessageIds = this.pendingKeys.get(op.key);
|
|
1145
|
-
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1174
|
+
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1175
|
+
pendingMessageIds[0] === localOpMetadata.pendingMessageId, 0x32e /* Unexpected pending message received */);
|
|
1146
1176
|
pendingMessageIds.shift();
|
|
1147
1177
|
if (pendingMessageIds.length === 0) {
|
|
1148
1178
|
this.pendingKeys.delete(op.key);
|
|
@@ -1204,7 +1234,8 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1204
1234
|
(0, common_utils_1.assert)(isSubDirLocalOpMetadata(localOpMetadata), 0x32f /* Invalid localOpMetadata for sub directory op */);
|
|
1205
1235
|
// clear the old pending message id
|
|
1206
1236
|
const pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);
|
|
1207
|
-
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1237
|
+
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1238
|
+
pendingMessageIds[0] === localOpMetadata.pendingMessageId, 0x330 /* Unexpected pending message received */);
|
|
1208
1239
|
pendingMessageIds.shift();
|
|
1209
1240
|
if (pendingMessageIds.length === 0) {
|
|
1210
1241
|
this.pendingSubDirectories.delete(op.subdirName);
|
|
@@ -1276,21 +1307,24 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1276
1307
|
map.delete(key);
|
|
1277
1308
|
}
|
|
1278
1309
|
}
|
|
1310
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
1279
1311
|
/**
|
|
1280
1312
|
* Rollback a local op
|
|
1281
1313
|
* @param op - The operation to rollback
|
|
1282
1314
|
* @param localOpMetadata - The local metadata associated with the op.
|
|
1283
1315
|
*/
|
|
1316
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1284
1317
|
rollback(op, localOpMetadata) {
|
|
1285
1318
|
if (!isDirectoryLocalOpMetadata(localOpMetadata)) {
|
|
1286
1319
|
throw new Error("Invalid localOpMetadata");
|
|
1287
1320
|
}
|
|
1288
1321
|
if (op.type === "clear" && localOpMetadata.type === "clear") {
|
|
1289
|
-
localOpMetadata.previousStorage.
|
|
1322
|
+
for (const [key, localValue] of localOpMetadata.previousStorage.entries()) {
|
|
1290
1323
|
this.setCore(key, localValue, true);
|
|
1291
|
-
}
|
|
1324
|
+
}
|
|
1292
1325
|
const lastPendingClearId = this.pendingClearMessageIds.pop();
|
|
1293
|
-
if (lastPendingClearId === undefined ||
|
|
1326
|
+
if (lastPendingClearId === undefined ||
|
|
1327
|
+
lastPendingClearId !== localOpMetadata.pendingMessageId) {
|
|
1294
1328
|
throw new Error("Rollback op does match last clear");
|
|
1295
1329
|
}
|
|
1296
1330
|
}
|
|
@@ -1322,6 +1356,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1322
1356
|
throw new Error("Unsupported op for rollback");
|
|
1323
1357
|
}
|
|
1324
1358
|
}
|
|
1359
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
1325
1360
|
/**
|
|
1326
1361
|
* Converts the given relative path into an absolute path.
|
|
1327
1362
|
* @param path - Relative path to convert
|
|
@@ -1342,7 +1377,8 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1342
1377
|
needProcessStorageOperation(op, local, localOpMetadata) {
|
|
1343
1378
|
if (this.pendingClearMessageIds.length > 0) {
|
|
1344
1379
|
if (local) {
|
|
1345
|
-
(0, common_utils_1.assert)(localOpMetadata !== undefined &&
|
|
1380
|
+
(0, common_utils_1.assert)(localOpMetadata !== undefined &&
|
|
1381
|
+
isKeyEditLocalOpMetadata(localOpMetadata) &&
|
|
1346
1382
|
localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0], 0x010 /* "Received out of order storage op when there is an unackd clear message" */);
|
|
1347
1383
|
}
|
|
1348
1384
|
// If I have a NACK clear, we can ignore all ops.
|
|
@@ -1355,7 +1391,8 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1355
1391
|
if (local) {
|
|
1356
1392
|
(0, common_utils_1.assert)(localOpMetadata !== undefined && isKeyEditLocalOpMetadata(localOpMetadata), 0x011 /* pendingMessageId is missing from the local client's operation */);
|
|
1357
1393
|
const pendingMessageIds = this.pendingKeys.get(op.key);
|
|
1358
|
-
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1394
|
+
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1395
|
+
pendingMessageIds[0] === localOpMetadata.pendingMessageId, 0x331 /* Unexpected pending message received */);
|
|
1359
1396
|
pendingMessageIds.shift();
|
|
1360
1397
|
if (pendingMessageIds.length === 0) {
|
|
1361
1398
|
this.pendingKeys.delete(op.key);
|
|
@@ -1382,7 +1419,8 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1382
1419
|
if (local) {
|
|
1383
1420
|
(0, common_utils_1.assert)(isSubDirLocalOpMetadata(localOpMetadata), 0x012 /* pendingMessageId is missing from the local client's operation */);
|
|
1384
1421
|
const pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);
|
|
1385
|
-
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1422
|
+
(0, common_utils_1.assert)(pendingMessageIds !== undefined &&
|
|
1423
|
+
pendingMessageIds[0] === localOpMetadata.pendingMessageId, 0x332 /* Unexpected pending message received */);
|
|
1386
1424
|
pendingMessageIds.shift();
|
|
1387
1425
|
if (pendingMessageIds.length === 0) {
|
|
1388
1426
|
this.pendingSubDirectories.delete(op.subdirName);
|
|
@@ -1399,14 +1437,14 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1399
1437
|
// Assuming the pendingKeys is small and the map is large
|
|
1400
1438
|
// we will get the value for the pendingKeys and clear the map
|
|
1401
1439
|
const temp = new Map();
|
|
1402
|
-
|
|
1440
|
+
for (const [key] of this.pendingKeys) {
|
|
1403
1441
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1404
1442
|
temp.set(key, this._storage.get(key));
|
|
1405
|
-
}
|
|
1443
|
+
}
|
|
1406
1444
|
this.clearCore(local);
|
|
1407
|
-
|
|
1445
|
+
for (const [key, value] of temp.entries()) {
|
|
1408
1446
|
this.setCore(key, value, true);
|
|
1409
|
-
}
|
|
1447
|
+
}
|
|
1410
1448
|
}
|
|
1411
1449
|
/**
|
|
1412
1450
|
* Clear implementation used for both locally sourced clears as well as incoming remote clears.
|