@fluidframework/map 1.2.2 → 2.0.0-internal.1.0.0.82159
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/dist/directory.d.ts +26 -7
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +4 -11
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +139 -181
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/localValues.d.ts +3 -3
- package/dist/localValues.js +2 -2
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +3 -5
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -7
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +9 -2
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +28 -13
- 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 +26 -7
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +4 -11
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +139 -181
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/localValues.d.ts +3 -3
- package/lib/localValues.js +2 -2
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +3 -5
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +4 -7
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +9 -2
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +28 -13
- 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 +53 -16
- package/src/directory.ts +30 -15
- package/src/interfaces.ts +146 -181
- package/src/localValues.ts +3 -3
- package/src/map.ts +8 -11
- package/src/mapKernel.ts +42 -16
- package/src/packageVersion.ts +1 -1
package/src/mapKernel.ts
CHANGED
|
@@ -41,7 +41,7 @@ interface IMapMessageHandler {
|
|
|
41
41
|
*/
|
|
42
42
|
submit(op: IMapOperation, localOpMetadata: unknown): void;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
applyStashedOp(op: IMapOperation): unknown;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -101,12 +101,19 @@ export type IMapOperation = IMapKeyOperation | IMapClearOperation;
|
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* Defines the in-memory object structure to be used for the conversion to/from serialized.
|
|
104
|
-
*
|
|
104
|
+
*
|
|
105
|
+
* @remarks Directly used in
|
|
106
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
|
|
107
|
+
* | JSON.stringify}, direct result from
|
|
108
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
|
|
105
109
|
*/
|
|
106
110
|
export interface IMapDataObjectSerializable {
|
|
107
111
|
[key: string]: ISerializableValue;
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Serialized key/value data.
|
|
116
|
+
*/
|
|
110
117
|
export interface IMapDataObjectSerialized {
|
|
111
118
|
[key: string]: ISerializedValue;
|
|
112
119
|
}
|
|
@@ -114,7 +121,7 @@ export interface IMapDataObjectSerialized {
|
|
|
114
121
|
interface IMapKeyEditLocalOpMetadata {
|
|
115
122
|
type: "edit";
|
|
116
123
|
pendingMessageId: number;
|
|
117
|
-
previousValue
|
|
124
|
+
previousValue: ILocalValue;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
interface IMapKeyAddLocalOpMetadata {
|
|
@@ -145,6 +152,23 @@ function isMapLocalOpMetadata(metadata: any): metadata is MapLocalOpMetadata {
|
|
|
145
152
|
(metadata.type === "add" || metadata.type === "edit" || metadata.type === "clear");
|
|
146
153
|
}
|
|
147
154
|
|
|
155
|
+
function createClearLocalOpMetadata(op: IMapClearOperation,
|
|
156
|
+
pendingClearMessageId: number, previousMap?: Map<string, ILocalValue>): IMapClearLocalOpMetadata {
|
|
157
|
+
const localMetadata: IMapClearLocalOpMetadata = {
|
|
158
|
+
type: "clear",
|
|
159
|
+
pendingMessageId: pendingClearMessageId, previousMap,
|
|
160
|
+
};
|
|
161
|
+
return localMetadata;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function createKeyLocalOpMetadata(op: IMapKeyOperation,
|
|
165
|
+
pendingMessageId: number, previousValue?: ILocalValue): MapKeyLocalOpMetadata {
|
|
166
|
+
const localMetadata: MapKeyLocalOpMetadata = previousValue ?
|
|
167
|
+
{ type: "edit", pendingMessageId, previousValue } :
|
|
168
|
+
{ type: "add", pendingMessageId };
|
|
169
|
+
return localMetadata;
|
|
170
|
+
}
|
|
171
|
+
|
|
148
172
|
/**
|
|
149
173
|
* A SharedMap is a map-like distributed data structure.
|
|
150
174
|
*/
|
|
@@ -435,12 +459,12 @@ export class MapKernel {
|
|
|
435
459
|
return true;
|
|
436
460
|
}
|
|
437
461
|
|
|
438
|
-
public
|
|
462
|
+
public tryApplyStashedOp(op: any): unknown {
|
|
439
463
|
const handler = this.messageHandlers.get(op.type);
|
|
440
464
|
if (handler === undefined) {
|
|
441
465
|
throw new Error("no apply stashed op handler");
|
|
442
466
|
}
|
|
443
|
-
return handler.
|
|
467
|
+
return handler.applyStashedOp(op as IMapOperation);
|
|
444
468
|
}
|
|
445
469
|
|
|
446
470
|
/**
|
|
@@ -661,9 +685,11 @@ export class MapKernel {
|
|
|
661
685
|
0x2fd /* pendingMessageId does not match */);
|
|
662
686
|
this.submitMapClearMessage(op, localOpMetadata.previousMap);
|
|
663
687
|
},
|
|
664
|
-
|
|
688
|
+
applyStashedOp: (op: IMapClearOperation) => {
|
|
689
|
+
const copy = new Map<string, ILocalValue>(this.data);
|
|
690
|
+
this.clearCore(true);
|
|
665
691
|
// We don't reuse the metadata pendingMessageId but send a new one on each submit.
|
|
666
|
-
return
|
|
692
|
+
return createClearLocalOpMetadata(op, this.getMapClearMessageId(), copy);
|
|
667
693
|
},
|
|
668
694
|
});
|
|
669
695
|
messageHandlers.set(
|
|
@@ -678,9 +704,10 @@ export class MapKernel {
|
|
|
678
704
|
submit: (op: IMapDeleteOperation, localOpMetadata: unknown) => {
|
|
679
705
|
this.resubmitMapKeyMessage(op, localOpMetadata);
|
|
680
706
|
},
|
|
681
|
-
|
|
707
|
+
applyStashedOp: (op: IMapDeleteOperation) => {
|
|
682
708
|
// We don't reuse the metadata pendingMessageId but send a new one on each submit.
|
|
683
|
-
|
|
709
|
+
const previousValue = this.deleteCore(op.key, true);
|
|
710
|
+
return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);
|
|
684
711
|
},
|
|
685
712
|
});
|
|
686
713
|
messageHandlers.set(
|
|
@@ -698,9 +725,11 @@ export class MapKernel {
|
|
|
698
725
|
submit: (op: IMapSetOperation, localOpMetadata: unknown) => {
|
|
699
726
|
this.resubmitMapKeyMessage(op, localOpMetadata);
|
|
700
727
|
},
|
|
701
|
-
|
|
728
|
+
applyStashedOp: (op: IMapSetOperation) => {
|
|
702
729
|
// We don't reuse the metadata pendingMessageId but send a new one on each submit.
|
|
703
|
-
|
|
730
|
+
const context = this.makeLocal(op.key, op.value);
|
|
731
|
+
const previousValue = this.setCore(op.key, context, true);
|
|
732
|
+
return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);
|
|
704
733
|
},
|
|
705
734
|
});
|
|
706
735
|
|
|
@@ -718,7 +747,7 @@ export class MapKernel {
|
|
|
718
747
|
* @param op - The clear message
|
|
719
748
|
*/
|
|
720
749
|
private submitMapClearMessage(op: IMapClearOperation, previousMap?: Map<string, ILocalValue>): void {
|
|
721
|
-
const metadata =
|
|
750
|
+
const metadata = createClearLocalOpMetadata(op, this.getMapClearMessageId(), previousMap);
|
|
722
751
|
this.submitMessage(op, metadata);
|
|
723
752
|
}
|
|
724
753
|
|
|
@@ -739,10 +768,7 @@ export class MapKernel {
|
|
|
739
768
|
* @param previousValue - The value of the key before this op
|
|
740
769
|
*/
|
|
741
770
|
private submitMapKeyMessage(op: IMapKeyOperation, previousValue?: ILocalValue): void {
|
|
742
|
-
const
|
|
743
|
-
const localMetadata = previousValue ?
|
|
744
|
-
{ type: "edit", pendingMessageId, previousValue } :
|
|
745
|
-
{ type: "add", pendingMessageId };
|
|
771
|
+
const localMetadata = createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);
|
|
746
772
|
this.submitMessage(op, localMetadata);
|
|
747
773
|
}
|
|
748
774
|
|
package/src/packageVersion.ts
CHANGED