@fluidframework/map 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.0

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.
Files changed (132) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +10 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +11 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/map.api.md +14 -57
  8. package/dist/directory.d.ts +10 -50
  9. package/dist/directory.d.ts.map +1 -1
  10. package/dist/directory.js +76 -164
  11. package/dist/directory.js.map +1 -1
  12. package/dist/index.d.ts +45 -4
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +43 -8
  15. package/dist/index.js.map +1 -1
  16. package/dist/interfaces.d.ts.map +1 -1
  17. package/dist/interfaces.js.map +1 -1
  18. package/dist/internalInterfaces.d.ts +2 -2
  19. package/dist/internalInterfaces.d.ts.map +1 -1
  20. package/dist/internalInterfaces.js.map +1 -1
  21. package/dist/localValues.d.ts +3 -5
  22. package/dist/localValues.d.ts.map +1 -1
  23. package/dist/localValues.js +9 -8
  24. package/dist/localValues.js.map +1 -1
  25. package/dist/map-alpha.d.ts +31 -116
  26. package/dist/map-beta.d.ts +24 -105
  27. package/dist/map-public.d.ts +24 -105
  28. package/dist/map-untrimmed.d.ts +31 -116
  29. package/dist/map.d.ts +4 -23
  30. package/dist/map.d.ts.map +1 -1
  31. package/dist/map.js +6 -29
  32. package/dist/map.js.map +1 -1
  33. package/dist/mapKernel.d.ts +3 -4
  34. package/dist/mapKernel.d.ts.map +1 -1
  35. package/dist/mapKernel.js +30 -35
  36. package/dist/mapKernel.js.map +1 -1
  37. package/dist/package.json +3 -0
  38. package/dist/packageVersion.d.ts +1 -1
  39. package/dist/packageVersion.js +1 -1
  40. package/dist/packageVersion.js.map +1 -1
  41. package/dist/tsdoc-metadata.json +1 -1
  42. package/lib/{directory.d.mts → directory.d.ts} +11 -51
  43. package/lib/directory.d.ts.map +1 -0
  44. package/lib/{directory.mjs → directory.js} +77 -165
  45. package/lib/directory.js.map +1 -0
  46. package/lib/index.d.ts +61 -0
  47. package/lib/index.d.ts.map +1 -0
  48. package/lib/index.js +55 -0
  49. package/lib/index.js.map +1 -0
  50. package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
  51. package/lib/interfaces.d.ts.map +1 -0
  52. package/lib/{interfaces.mjs → interfaces.js} +1 -1
  53. package/lib/interfaces.js.map +1 -0
  54. package/lib/{internalInterfaces.d.mts → internalInterfaces.d.ts} +3 -3
  55. package/lib/internalInterfaces.d.ts.map +1 -0
  56. package/lib/{internalInterfaces.mjs → internalInterfaces.js} +1 -1
  57. package/lib/internalInterfaces.js.map +1 -0
  58. package/lib/{localValues.d.mts → localValues.d.ts} +4 -6
  59. package/lib/localValues.d.ts.map +1 -0
  60. package/lib/{localValues.mjs → localValues.js} +10 -9
  61. package/lib/localValues.js.map +1 -0
  62. package/lib/{map-alpha.d.mts → map-alpha.d.ts} +43 -116
  63. package/lib/{map-beta.d.mts → map-beta.d.ts} +36 -105
  64. package/lib/{map-public.d.mts → map-public.d.ts} +36 -105
  65. package/lib/{map-untrimmed.d.mts → map-untrimmed.d.ts} +43 -116
  66. package/lib/{map.d.mts → map.d.ts} +5 -24
  67. package/lib/map.d.ts.map +1 -0
  68. package/lib/{map.mjs → map.js} +5 -28
  69. package/lib/map.js.map +1 -0
  70. package/lib/{mapKernel.d.mts → mapKernel.d.ts} +4 -5
  71. package/lib/mapKernel.d.ts.map +1 -0
  72. package/lib/{mapKernel.mjs → mapKernel.js} +32 -37
  73. package/lib/mapKernel.js.map +1 -0
  74. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  75. package/lib/packageVersion.d.ts.map +1 -0
  76. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  77. package/lib/packageVersion.js.map +1 -0
  78. package/lib/test/memory/directory.spec.js +71 -0
  79. package/lib/test/memory/directory.spec.js.map +1 -0
  80. package/lib/test/memory/map.spec.js +71 -0
  81. package/lib/test/memory/map.spec.js.map +1 -0
  82. package/lib/test/mocha/directory.order.spec.js +422 -0
  83. package/lib/test/mocha/directory.order.spec.js.map +1 -0
  84. package/lib/test/mocha/directory.snapshot.spec.js +111 -0
  85. package/lib/test/mocha/directory.snapshot.spec.js.map +1 -0
  86. package/lib/test/mocha/directory.spec.js +1406 -0
  87. package/lib/test/mocha/directory.spec.js.map +1 -0
  88. package/lib/test/mocha/directoryEquivalenceUtils.js +36 -0
  89. package/lib/test/mocha/directoryEquivalenceUtils.js.map +1 -0
  90. package/lib/test/mocha/directoryFuzzTests.spec.js +337 -0
  91. package/lib/test/mocha/directoryFuzzTests.spec.js.map +1 -0
  92. package/lib/test/mocha/dirname.cjs +16 -0
  93. package/lib/test/mocha/dirname.cjs.map +1 -0
  94. package/lib/test/mocha/map.fuzz.spec.js +114 -0
  95. package/lib/test/mocha/map.fuzz.spec.js.map +1 -0
  96. package/lib/test/mocha/map.spec.js +685 -0
  97. package/lib/test/mocha/map.spec.js.map +1 -0
  98. package/lib/test/mocha/rebasing.spec.js +158 -0
  99. package/lib/test/mocha/rebasing.spec.js.map +1 -0
  100. package/lib/test/mocha/reconnection.spec.js +327 -0
  101. package/lib/test/mocha/reconnection.spec.js.map +1 -0
  102. package/lib/test/types/validateMapPrevious.generated.js +66 -0
  103. package/lib/test/types/validateMapPrevious.generated.js.map +1 -0
  104. package/package.json +55 -52
  105. package/src/directory.ts +122 -217
  106. package/src/index.ts +57 -4
  107. package/src/interfaces.ts +2 -2
  108. package/src/internalInterfaces.ts +2 -2
  109. package/src/localValues.ts +14 -9
  110. package/src/map.ts +7 -32
  111. package/src/mapKernel.ts +40 -42
  112. package/src/packageVersion.ts +1 -1
  113. package/tsconfig.cjs.json +7 -0
  114. package/tsconfig.json +2 -5
  115. package/lib/directory.d.mts.map +0 -1
  116. package/lib/directory.mjs.map +0 -1
  117. package/lib/index.d.mts +0 -9
  118. package/lib/index.d.mts.map +0 -1
  119. package/lib/index.mjs +0 -8
  120. package/lib/index.mjs.map +0 -1
  121. package/lib/interfaces.d.mts.map +0 -1
  122. package/lib/interfaces.mjs.map +0 -1
  123. package/lib/internalInterfaces.d.mts.map +0 -1
  124. package/lib/internalInterfaces.mjs.map +0 -1
  125. package/lib/localValues.d.mts.map +0 -1
  126. package/lib/localValues.mjs.map +0 -1
  127. package/lib/map.d.mts.map +0 -1
  128. package/lib/map.mjs.map +0 -1
  129. package/lib/mapKernel.d.mts.map +0 -1
  130. package/lib/mapKernel.mjs.map +0 -1
  131. package/lib/packageVersion.d.mts.map +0 -1
  132. package/lib/packageVersion.mjs.map +0 -1
@@ -1,3 +1,15 @@
1
+ /**
2
+ * The `map` library provides interfaces and implementing classes for map-like distributed data structures.
3
+ *
4
+ * @remarks The following distributed data structures are defined in this library:
5
+ *
6
+ * - {@link SharedMap}
7
+ *
8
+ * - {@link SharedDirectory}
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
1
13
  import { IChannelAttributes } from '@fluidframework/datastore-definitions';
2
14
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
3
15
  import { IChannelServices } from '@fluidframework/datastore-definitions';
@@ -22,7 +34,7 @@ import { SharedObject } from '@fluidframework/shared-object-base';
22
34
  * @sealed
23
35
  * @alpha
24
36
  */
25
- export declare class DirectoryFactory implements IChannelFactory {
37
+ export declare class DirectoryFactory implements IChannelFactory<ISharedDirectory> {
26
38
  /**
27
39
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
28
40
  */
@@ -599,17 +611,15 @@ export declare interface IValueChanged {
599
611
  * @alpha
600
612
  */
601
613
  export declare class LocalValueMaker {
602
- private readonly serializer;
603
614
  /**
604
615
  * Create a new LocalValueMaker.
605
- * @param serializer - The serializer to serialize / parse handles.
606
616
  */
607
- constructor(serializer: IFluidSerializer);
617
+ constructor();
608
618
  /**
609
619
  * Create a new local value from an incoming serialized value.
610
620
  * @param serializable - The serializable value to make local
611
621
  */
612
- fromSerializable(serializable: ISerializableValue): ILocalValue;
622
+ fromSerializable(serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle): ILocalValue;
613
623
  /**
614
624
  * Create a new local value containing a given plain object.
615
625
  * @param value - The value to store
@@ -619,12 +629,12 @@ export declare class LocalValueMaker {
619
629
  }
620
630
 
621
631
  /**
622
- * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
632
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMap}.
623
633
  *
624
634
  * @sealed
625
635
  * @alpha
626
636
  */
627
- export declare class MapFactory implements IChannelFactory {
637
+ export declare class MapFactory implements IChannelFactory<ISharedMap> {
628
638
  /**
629
639
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
630
640
  */
@@ -673,13 +683,13 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
673
683
  * @param id - Optional name of the shared directory
674
684
  * @returns Newly create shared directory (but not attached yet)
675
685
  */
676
- static create(runtime: IFluidDataStoreRuntime, id?: string): SharedDirectory;
686
+ static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedDirectory;
677
687
  /**
678
688
  * Get a factory for SharedDirectory to register with the data store.
679
689
  *
680
690
  * @returns A factory that creates and load SharedDirectory
681
691
  */
682
- static getFactory(): IChannelFactory;
692
+ static getFactory(): IChannelFactory<ISharedDirectory>;
683
693
  /**
684
694
  * String representation for the class.
685
695
  */
@@ -854,7 +864,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
854
864
  /**
855
865
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
856
866
  */
857
- protected applyStashedOp(op: unknown): unknown;
867
+ protected applyStashedOp(op: unknown): void;
858
868
  private serializeDirectory;
859
869
  }
860
870
 
@@ -863,7 +873,12 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
863
873
  * @public
864
874
  * @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.
865
875
  */
866
- export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
876
+ export declare const SharedMap: {
877
+ /**
878
+ * Get a factory for SharedMap to register with the data store.
879
+ * @returns A factory that creates SharedMaps and loads them from storage.
880
+ */
881
+ getFactory(): IChannelFactory<ISharedMap>;
867
882
  /**
868
883
  * Create a new shared map.
869
884
  * @param runtime - The data store runtime that the new shared map belongs to.
@@ -876,110 +891,22 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
876
891
  * ```typescript
877
892
  * const myMap = SharedMap.create(this.runtime, id);
878
893
  * ```
879
- */
880
- static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
881
- /**
882
- * Get a factory for SharedMap to register with the data store.
883
- * @returns A factory that creates SharedMaps and loads them from storage.
884
- */
885
- static getFactory(): IChannelFactory;
886
- /**
887
- * String representation for the class.
888
- */
889
- readonly [Symbol.toStringTag]: string;
890
- /**
891
- * MapKernel which manages actual map operations.
892
- */
893
- private readonly kernel;
894
- /**
895
- * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
896
- *
897
- * @param id - String identifier.
898
- * @param runtime - Data store runtime.
899
- * @param attributes - The attributes for the map.
900
- */
901
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
902
- /**
903
- * Get an iterator over the keys in this map.
904
- * @returns The iterator
905
- */
906
- keys(): IterableIterator<string>;
907
- /**
908
- * Get an iterator over the entries in this map.
909
- * @returns The iterator
910
- */
911
- entries(): IterableIterator<[string, any]>;
912
- /**
913
- * Get an iterator over the values in this map.
914
- * @returns The iterator
915
- */
916
- values(): IterableIterator<any>;
917
- /**
918
- * Get an iterator over the entries in this map.
919
- * @returns The iterator
920
- */
921
- [Symbol.iterator](): IterableIterator<[string, any]>;
922
- /**
923
- * The number of key/value pairs stored in the map.
924
- */
925
- get size(): number;
926
- /**
927
- * Executes the given callback on each entry in the map.
928
- * @param callbackFn - Callback function
929
- */
930
- forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
931
- /**
932
- * {@inheritDoc ISharedMap.get}
933
- */
934
- get<T = any>(key: string): T | undefined;
935
- /**
936
- * Check if a key exists in the map.
937
- * @param key - The key to check
938
- * @returns True if the key exists, false otherwise
939
- */
940
- has(key: string): boolean;
941
- /**
942
- * {@inheritDoc ISharedMap.set}
943
- */
944
- set(key: string, value: unknown): this;
945
- /**
946
- * Delete a key from the map.
947
- * @param key - Key to delete
948
- * @returns True if the key existed and was deleted, false if it did not exist
949
- */
950
- delete(key: string): boolean;
951
- /**
952
- * Clear all data from the map.
953
- */
954
- clear(): void;
955
- /**
956
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
957
- */
958
- protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
959
- /**
960
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
961
- */
962
- protected loadCore(storage: IChannelStorageService): Promise<void>;
963
- /**
964
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
965
- */
966
- protected onDisconnect(): void;
967
- /**
968
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
969
- */
970
- protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
971
- /**
972
- * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
973
- */
974
- protected applyStashedOp(content: unknown): unknown;
975
- /**
976
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
977
- */
978
- protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
979
- /**
980
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
981
- */
982
- protected rollback(content: unknown, localOpMetadata: unknown): void;
983
- }
894
+ * @privateRemarks
895
+ * TODO:
896
+ * Clarify how this differs from `MapFactory.create`.
897
+ * They are different since making this forward to MapFactory.create breaks some things,
898
+ * but the difference is unclear from the documentation.
899
+ */
900
+ create(runtime: IFluidDataStoreRuntime, id?: string): ISharedMap;
901
+ };
902
+
903
+ /**
904
+ * {@inheritDoc ISharedMap}
905
+ * @public
906
+ * @deprecated Use ISharedMap instead.
907
+ * @privateRemarks
908
+ * This alias is for legacy compat from when the SharedMap class was exported as public.
909
+ */
910
+ export declare type SharedMap = ISharedMap;
984
911
 
985
912
  export { }
@@ -6,14 +6,14 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
7
7
  import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { ISharedMap, ISharedMapEvents } from "./interfaces.mjs";
9
+ import { ISharedMap, ISharedMapEvents } from "./interfaces.js";
10
10
  /**
11
- * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
11
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMap}.
12
12
  *
13
13
  * @sealed
14
14
  * @alpha
15
15
  */
16
- export declare class MapFactory implements IChannelFactory {
16
+ export declare class MapFactory implements IChannelFactory<ISharedMap> {
17
17
  /**
18
18
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
19
19
  */
@@ -45,25 +45,6 @@ export declare class MapFactory implements IChannelFactory {
45
45
  * @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.
46
46
  */
47
47
  export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
48
- /**
49
- * Create a new shared map.
50
- * @param runtime - The data store runtime that the new shared map belongs to.
51
- * @param id - Optional name of the shared map.
52
- * @returns Newly created shared map.
53
- *
54
- * @example
55
- * To create a `SharedMap`, call the static create method:
56
- *
57
- * ```typescript
58
- * const myMap = SharedMap.create(this.runtime, id);
59
- * ```
60
- */
61
- static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
62
- /**
63
- * Get a factory for SharedMap to register with the data store.
64
- * @returns A factory that creates SharedMaps and loads them from storage.
65
- */
66
- static getFactory(): IChannelFactory;
67
48
  /**
68
49
  * String representation for the class.
69
50
  */
@@ -152,7 +133,7 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
152
133
  /**
153
134
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
154
135
  */
155
- protected applyStashedOp(content: unknown): unknown;
136
+ protected applyStashedOp(content: unknown): void;
156
137
  /**
157
138
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
158
139
  */
@@ -162,4 +143,4 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
162
143
  */
163
144
  protected rollback(content: unknown, localOpMetadata: unknown): void;
164
145
  }
165
- //# sourceMappingURL=map.d.mts.map
146
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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;AAE/F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAW/D;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,eAAe,CAAC,UAAU,CAAC;IAC7D;;OAEG;IACH,gBAAuB,IAAI,2CAA2C;IAEtE;;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AI;IAK1F;;OAEG;IAGI,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI/C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAK7C;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInC;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACH,SAAS,CAAC,aAAa,CACtB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAyExB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAIxE;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhD;;OAEG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAUP;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAGpE"}
@@ -7,11 +7,11 @@ import { MessageType } from "@fluidframework/protocol-definitions";
7
7
  import { readAndParse } from "@fluidframework/driver-utils";
8
8
  import { SharedObject } from "@fluidframework/shared-object-base";
9
9
  import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
10
- import { MapKernel } from "./mapKernel.mjs";
11
- import { pkgVersion } from "./packageVersion.mjs";
10
+ import { MapKernel } from "./mapKernel.js";
11
+ import { pkgVersion } from "./packageVersion.js";
12
12
  const snapshotFileName = "header";
13
13
  /**
14
- * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
14
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMap}.
15
15
  *
16
16
  * @sealed
17
17
  * @alpha
@@ -64,29 +64,6 @@ MapFactory.Attributes = {
64
64
  * @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.
65
65
  */
66
66
  export class SharedMap extends SharedObject {
67
- /**
68
- * Create a new shared map.
69
- * @param runtime - The data store runtime that the new shared map belongs to.
70
- * @param id - Optional name of the shared map.
71
- * @returns Newly created shared map.
72
- *
73
- * @example
74
- * To create a `SharedMap`, call the static create method:
75
- *
76
- * ```typescript
77
- * const myMap = SharedMap.create(this.runtime, id);
78
- * ```
79
- */
80
- static create(runtime, id) {
81
- return runtime.createChannel(id, MapFactory.Type);
82
- }
83
- /**
84
- * Get a factory for SharedMap to register with the data store.
85
- * @returns A factory that creates SharedMaps and loads them from storage.
86
- */
87
- static getFactory() {
88
- return new MapFactory();
89
- }
90
67
  /**
91
68
  * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
92
69
  *
@@ -287,7 +264,7 @@ export class SharedMap extends SharedObject {
287
264
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
288
265
  */
289
266
  applyStashedOp(content) {
290
- return this.kernel.tryApplyStashedOp(content);
267
+ this.kernel.tryApplyStashedOp(content);
291
268
  }
292
269
  /**
293
270
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
@@ -304,4 +281,4 @@ export class SharedMap extends SharedObject {
304
281
  this.kernel.rollback(content, localOpMetadata);
305
282
  }
306
283
  }
307
- //# sourceMappingURL=map.mjs.map
284
+ //# sourceMappingURL=map.js.map
package/lib/map.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceR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Ae,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE;YAC3C,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC5B,OAAO,CAAC,QAAyB,EACjC,KAAK,EACL,eAAe,CACf,CAAC;SACF;IACF,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISharedMap, ISharedMapEvents } from \"./interfaces.js\";\nimport { IMapDataObjectSerializable, IMapOperation, MapKernel } from \"./mapKernel.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMap}.\n *\n * @sealed\n * @alpha\n */\nexport class MapFactory implements IChannelFactory<ISharedMap> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/map\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: MapFactory.Type,\n\t\tsnapshotFormatVersion: \"0.2\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn MapFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn MapFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMap> {\n\t\tconst map = new SharedMap(id, runtime, attributes);\n\t\tawait map.load(services);\n\n\t\treturn map;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap {\n\t\tconst map = new SharedMap(id, runtime, MapFactory.Attributes);\n\t\tmap.initializeLocal();\n\n\t\treturn map;\n\t}\n}\n\n/**\n * {@inheritDoc ISharedMap}\n * @public\n * @deprecated Please use SharedTree for new containers. SharedMap is supported for loading preexisting Fluid Framework 1.0 containers only.\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n\t/**\n\t * MapKernel which manages actual map operations.\n\t */\n\tprivate readonly kernel: MapKernel;\n\n\t/**\n\t * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n\t *\n\t * @param id - String identifier.\n\t * @param runtime - Data store runtime.\n\t * @param attributes - The attributes for the map.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_map_\");\n\t\tthis.kernel = new MapKernel(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\t() => this.isAttached(),\n\t\t\tthis,\n\t\t);\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.kernel.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.kernel.values();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.kernel.size;\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.kernel.forEach(callbackFn);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.kernel.get<T>(key);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.kernel.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): this {\n\t\tthis.kernel.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.kernel.delete(key);\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.kernel.clear();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tlet currentSize = 0;\n\t\tlet counter = 0;\n\t\tlet headerBlob: IMapDataObjectSerializable = {};\n\t\tconst blobs: string[] = [];\n\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\tconst data = this.kernel.getSerializedStorage(serializer);\n\n\t\t// If single property exceeds this size, it goes into its own blob\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\t// Maximum blob size for multiple map properties\n\t\t// Should be bigger than MinValueSizeSeparateSnapshotBlob\n\t\tconst MaxSnapshotBlobSize = 16 * 1024;\n\n\t\t// Partitioning algorithm:\n\t\t// 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n\t\t// Naming (across snapshots) of such blob does not have to be stable across snapshots,\n\t\t// As de-duping process (in driver) should not care about paths, only content.\n\t\t// 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n\t\t// This process does not produce stable partitioning. This means\n\t\t// modification (including addition / deletion) of property can shift properties across blobs\n\t\t// and result in non-incremental snapshot.\n\t\t// This can be improved in the future, without being format breaking change, as loading sequence\n\t\t// loads all blobs at once and partitioning schema has no impact on that process.\n\t\tfor (const key of Object.keys(data)) {\n\t\t\tconst value = data[key];\n\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\tcounter++;\n\t\t\t\tblobs.push(blobName);\n\t\t\t\tconst content: IMapDataObjectSerializable = {\n\t\t\t\t\t[key]: {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tvalue: JSON.parse(value.value) as unknown,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(content));\n\t\t\t} else {\n\t\t\t\tcurrentSize += value.type.length + 21; // Approximation cost of property header\n\t\t\t\tif (value.value) {\n\t\t\t\t\tcurrentSize += value.value.length;\n\t\t\t\t}\n\n\t\t\t\tif (currentSize > MaxSnapshotBlobSize) {\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(headerBlob));\n\t\t\t\t\theaderBlob = {};\n\t\t\t\t\tcurrentSize = 0;\n\t\t\t\t}\n\t\t\t\theaderBlob[key] = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue:\n\t\t\t\t\t\tvalue.value === undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (JSON.parse(value.value) as unknown),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst header: IMapSerializationFormat = {\n\t\t\tblobs,\n\t\t\tcontent: headerBlob,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(header));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst json = await readAndParse<object>(storage, snapshotFileName);\n\t\tconst newFormat = json as IMapSerializationFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\tthis.kernel.populateFromSerializable(newFormat.content);\n\t\t\tawait Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (value) => {\n\t\t\t\t\tconst content = await readAndParse<IMapDataObjectSerializable>(storage, value);\n\t\t\t\t\tthis.kernel.populateFromSerializable(content);\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: unknown): void {\n\t\tthis.kernel.tryApplyStashedOp(content as IMapOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\tlocal,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
@@ -5,8 +5,8 @@
5
5
  import { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
7
7
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
8
- import { ISerializableValue, ISerializedValue, ISharedMapEvents } from "./interfaces.mjs";
9
- import { IMapSetOperation, IMapDeleteOperation, IMapClearOperation } from "./internalInterfaces.mjs";
8
+ import { ISerializableValue, ISerializedValue, ISharedMapEvents } from "./interfaces.js";
9
+ import { IMapSetOperation, IMapDeleteOperation, IMapClearOperation } from "./internalInterfaces.js";
10
10
  /**
11
11
  * Map key operations are one of several types.
12
12
  */
@@ -141,7 +141,6 @@ export declare class MapKernel {
141
141
  * @param data - A JSON string containing serialized map data
142
142
  */
143
143
  populateFromSerializable(json: IMapDataObjectSerializable): void;
144
- populate(json: string): void;
145
144
  /**
146
145
  * Submit the given op if a handler is registered.
147
146
  * @param op - The operation to attempt to submit
@@ -151,7 +150,7 @@ export declare class MapKernel {
151
150
  * @returns True if the operation was submitted, false otherwise.
152
151
  */
153
152
  trySubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean;
154
- tryApplyStashedOp(op: IMapOperation): unknown;
153
+ tryApplyStashedOp(op: IMapOperation): void;
155
154
  /**
156
155
  * Process the given op if a handler is registered.
157
156
  * @param op - The message to process
@@ -237,4 +236,4 @@ export declare class MapKernel {
237
236
  */
238
237
  private resubmitMapKeyMessage;
239
238
  }
240
- //# sourceMappingURL=mapKernel.d.mts.map
239
+ //# sourceMappingURL=map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IAoBpB;;;;OAIG;IACI,oBAAoB,CAAC,UAAU,EAAE,gBAAgB,GAAG,wBAAwB;IAQ5E,sBAAsB,CAAC,UAAU,EAAE,gBAAgB,GAAG,0BAA0B;IAQhF,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM;IAItD;;;OAGG;IACI,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI;IAavE;;;;;;;OAOG;IACI,gBAAgB,CAAC,EAAE,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO;IAStE,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAoBjD;;;;;;;OAOG;IACI,iBAAiB,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO;IAW9F;;;;OAIG;IAEI,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IA+CxD;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAQf;;;OAGG;IACH,OAAO,CAAC,SAAS;IAKjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAelB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAiB9B;;;;;;;;;OASG;IAEH,OAAO,CAAC,SAAS;IAejB;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA2C/B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAiE1B,OAAO,CAAC,oBAAoB;IAM5B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,kBAAkB;IAW1B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;CA8B7B"}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ValueType } from "@fluidframework/shared-object-base";
6
- import { assert } from "@fluidframework/core-utils";
7
- import { LocalValueMaker, makeSerializable } from "./localValues.mjs";
5
+ import { ValueType, bindHandles } from "@fluidframework/shared-object-base";
6
+ import { assert, unreachableCase } from "@fluidframework/core-utils";
7
+ import { LocalValueMaker, makeSerializable } from "./localValues.js";
8
8
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
9
9
  function isMapKeyLocalOpMetadata(metadata) {
10
10
  return (metadata !== undefined &&
@@ -81,7 +81,7 @@ export class MapKernel {
81
81
  * The pending ids of any clears that have been performed locally but not yet ack'd from the server
82
82
  */
83
83
  this.pendingClearMessageIds = [];
84
- this.localValueMaker = new LocalValueMaker(serializer);
84
+ this.localValueMaker = new LocalValueMaker();
85
85
  this.messageHandlers = this.getMessageHandlers();
86
86
  }
87
87
  /**
@@ -181,17 +181,20 @@ export class MapKernel {
181
181
  }
182
182
  // Create a local value and serialize it.
183
183
  const localValue = this.localValueMaker.fromInMemory(value);
184
- const serializableValue = makeSerializable(localValue, this.serializer, this.handle);
185
184
  // Set the value locally.
186
185
  const previousValue = this.setCore(key, localValue, true);
187
186
  // If we are not attached, don't submit the op.
188
187
  if (!this.isAttached()) {
188
+ // this is necessary to bind the potential handles in the value
189
+ // to this DDS, as we do not walk the object normally unless we
190
+ // are attached
191
+ bindHandles(localValue.value, this.serializer, this.handle);
189
192
  return;
190
193
  }
191
194
  const op = {
192
195
  key,
193
196
  type: "set",
194
- value: serializableValue,
197
+ value: { type: localValue.type, value: localValue.value },
195
198
  };
196
199
  this.submitMapKeyMessage(op, previousValue);
197
200
  }
@@ -259,7 +262,7 @@ export class MapKernel {
259
262
  * @param data - A JSON string containing serialized map data
260
263
  */
261
264
  populateFromSerializable(json) {
262
- for (const [key, serializable] of Object.entries(json)) {
265
+ for (const [key, serializable] of Object.entries(this.serializer.decode(json))) {
263
266
  const localValue = {
264
267
  key,
265
268
  value: this.makeLocal(key, serializable),
@@ -267,9 +270,6 @@ export class MapKernel {
267
270
  this.data.set(localValue.key, localValue.value);
268
271
  }
269
272
  }
270
- populate(json) {
271
- this.populateFromSerializable(JSON.parse(json));
272
- }
273
273
  /**
274
274
  * Submit the given op if a handler is registered.
275
275
  * @param op - The operation to attempt to submit
@@ -287,11 +287,23 @@ export class MapKernel {
287
287
  return true;
288
288
  }
289
289
  tryApplyStashedOp(op) {
290
- const handler = this.messageHandlers.get(op.type);
291
- if (handler === undefined) {
292
- throw new Error("no apply stashed op handler");
290
+ switch (op.type) {
291
+ case "clear": {
292
+ this.clear();
293
+ break;
294
+ }
295
+ case "delete": {
296
+ this.delete(op.key);
297
+ break;
298
+ }
299
+ case "set": {
300
+ this.set(op.key, this.makeLocal(op.key, op.value).value);
301
+ break;
302
+ }
303
+ default: {
304
+ unreachableCase(op);
305
+ }
293
306
  }
294
- return handler.applyStashedOp(op);
295
307
  }
296
308
  /**
297
309
  * Process the given op if a handler is registered.
@@ -428,7 +440,7 @@ export class MapKernel {
428
440
  makeLocal(key, serializable) {
429
441
  if (serializable.type === ValueType[ValueType.Plain] ||
430
442
  serializable.type === ValueType[ValueType.Shared]) {
431
- return this.localValueMaker.fromSerializable(serializable);
443
+ return this.localValueMaker.fromSerializable(serializable, this.serializer, this.handle);
432
444
  }
433
445
  else {
434
446
  throw new Error("Unknown local value type");
@@ -497,12 +509,6 @@ export class MapKernel {
497
509
  assert(pendingClearMessageId === localOpMetadata.pendingMessageId, 0x2fd /* pendingMessageId does not match */);
498
510
  this.submitMapClearMessage(op, localOpMetadata.previousMap);
499
511
  },
500
- applyStashedOp: (op) => {
501
- const copy = new Map(this.data);
502
- this.clearCore(true);
503
- // We don't reuse the metadata pendingMessageId but send a new one on each submit.
504
- return createClearLocalOpMetadata(op, this.getMapClearMessageId(), copy);
505
- },
506
512
  });
507
513
  messageHandlers.set("delete", {
508
514
  process: (op, local, localOpMetadata) => {
@@ -514,11 +520,6 @@ export class MapKernel {
514
520
  submit: (op, localOpMetadata) => {
515
521
  this.resubmitMapKeyMessage(op, localOpMetadata);
516
522
  },
517
- applyStashedOp: (op) => {
518
- // We don't reuse the metadata pendingMessageId but send a new one on each submit.
519
- const previousValue = this.deleteCore(op.key, true);
520
- return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);
521
- },
522
523
  });
523
524
  messageHandlers.set("set", {
524
525
  process: (op, local, localOpMetadata) => {
@@ -532,12 +533,6 @@ export class MapKernel {
532
533
  submit: (op, localOpMetadata) => {
533
534
  this.resubmitMapKeyMessage(op, localOpMetadata);
534
535
  },
535
- applyStashedOp: (op) => {
536
- // We don't reuse the metadata pendingMessageId but send a new one on each submit.
537
- const context = this.makeLocal(op.key, op.value);
538
- const previousValue = this.setCore(op.key, context, true);
539
- return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);
540
- },
541
536
  });
542
537
  return messageHandlers;
543
538
  }
@@ -557,11 +552,11 @@ export class MapKernel {
557
552
  getMapKeyMessageId(op) {
558
553
  const pendingMessageId = ++this.pendingMessageId;
559
554
  const pendingMessageIds = this.pendingKeys.get(op.key);
560
- if (pendingMessageIds !== undefined) {
561
- pendingMessageIds.push(pendingMessageId);
555
+ if (pendingMessageIds === undefined) {
556
+ this.pendingKeys.set(op.key, [pendingMessageId]);
562
557
  }
563
558
  else {
564
- this.pendingKeys.set(op.key, [pendingMessageId]);
559
+ pendingMessageIds.push(pendingMessageId);
565
560
  }
566
561
  return pendingMessageId;
567
562
  }
@@ -586,7 +581,7 @@ export class MapKernel {
586
581
  if (pendingMessageIds === undefined) {
587
582
  return;
588
583
  }
589
- const index = pendingMessageIds.findIndex((id) => id === localOpMetadata.pendingMessageId);
584
+ const index = pendingMessageIds.indexOf(localOpMetadata.pendingMessageId);
590
585
  if (index === -1) {
591
586
  return;
592
587
  }
@@ -602,4 +597,4 @@ export class MapKernel {
602
597
  this.submitMessage(op, localMetadata);
603
598
  }
604
599
  }
605
- //# sourceMappingURL=mapKernel.mjs.map
600
+ //# sourceMappingURL=mapKernel.js.map