@fluid-experimental/dds-interceptions 2.0.0-dev-rc.2.0.0.245554

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 (83) hide show
  1. package/.eslintrc.cjs +14 -0
  2. package/.mocharc.cjs +12 -0
  3. package/CHANGELOG.md +93 -0
  4. package/LICENSE +21 -0
  5. package/README.md +95 -0
  6. package/api-extractor-cjs.json +8 -0
  7. package/api-extractor-lint.json +4 -0
  8. package/api-extractor.json +4 -0
  9. package/api-report/dds-interceptions.api.md +24 -0
  10. package/dist/dds-interceptions-alpha.d.ts +13 -0
  11. package/dist/dds-interceptions-beta.d.ts +19 -0
  12. package/dist/dds-interceptions-public.d.ts +19 -0
  13. package/dist/dds-interceptions-untrimmed.d.ts +67 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +13 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/map/index.d.ts +7 -0
  19. package/dist/map/index.d.ts.map +1 -0
  20. package/dist/map/index.js +12 -0
  21. package/dist/map/index.js.map +1 -0
  22. package/dist/map/sharedDirectoryWithInterception.d.ts +29 -0
  23. package/dist/map/sharedDirectoryWithInterception.d.ts.map +1 -0
  24. package/dist/map/sharedDirectoryWithInterception.js +117 -0
  25. package/dist/map/sharedDirectoryWithInterception.js.map +1 -0
  26. package/dist/map/sharedMapWithInterception.d.ts +23 -0
  27. package/dist/map/sharedMapWithInterception.d.ts.map +1 -0
  28. package/dist/map/sharedMapWithInterception.js +49 -0
  29. package/dist/map/sharedMapWithInterception.js.map +1 -0
  30. package/dist/package.json +3 -0
  31. package/dist/sequence/index.d.ts +6 -0
  32. package/dist/sequence/index.d.ts.map +1 -0
  33. package/dist/sequence/index.js +10 -0
  34. package/dist/sequence/index.js.map +1 -0
  35. package/dist/sequence/sharedStringWithInterception.d.ts +27 -0
  36. package/dist/sequence/sharedStringWithInterception.d.ts.map +1 -0
  37. package/dist/sequence/sharedStringWithInterception.js +207 -0
  38. package/dist/sequence/sharedStringWithInterception.js.map +1 -0
  39. package/dist/tsdoc-metadata.json +11 -0
  40. package/lib/dds-interceptions-alpha.d.ts +13 -0
  41. package/lib/dds-interceptions-beta.d.ts +19 -0
  42. package/lib/dds-interceptions-public.d.ts +19 -0
  43. package/lib/dds-interceptions-untrimmed.d.ts +67 -0
  44. package/lib/index.d.ts +7 -0
  45. package/lib/index.d.ts.map +1 -0
  46. package/lib/index.js +7 -0
  47. package/lib/index.js.map +1 -0
  48. package/lib/map/index.d.ts +7 -0
  49. package/lib/map/index.d.ts.map +1 -0
  50. package/lib/map/index.js +7 -0
  51. package/lib/map/index.js.map +1 -0
  52. package/lib/map/sharedDirectoryWithInterception.d.ts +29 -0
  53. package/lib/map/sharedDirectoryWithInterception.d.ts.map +1 -0
  54. package/lib/map/sharedDirectoryWithInterception.js +113 -0
  55. package/lib/map/sharedDirectoryWithInterception.js.map +1 -0
  56. package/lib/map/sharedMapWithInterception.d.ts +23 -0
  57. package/lib/map/sharedMapWithInterception.d.ts.map +1 -0
  58. package/lib/map/sharedMapWithInterception.js +45 -0
  59. package/lib/map/sharedMapWithInterception.js.map +1 -0
  60. package/lib/sequence/index.d.ts +6 -0
  61. package/lib/sequence/index.d.ts.map +1 -0
  62. package/lib/sequence/index.js +6 -0
  63. package/lib/sequence/index.js.map +1 -0
  64. package/lib/sequence/sharedStringWithInterception.d.ts +27 -0
  65. package/lib/sequence/sharedStringWithInterception.d.ts.map +1 -0
  66. package/lib/sequence/sharedStringWithInterception.js +203 -0
  67. package/lib/sequence/sharedStringWithInterception.js.map +1 -0
  68. package/lib/test/sharedDirectoryWithInterception.spec.js +282 -0
  69. package/lib/test/sharedDirectoryWithInterception.spec.js.map +1 -0
  70. package/lib/test/sharedMapWithInterception.spec.js +105 -0
  71. package/lib/test/sharedMapWithInterception.spec.js.map +1 -0
  72. package/lib/test/sharedStringWithInterception.spec.js +147 -0
  73. package/lib/test/sharedStringWithInterception.spec.js.map +1 -0
  74. package/package.json +151 -0
  75. package/prettier.config.cjs +8 -0
  76. package/src/index.ts +7 -0
  77. package/src/map/index.ts +7 -0
  78. package/src/map/sharedDirectoryWithInterception.ts +172 -0
  79. package/src/map/sharedMapWithInterception.ts +58 -0
  80. package/src/sequence/index.ts +6 -0
  81. package/src/sequence/sharedStringWithInterception.ts +288 -0
  82. package/tsconfig.cjs.json +7 -0
  83. package/tsconfig.json +9 -0
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISharedMap } from "@fluidframework/map";
6
+ import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions";
7
+ /**
8
+ * - Create a new object from the passed SharedMap.
9
+ *
10
+ * - Modify the set method to call the setInterceptionCallback before calling set on the underlying SharedMap.
11
+ *
12
+ * - The setInterceptionCallback and the call to the underlying SharedMap are wrapped around an
13
+ * orderSequentially call to batch any operations that might happen in the callback.
14
+ *
15
+ * @param sharedMap - The underlying SharedMap
16
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
17
+ * @param setInterceptionCallback - The interception callback to be called
18
+ *
19
+ * @returns A new SharedMap that intercepts the set method and calls the setInterceptionCallback.
20
+ * @internal
21
+ */
22
+ export declare function createSharedMapWithInterception(sharedMap: ISharedMap, context: IFluidDataStoreContext, setInterceptionCallback: (sharedMap: ISharedMap, key: string, value: any) => void): ISharedMap;
23
+ //# sourceMappingURL=sharedMapWithInterception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedMapWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,+BAA+B,CAC9C,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,sBAAsB,EAC/B,uBAAuB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,GAC/E,UAAU,CA6BZ"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createSharedMapWithInterception = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ /**
10
+ * - Create a new object from the passed SharedMap.
11
+ *
12
+ * - Modify the set method to call the setInterceptionCallback before calling set on the underlying SharedMap.
13
+ *
14
+ * - The setInterceptionCallback and the call to the underlying SharedMap are wrapped around an
15
+ * orderSequentially call to batch any operations that might happen in the callback.
16
+ *
17
+ * @param sharedMap - The underlying SharedMap
18
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
19
+ * @param setInterceptionCallback - The interception callback to be called
20
+ *
21
+ * @returns A new SharedMap that intercepts the set method and calls the setInterceptionCallback.
22
+ * @internal
23
+ */
24
+ function createSharedMapWithInterception(sharedMap, context, setInterceptionCallback) {
25
+ const sharedMapWithInterception = Object.create(sharedMap);
26
+ // executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.
27
+ let executingCallback = false;
28
+ sharedMapWithInterception.set = (key, value) => {
29
+ let map;
30
+ // Set should not be called on the wrapped object from the interception callback as this will lead to
31
+ // infinite recursion.
32
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c0 /* "set called recursively from the interception callback" */);
33
+ context.containerRuntime.orderSequentially(() => {
34
+ map = sharedMap.set(key, value);
35
+ executingCallback = true;
36
+ try {
37
+ setInterceptionCallback(sharedMap, key, value);
38
+ }
39
+ finally {
40
+ executingCallback = false;
41
+ }
42
+ });
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
44
+ return map;
45
+ };
46
+ return sharedMapWithInterception;
47
+ }
48
+ exports.createSharedMapWithInterception = createSharedMapWithInterception;
49
+ //# sourceMappingURL=sharedMapWithInterception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedMapWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAIpD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,+BAA+B,CAC9C,SAAqB,EACrB,OAA+B,EAC/B,uBAAiF;IAEjF,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAE3D,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,yBAAyB,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;QAC3D,IAAI,GAAG,CAAC;QACR,qGAAqG;QACrG,sBAAsB;QACtB,IAAA,mBAAM,EACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,6DAA6D,CACnE,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAChC,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI;gBACH,uBAAuB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;aAC/C;oBAAS;gBACT,iBAAiB,GAAG,KAAK,CAAC;aAC1B;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,yBAAuC,CAAC;AAChD,CAAC;AAjCD,0EAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ISharedMap } from \"@fluidframework/map\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\n\n/**\n * - Create a new object from the passed SharedMap.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying SharedMap.\n *\n * - The setInterceptionCallback and the call to the underlying SharedMap are wrapped around an\n * orderSequentially call to batch any operations that might happen in the callback.\n *\n * @param sharedMap - The underlying SharedMap\n * @param context - The IFluidDataStoreContext that will be used to call orderSequentially\n * @param setInterceptionCallback - The interception callback to be called\n *\n * @returns A new SharedMap that intercepts the set method and calls the setInterceptionCallback.\n * @internal\n */\nexport function createSharedMapWithInterception(\n\tsharedMap: ISharedMap,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (sharedMap: ISharedMap, key: string, value: any) => void,\n): ISharedMap {\n\tconst sharedMapWithInterception = Object.create(sharedMap);\n\n\t// executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\tsharedMapWithInterception.set = (key: string, value: any) => {\n\t\tlet map;\n\t\t// Set should not be called on the wrapped object from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c0 /* \"set called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\tmap = sharedMap.set(key, value);\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsetInterceptionCallback(sharedMap, key, value);\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn map;\n\t};\n\n\treturn sharedMapWithInterception as ISharedMap;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createSharedStringWithInterception } from "./sharedStringWithInterception.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createSharedStringWithInterception = void 0;
8
+ var sharedStringWithInterception_js_1 = require("./sharedStringWithInterception.js");
9
+ Object.defineProperty(exports, "createSharedStringWithInterception", { enumerable: true, get: function () { return sharedStringWithInterception_js_1.createSharedStringWithInterception; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qFAAuF;AAA9E,qJAAA,kCAAkC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createSharedStringWithInterception } from \"./sharedStringWithInterception.js\";\n"]}
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import * as MergeTree from "@fluidframework/merge-tree";
6
+ import { SharedString } from "@fluidframework/sequence";
7
+ import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions";
8
+ /**
9
+ * - Create a new object from the passed SharedString.
10
+ *
11
+ * - Modify the methods that insert / remove / annotate the properties of the SharedString to call
12
+ * the propertyInterceptionCallback to get new properties.
13
+ *
14
+ * - Use these new properties to call the underlying SharedString.
15
+ *
16
+ * - The propertyInterceptionCallback and the call to the underlying SharedString are wrapped around an
17
+ * orderSequentially call to batch any operations that might happen in the callback.
18
+ *
19
+ * @param sharedString - The underlying SharedString
20
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
21
+ * @param propertyInterceptionCallback - The interception callback to be called
22
+ *
23
+ * @returns A new SharedString that intercepts the methods modifying the SharedString properties.
24
+ * @internal
25
+ */
26
+ export declare function createSharedStringWithInterception(sharedString: SharedString, context: IFluidDataStoreContext, propertyInterceptionCallback: (props?: MergeTree.PropertySet) => MergeTree.PropertySet): SharedString;
27
+ //# sourceMappingURL=sharedStringWithInterception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedStringWithInterception.d.ts","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kCAAkC,CACjD,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,sBAAsB,EAC/B,4BAA4B,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,WAAW,KAAK,SAAS,CAAC,WAAW,GACpF,YAAY,CA+Pd"}
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createSharedStringWithInterception = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ /**
10
+ * - Create a new object from the passed SharedString.
11
+ *
12
+ * - Modify the methods that insert / remove / annotate the properties of the SharedString to call
13
+ * the propertyInterceptionCallback to get new properties.
14
+ *
15
+ * - Use these new properties to call the underlying SharedString.
16
+ *
17
+ * - The propertyInterceptionCallback and the call to the underlying SharedString are wrapped around an
18
+ * orderSequentially call to batch any operations that might happen in the callback.
19
+ *
20
+ * @param sharedString - The underlying SharedString
21
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
22
+ * @param propertyInterceptionCallback - The interception callback to be called
23
+ *
24
+ * @returns A new SharedString that intercepts the methods modifying the SharedString properties.
25
+ * @internal
26
+ */
27
+ function createSharedStringWithInterception(sharedString, context, propertyInterceptionCallback) {
28
+ const sharedStringWithInterception = Object.create(sharedString);
29
+ // executingCallback keeps track of whether a method on this wrapper object is called recursively
30
+ // from the propertyInterceptionCallback.
31
+ let executingCallback = false;
32
+ /**
33
+ * Inserts a marker at a relative position.
34
+ *
35
+ * @param relativePos1 - The relative position to insert the marker at
36
+ * @param refType - The reference type of the marker
37
+ * @param props - The properties of the marker
38
+ */
39
+ sharedStringWithInterception.insertMarkerRelative = (relativePos1, refType, props) => {
40
+ // Wrapper methods should not be called from the interception callback as this will lead to
41
+ // infinite recursion.
42
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c1 /* "Interception wrapper methods called recursively from the interception callback" */);
43
+ context.containerRuntime.orderSequentially(() => {
44
+ executingCallback = true;
45
+ try {
46
+ sharedString.insertMarkerRelative(relativePos1, refType, propertyInterceptionCallback(props));
47
+ }
48
+ finally {
49
+ executingCallback = false;
50
+ }
51
+ });
52
+ };
53
+ /**
54
+ * Inserts a marker at the position.
55
+ *
56
+ * @param pos - The position to insert the marker at
57
+ * @param refType - The reference type of the marker
58
+ * @param props - The properties of the marker
59
+ */
60
+ sharedStringWithInterception.insertMarker = (pos, refType, props) => {
61
+ let insertOp;
62
+ // Wrapper methods should not be called from the interception callback as this will lead to
63
+ // infinite recursion.
64
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c2 /* "Interception wrapper methods called recursively from the interception callback" */);
65
+ context.containerRuntime.orderSequentially(() => {
66
+ executingCallback = true;
67
+ try {
68
+ insertOp = sharedString.insertMarker(pos, refType, propertyInterceptionCallback(props));
69
+ }
70
+ finally {
71
+ executingCallback = false;
72
+ }
73
+ });
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
75
+ return insertOp;
76
+ };
77
+ /**
78
+ * Inserts the text at a relative position.
79
+ *
80
+ * @param relativePos1 - The relative position to insert the text at
81
+ * @param text - The text to insert
82
+ * @param props - The properties of text
83
+ */
84
+ sharedStringWithInterception.insertTextRelative = (relativePos1, text, props) => {
85
+ // Wrapper methods should not be called from the interception callback as this will lead to
86
+ // infinite recursion.
87
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c3 /* "Interception wrapper methods called recursively from the interception callback" */);
88
+ context.containerRuntime.orderSequentially(() => {
89
+ executingCallback = true;
90
+ try {
91
+ sharedString.insertTextRelative(relativePos1, text, propertyInterceptionCallback(props));
92
+ }
93
+ finally {
94
+ executingCallback = false;
95
+ }
96
+ });
97
+ };
98
+ /**
99
+ * Inserts the text at the position.
100
+ *
101
+ * @param pos - The position to insert the text at
102
+ * @param text - The text to insert
103
+ * @param props - The properties of text
104
+ */
105
+ sharedStringWithInterception.insertText = (pos, text, props) => {
106
+ // Wrapper methods should not be called from the interception callback as this will lead to
107
+ // infinite recursion.
108
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c4 /* "Interception wrapper methods called recursively from the interception callback" */);
109
+ context.containerRuntime.orderSequentially(() => {
110
+ executingCallback = true;
111
+ try {
112
+ sharedString.insertText(pos, text, propertyInterceptionCallback(props));
113
+ }
114
+ finally {
115
+ executingCallback = false;
116
+ }
117
+ });
118
+ };
119
+ /**
120
+ * Replaces a range with the provided text.
121
+ *
122
+ * @param start - The inclusive start of the range to replace
123
+ * @param end - The exclusive end of the range to replace
124
+ * @param text - The text to replace the range with
125
+ * @param props - Optional. The properties of the replacement text
126
+ */
127
+ sharedStringWithInterception.replaceText = (start, end, text, props) => {
128
+ // Wrapper methods should not be called from the interception callback as this will lead to
129
+ // infinite recursion.
130
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c5 /* "Interception wrapper methods called recursively from the interception callback" */);
131
+ context.containerRuntime.orderSequentially(() => {
132
+ executingCallback = true;
133
+ try {
134
+ sharedString.replaceText(start, end, text, propertyInterceptionCallback(props));
135
+ }
136
+ finally {
137
+ executingCallback = false;
138
+ }
139
+ });
140
+ };
141
+ /**
142
+ * Annotates the marker with the provided properties.
143
+ *
144
+ * @param marker - The marker to annotate
145
+ * @param props - The properties to annotate the marker with
146
+ */
147
+ sharedStringWithInterception.annotateMarker = (marker, props) => {
148
+ // Wrapper methods should not be called from the interception callback as this will lead to
149
+ // infinite recursion.
150
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c7 /* "Interception wrapper methods called recursively from the interception callback" */);
151
+ context.containerRuntime.orderSequentially(() => {
152
+ executingCallback = true;
153
+ try {
154
+ sharedString.annotateMarker(marker, propertyInterceptionCallback(props));
155
+ }
156
+ finally {
157
+ executingCallback = false;
158
+ }
159
+ });
160
+ };
161
+ /**
162
+ * Annotates the range with the provided properties.
163
+ *
164
+ * @param start - The inclusive start position of the range to annotate
165
+ * @param end - The exclusive end position of the range to annotate
166
+ * @param props - The properties to annotate the range with
167
+ *
168
+ */
169
+ sharedStringWithInterception.annotateRange = (start, end, props) => {
170
+ // Wrapper methods should not be called from the interception callback as this will lead to
171
+ // infinite recursion.
172
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c8 /* "Interception wrapper methods called recursively from the interception callback" */);
173
+ context.containerRuntime.orderSequentially(() => {
174
+ executingCallback = true;
175
+ try {
176
+ sharedString.annotateRange(start, end, propertyInterceptionCallback(props));
177
+ }
178
+ finally {
179
+ executingCallback = false;
180
+ }
181
+ });
182
+ };
183
+ /**
184
+ * Inserts the segment at the given position
185
+ *
186
+ * @param pos - The position to insert the segment at
187
+ * @param segment - The segment to insert
188
+ */
189
+ sharedStringWithInterception.insertAtReferencePosition = (pos, segment) => {
190
+ // Wrapper methods should not be called from the interception callback as this will lead to
191
+ // infinite recursion.
192
+ (0, core_utils_1.assert)(executingCallback === false, 0x0c9 /* "Interception wrapper methods called recursively from the interception callback" */);
193
+ context.containerRuntime.orderSequentially(() => {
194
+ executingCallback = true;
195
+ try {
196
+ segment.properties = propertyInterceptionCallback(segment.properties);
197
+ sharedString.insertAtReferencePosition(pos, segment);
198
+ }
199
+ finally {
200
+ executingCallback = false;
201
+ }
202
+ });
203
+ };
204
+ return sharedStringWithInterception;
205
+ }
206
+ exports.createSharedStringWithInterception = createSharedStringWithInterception;
207
+ //# sourceMappingURL=sharedStringWithInterception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedStringWithInterception.js","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport * as MergeTree from \"@fluidframework/merge-tree\";\nimport { SharedString } from \"@fluidframework/sequence\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\n\n/**\n * - Create a new object from the passed SharedString.\n *\n * - Modify the methods that insert / remove / annotate the properties of the SharedString to call\n * the propertyInterceptionCallback to get new properties.\n *\n * - Use these new properties to call the underlying SharedString.\n *\n * - The propertyInterceptionCallback and the call to the underlying SharedString are wrapped around an\n * orderSequentially call to batch any operations that might happen in the callback.\n *\n * @param sharedString - The underlying SharedString\n * @param context - The IFluidDataStoreContext that will be used to call orderSequentially\n * @param propertyInterceptionCallback - The interception callback to be called\n *\n * @returns A new SharedString that intercepts the methods modifying the SharedString properties.\n * @internal\n */\nexport function createSharedStringWithInterception(\n\tsharedString: SharedString,\n\tcontext: IFluidDataStoreContext,\n\tpropertyInterceptionCallback: (props?: MergeTree.PropertySet) => MergeTree.PropertySet,\n): SharedString {\n\tconst sharedStringWithInterception = Object.create(sharedString);\n\n\t// executingCallback keeps track of whether a method on this wrapper object is called recursively\n\t// from the propertyInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t *\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tsharedStringWithInterception.insertMarkerRelative = (\n\t\trelativePos1: MergeTree.IRelativePosition,\n\t\trefType: MergeTree.ReferenceType,\n\t\tprops?: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c1 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.insertMarkerRelative(\n\t\t\t\t\trelativePos1,\n\t\t\t\t\trefType,\n\t\t\t\t\tpropertyInterceptionCallback(props),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Inserts a marker at the position.\n\t *\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tsharedStringWithInterception.insertMarker = (\n\t\tpos: number,\n\t\trefType: MergeTree.ReferenceType,\n\t\tprops?: MergeTree.PropertySet,\n\t) => {\n\t\tlet insertOp;\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c2 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tinsertOp = sharedString.insertMarker(\n\t\t\t\t\tpos,\n\t\t\t\t\trefType,\n\t\t\t\t\tpropertyInterceptionCallback(props),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn insertOp;\n\t};\n\n\t/**\n\t * Inserts the text at a relative position.\n\t *\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tsharedStringWithInterception.insertTextRelative = (\n\t\trelativePos1: MergeTree.IRelativePosition,\n\t\ttext: string,\n\t\tprops?: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c3 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.insertTextRelative(\n\t\t\t\t\trelativePos1,\n\t\t\t\t\ttext,\n\t\t\t\t\tpropertyInterceptionCallback(props),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Inserts the text at the position.\n\t *\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tsharedStringWithInterception.insertText = (\n\t\tpos: number,\n\t\ttext: string,\n\t\tprops?: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c4 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.insertText(pos, text, propertyInterceptionCallback(props));\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Replaces a range with the provided text.\n\t *\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tsharedStringWithInterception.replaceText = (\n\t\tstart: number,\n\t\tend: number,\n\t\ttext: string,\n\t\tprops?: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c5 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.replaceText(start, end, text, propertyInterceptionCallback(props));\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t *\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t */\n\tsharedStringWithInterception.annotateMarker = (\n\t\tmarker: MergeTree.Marker,\n\t\tprops: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c7 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.annotateMarker(marker, propertyInterceptionCallback(props));\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Annotates the range with the provided properties.\n\t *\n\t * @param start - The inclusive start position of the range to annotate\n\t * @param end - The exclusive end position of the range to annotate\n\t * @param props - The properties to annotate the range with\n\t *\n\t */\n\tsharedStringWithInterception.annotateRange = (\n\t\tstart: number,\n\t\tend: number,\n\t\tprops: MergeTree.PropertySet,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c8 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsharedString.annotateRange(start, end, propertyInterceptionCallback(props));\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Inserts the segment at the given position\n\t *\n\t * @param pos - The position to insert the segment at\n\t * @param segment - The segment to insert\n\t */\n\tsharedStringWithInterception.insertAtReferencePosition = (\n\t\tpos: MergeTree.ReferencePosition,\n\t\tsegment: MergeTree.TextSegment,\n\t) => {\n\t\t// Wrapper methods should not be called from the interception callback as this will lead to\n\t\t// infinite recursion.\n\t\tassert(\n\t\t\texecutingCallback === false,\n\t\t\t0x0c9 /* \"Interception wrapper methods called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsegment.properties = propertyInterceptionCallback(segment.properties);\n\t\t\t\tsharedString.insertAtReferencePosition(pos, segment);\n\t\t\t} finally {\n\t\t\t\texecutingCallback = false;\n\t\t\t}\n\t\t});\n\t};\n\n\treturn sharedStringWithInterception as SharedString;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.42.3"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,13 @@
1
+ import { IDirectory } from '@fluidframework/map';
2
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
3
+ import { ISharedMap } from '@fluidframework/map';
4
+ import * as MergeTree from '@fluidframework/merge-tree';
5
+ import { SharedString } from '@fluidframework/sequence';
6
+
7
+ /* Excluded from this release type: createDirectoryWithInterception */
8
+
9
+ /* Excluded from this release type: createSharedMapWithInterception */
10
+
11
+ /* Excluded from this release type: createSharedStringWithInterception */
12
+
13
+ export { }
@@ -0,0 +1,19 @@
1
+ import { IDirectory } from '@fluidframework/map';
2
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
3
+ import { ISharedMap } from '@fluidframework/map';
4
+ import * as MergeTree from '@fluidframework/merge-tree';
5
+ import { SharedString } from '@fluidframework/sequence';
6
+
7
+ /* Excluded from this release type: createDirectoryWithInterception */
8
+
9
+ /* Excluded from this release type: createSharedMapWithInterception */
10
+
11
+ /* Excluded from this release type: createSharedStringWithInterception */
12
+
13
+ /* Excluded from this release type: IDirectory */
14
+
15
+ /* Excluded from this release type: IFluidDataStoreContext */
16
+
17
+ /* Excluded from this release type: SharedString */
18
+
19
+ export { }
@@ -0,0 +1,19 @@
1
+ import { IDirectory } from '@fluidframework/map';
2
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
3
+ import { ISharedMap } from '@fluidframework/map';
4
+ import * as MergeTree from '@fluidframework/merge-tree';
5
+ import { SharedString } from '@fluidframework/sequence';
6
+
7
+ /* Excluded from this release type: createDirectoryWithInterception */
8
+
9
+ /* Excluded from this release type: createSharedMapWithInterception */
10
+
11
+ /* Excluded from this release type: createSharedStringWithInterception */
12
+
13
+ /* Excluded from this release type: IDirectory */
14
+
15
+ /* Excluded from this release type: IFluidDataStoreContext */
16
+
17
+ /* Excluded from this release type: SharedString */
18
+
19
+ export { }
@@ -0,0 +1,67 @@
1
+ import { IDirectory } from '@fluidframework/map';
2
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
3
+ import { ISharedMap } from '@fluidframework/map';
4
+ import * as MergeTree from '@fluidframework/merge-tree';
5
+ import { SharedString } from '@fluidframework/sequence';
6
+
7
+ /**
8
+ * - Create a new object from the passed IDirectory object.
9
+ *
10
+ * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.
11
+ *
12
+ * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially
13
+ * call to batch any operations that might happen in the callback.
14
+ *
15
+ * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and
16
+ * calls the setInterceptionCallback.
17
+ *
18
+ * - When a sub directory is created from this directory, this directory object is passed to it which is passed into
19
+ * the interception callback.
20
+ *
21
+ * @param baseDirectory - The underlying object that is to be intercepted
22
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
23
+ * @param setInterceptionCallback - The interception callback to be called
24
+ *
25
+ * @returns A new IDirectory object that intercepts the set method and calls the setInterceptionCallback.
26
+ * @internal
27
+ */
28
+ export declare function createDirectoryWithInterception<T extends IDirectory>(baseDirectory: T, context: IFluidDataStoreContext, setInterceptionCallback: (baseDirectory: IDirectory, subDirectory: IDirectory, key: string, value: any) => void): T;
29
+
30
+ /**
31
+ * - Create a new object from the passed SharedMap.
32
+ *
33
+ * - Modify the set method to call the setInterceptionCallback before calling set on the underlying SharedMap.
34
+ *
35
+ * - The setInterceptionCallback and the call to the underlying SharedMap are wrapped around an
36
+ * orderSequentially call to batch any operations that might happen in the callback.
37
+ *
38
+ * @param sharedMap - The underlying SharedMap
39
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
40
+ * @param setInterceptionCallback - The interception callback to be called
41
+ *
42
+ * @returns A new SharedMap that intercepts the set method and calls the setInterceptionCallback.
43
+ * @internal
44
+ */
45
+ export declare function createSharedMapWithInterception(sharedMap: ISharedMap, context: IFluidDataStoreContext, setInterceptionCallback: (sharedMap: ISharedMap, key: string, value: any) => void): ISharedMap;
46
+
47
+ /**
48
+ * - Create a new object from the passed SharedString.
49
+ *
50
+ * - Modify the methods that insert / remove / annotate the properties of the SharedString to call
51
+ * the propertyInterceptionCallback to get new properties.
52
+ *
53
+ * - Use these new properties to call the underlying SharedString.
54
+ *
55
+ * - The propertyInterceptionCallback and the call to the underlying SharedString are wrapped around an
56
+ * orderSequentially call to batch any operations that might happen in the callback.
57
+ *
58
+ * @param sharedString - The underlying SharedString
59
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
60
+ * @param propertyInterceptionCallback - The interception callback to be called
61
+ *
62
+ * @returns A new SharedString that intercepts the methods modifying the SharedString properties.
63
+ * @internal
64
+ */
65
+ export declare function createSharedStringWithInterception(sharedString: SharedString, context: IFluidDataStoreContext, propertyInterceptionCallback: (props?: MergeTree.PropertySet) => MergeTree.PropertySet): SharedString;
66
+
67
+ export { }
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createDirectoryWithInterception, createSharedMapWithInterception } from "./map/index.js";
6
+ export { createSharedStringWithInterception } from "./sequence/index.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createDirectoryWithInterception, createSharedMapWithInterception } from "./map/index.js";
6
+ export { createSharedStringWithInterception } from "./sequence/index.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createDirectoryWithInterception, createSharedMapWithInterception } from \"./map/index.js\";\nexport { createSharedStringWithInterception } from \"./sequence/index.js\";\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createDirectoryWithInterception } from "./sharedDirectoryWithInterception.js";
6
+ export { createSharedMapWithInterception } from "./sharedMapWithInterception.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/map/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { createDirectoryWithInterception } from "./sharedDirectoryWithInterception.js";
6
+ export { createSharedMapWithInterception } from "./sharedMapWithInterception.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/map/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createDirectoryWithInterception } from \"./sharedDirectoryWithInterception.js\";\nexport { createSharedMapWithInterception } from \"./sharedMapWithInterception.js\";\n"]}
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IDirectory } from "@fluidframework/map";
6
+ import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions";
7
+ /**
8
+ * - Create a new object from the passed IDirectory object.
9
+ *
10
+ * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.
11
+ *
12
+ * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially
13
+ * call to batch any operations that might happen in the callback.
14
+ *
15
+ * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and
16
+ * calls the setInterceptionCallback.
17
+ *
18
+ * - When a sub directory is created from this directory, this directory object is passed to it which is passed into
19
+ * the interception callback.
20
+ *
21
+ * @param baseDirectory - The underlying object that is to be intercepted
22
+ * @param context - The IFluidDataStoreContext that will be used to call orderSequentially
23
+ * @param setInterceptionCallback - The interception callback to be called
24
+ *
25
+ * @returns A new IDirectory object that intercepts the set method and calls the setInterceptionCallback.
26
+ * @internal
27
+ */
28
+ export declare function createDirectoryWithInterception<T extends IDirectory>(baseDirectory: T, context: IFluidDataStoreContext, setInterceptionCallback: (baseDirectory: IDirectory, subDirectory: IDirectory, key: string, value: any) => void): T;
29
+ //# sourceMappingURL=sharedDirectoryWithInterception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedDirectoryWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AA+H7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,UAAU,EACnE,aAAa,EAAE,CAAC,EAChB,OAAO,EAAE,sBAAsB,EAC/B,uBAAuB,EAAE,CACxB,aAAa,EAAE,UAAU,EACzB,YAAY,EAAE,UAAU,EACxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,KACN,IAAI,GACP,CAAC,CAOH"}