@fluidframework/map 2.0.0-rc.2.0.6 → 2.0.0-rc.2.0.7
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/api-report/map.api.md +2 -2
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +4 -6
- package/dist/directory.js.map +1 -1
- package/dist/localValues.d.ts +4 -2
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +8 -9
- package/dist/localValues.js.map +1 -1
- package/dist/map-alpha.d.ts +4 -2
- package/dist/map-untrimmed.d.ts +4 -2
- package/dist/mapKernel.d.ts +1 -0
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +8 -8
- 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.map +1 -1
- package/lib/directory.js +5 -7
- package/lib/directory.js.map +1 -1
- package/lib/localValues.d.ts +4 -2
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +8 -9
- package/lib/localValues.js.map +1 -1
- package/lib/map-alpha.d.ts +4 -2
- package/lib/map-untrimmed.d.ts +4 -2
- package/lib/mapKernel.d.ts +1 -0
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +9 -9
- 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 +16 -16
- package/src/directory.ts +5 -15
- package/src/localValues.ts +8 -13
- package/src/mapKernel.ts +10 -15
- package/src/packageVersion.ts +1 -1
package/src/localValues.ts
CHANGED
|
@@ -103,19 +103,16 @@ export class PlainLocalValue implements ILocalValue {
|
|
|
103
103
|
export class LocalValueMaker {
|
|
104
104
|
/**
|
|
105
105
|
* Create a new LocalValueMaker.
|
|
106
|
+
* @param serializer - The serializer to serialize / parse handles.
|
|
106
107
|
*/
|
|
107
|
-
public constructor() {}
|
|
108
|
+
public constructor(private readonly serializer: IFluidSerializer) {}
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
111
|
* Create a new local value from an incoming serialized value.
|
|
111
112
|
* @param serializable - The serializable value to make local
|
|
112
113
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
serializable: ISerializableValue,
|
|
116
|
-
serializer: IFluidSerializer,
|
|
117
|
-
bind: IFluidHandle,
|
|
118
|
-
): ILocalValue {
|
|
114
|
+
// eslint-disable-next-line import/no-deprecated
|
|
115
|
+
public fromSerializable(serializable: ISerializableValue): ILocalValue {
|
|
119
116
|
// Migrate from old shared value to handles
|
|
120
117
|
if (serializable.type === ValueType[ValueType.Shared]) {
|
|
121
118
|
serializable.type = ValueType[ValueType.Plain];
|
|
@@ -123,14 +120,12 @@ export class LocalValueMaker {
|
|
|
123
120
|
type: "__fluid_handle__",
|
|
124
121
|
url: serializable.value as string,
|
|
125
122
|
};
|
|
126
|
-
|
|
127
|
-
// through a string is necessary to resolve the absolute path of
|
|
128
|
-
// legacy handles (`ValueType.Shared`)
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
130
|
-
serializable.value = serializer.encode(parseHandles(handle, serializer), bind);
|
|
123
|
+
serializable.value = handle;
|
|
131
124
|
}
|
|
132
125
|
|
|
133
|
-
|
|
126
|
+
const translatedValue: unknown = parseHandles(serializable.value, this.serializer);
|
|
127
|
+
|
|
128
|
+
return new PlainLocalValue(translatedValue);
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
/**
|
package/src/mapKernel.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
-
import { IFluidSerializer, ValueType
|
|
7
|
+
import { IFluidSerializer, ValueType } from "@fluidframework/shared-object-base";
|
|
8
8
|
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
9
9
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
10
10
|
// eslint-disable-next-line import/no-deprecated
|
|
@@ -182,7 +182,7 @@ export class MapKernel {
|
|
|
182
182
|
private readonly isAttached: () => boolean,
|
|
183
183
|
private readonly eventEmitter: TypedEventEmitter<ISharedMapEvents>,
|
|
184
184
|
) {
|
|
185
|
-
this.localValueMaker = new LocalValueMaker();
|
|
185
|
+
this.localValueMaker = new LocalValueMaker(serializer);
|
|
186
186
|
this.messageHandlers = this.getMessageHandlers();
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -293,23 +293,20 @@ export class MapKernel {
|
|
|
293
293
|
|
|
294
294
|
// Create a local value and serialize it.
|
|
295
295
|
const localValue = this.localValueMaker.fromInMemory(value);
|
|
296
|
+
const serializableValue = makeSerializable(localValue, this.serializer, this.handle);
|
|
296
297
|
|
|
297
298
|
// Set the value locally.
|
|
298
299
|
const previousValue = this.setCore(key, localValue, true);
|
|
299
300
|
|
|
300
301
|
// If we are not attached, don't submit the op.
|
|
301
302
|
if (!this.isAttached()) {
|
|
302
|
-
// this is necessary to bind the potential handles in the value
|
|
303
|
-
// to this DDS, as we do not walk the object normally unless we
|
|
304
|
-
// are attached
|
|
305
|
-
bindHandles(localValue.value, this.serializer, this.handle);
|
|
306
303
|
return;
|
|
307
304
|
}
|
|
308
305
|
|
|
309
306
|
const op: IMapSetOperation = {
|
|
310
307
|
key,
|
|
311
308
|
type: "set",
|
|
312
|
-
value:
|
|
309
|
+
value: serializableValue,
|
|
313
310
|
};
|
|
314
311
|
this.submitMapKeyMessage(op, previousValue);
|
|
315
312
|
}
|
|
@@ -390,9 +387,7 @@ export class MapKernel {
|
|
|
390
387
|
* @param data - A JSON string containing serialized map data
|
|
391
388
|
*/
|
|
392
389
|
public populateFromSerializable(json: IMapDataObjectSerializable): void {
|
|
393
|
-
for (const [key, serializable] of Object.entries(
|
|
394
|
-
this.serializer.decode(json) as IMapDataObjectSerializable,
|
|
395
|
-
)) {
|
|
390
|
+
for (const [key, serializable] of Object.entries(json)) {
|
|
396
391
|
const localValue = {
|
|
397
392
|
key,
|
|
398
393
|
value: this.makeLocal(key, serializable),
|
|
@@ -402,6 +397,10 @@ export class MapKernel {
|
|
|
402
397
|
}
|
|
403
398
|
}
|
|
404
399
|
|
|
400
|
+
public populate(json: string): void {
|
|
401
|
+
this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);
|
|
402
|
+
}
|
|
403
|
+
|
|
405
404
|
/**
|
|
406
405
|
* Submit the given op if a handler is registered.
|
|
407
406
|
* @param op - The operation to attempt to submit
|
|
@@ -592,11 +591,7 @@ export class MapKernel {
|
|
|
592
591
|
serializable.type === ValueType[ValueType.Plain] ||
|
|
593
592
|
serializable.type === ValueType[ValueType.Shared]
|
|
594
593
|
) {
|
|
595
|
-
return this.localValueMaker.fromSerializable(
|
|
596
|
-
serializable,
|
|
597
|
-
this.serializer,
|
|
598
|
-
this.handle,
|
|
599
|
-
);
|
|
594
|
+
return this.localValueMaker.fromSerializable(serializable);
|
|
600
595
|
} else {
|
|
601
596
|
throw new Error("Unknown local value type");
|
|
602
597
|
}
|
package/src/packageVersion.ts
CHANGED