@fluid-experimental/dds-interceptions 2.51.0-347100 → 2.51.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.
- package/.eslintrc.cjs +13 -0
- package/CHANGELOG.md +4 -0
- package/dist/map/sharedDirectoryWithInterception.d.ts +2 -2
- package/dist/map/sharedDirectoryWithInterception.d.ts.map +1 -1
- package/dist/map/sharedDirectoryWithInterception.js.map +1 -1
- package/dist/map/sharedMapWithInterception.d.ts +2 -2
- package/dist/map/sharedMapWithInterception.d.ts.map +1 -1
- package/dist/map/sharedMapWithInterception.js.map +1 -1
- package/dist/sequence/sharedStringWithInterception.d.ts +3 -3
- package/dist/sequence/sharedStringWithInterception.d.ts.map +1 -1
- package/dist/sequence/sharedStringWithInterception.js.map +1 -1
- package/lib/map/sharedDirectoryWithInterception.d.ts +2 -2
- package/lib/map/sharedDirectoryWithInterception.d.ts.map +1 -1
- package/lib/map/sharedDirectoryWithInterception.js.map +1 -1
- package/lib/map/sharedMapWithInterception.d.ts +2 -2
- package/lib/map/sharedMapWithInterception.d.ts.map +1 -1
- package/lib/map/sharedMapWithInterception.js.map +1 -1
- package/lib/sequence/sharedStringWithInterception.d.ts +3 -3
- package/lib/sequence/sharedStringWithInterception.d.ts.map +1 -1
- package/lib/sequence/sharedStringWithInterception.js.map +1 -1
- package/package.json +8 -8
- package/src/map/sharedDirectoryWithInterception.ts +2 -2
- package/src/map/sharedMapWithInterception.ts +2 -2
- package/src/sequence/sharedStringWithInterception.ts +3 -3
package/.eslintrc.cjs
CHANGED
|
@@ -8,4 +8,17 @@ module.exports = {
|
|
|
8
8
|
parserOptions: {
|
|
9
9
|
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
10
|
},
|
|
11
|
+
rules: {
|
|
12
|
+
// #region TODO: remove these once eslint-config-fluid has been updated to 5.8.0
|
|
13
|
+
"@typescript-eslint/consistent-type-exports": [
|
|
14
|
+
"error",
|
|
15
|
+
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
16
|
+
],
|
|
17
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
18
|
+
"error",
|
|
19
|
+
{ fixStyle: "inline-type-imports" },
|
|
20
|
+
],
|
|
21
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
22
|
+
// #endregion
|
|
23
|
+
},
|
|
11
24
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDirectory } from "@fluidframework/map/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
5
|
+
import type { IDirectory } from "@fluidframework/map/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* - Create a new object from the passed IDirectory object.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDirectoryWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedDirectoryWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAiI3F;;;;;;;;;;;;;;;;;;;;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,OAAO,KACV,IAAI,GACP,CAAC,CAOH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDirectoryWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kCAAkC,CAC1C,aAAgB,EAChB,YAAe,EACf,OAA+B,EAC/B,uBAKS;IAET,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAM,CAAC;IAEtE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,4BAA4B,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAClE,IAAI,SAAS,CAAC;QACd,qGAAqG;QACrG,sBAAsB;QACtB,IAAA,iBAAM,EACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,6DAA6D,CACnE,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,uBAAuB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAClE,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;IAEF,4BAA4B,CAAC,kBAAkB,GAAG,CAAC,UAAkB,EAAc,EAAE;QACpF,MAAM,eAAe,GAAG,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,C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e,GAAG,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvE,OAAO,eAAe,KAAK,SAAS;YACnC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,kCAAkC,CAClC,aAAa,EACb,eAAe,EACf,OAAO,EACP,uBAAuB,CACvB,CAAC;IACL,CAAC,CAAC;IAEF,+DAA+D;IAC/D,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,+BAA+B,CAC9C,aAAgB,EAChB,OAA+B,EAC/B,uBAKS;IAET,OAAO,kCAAkC,CACxC,aAAa,EACb,aAAa,EACb,OAAO,EACP,uBAAuB,CACvB,CAAC;AACH,CAAC;AAhBD,0EAgBC","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/internal\";\nimport { IDirectory } from \"@fluidframework/map/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\n\n/**\n * - Create a new object from the passed subDirectory.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this base directory object is passed to it which is passed\n * into the interception callback.\n *\n * @param baseDirectory - The base directory in the directory structure that is passed to the interception callback\n * @param subDirectory - The underlying object that is to be intercepted\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 sub directory that intercepts the set method and calls the setInterceptionCallback.\n */\nfunction createSubDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tsubDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\tconst subDirectoryWithInterception = Object.create(subDirectory) as T;\n\n\t// executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\tsubDirectoryWithInterception.set = (key: string, value: unknown) => {\n\t\tlet directory;\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\t0x0bf /* \"set called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\tdirectory = subDirectory.set(key, value);\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsetInterceptionCallback(baseDirectory, subDirectory, 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 directory;\n\t};\n\n\tsubDirectoryWithInterception.createSubDirectory = (subdirName: string): IDirectory => {\n\t\tconst subSubDirectory = subDirectory.createSubDirectory(subdirName);\n\t\treturn createSubDirectoryWithInterception(\n\t\t\tbaseDirectory,\n\t\t\tsubSubDirectory,\n\t\t\tcontext,\n\t\t\tsetInterceptionCallback,\n\t\t);\n\t};\n\n\tsubDirectoryWithInterception.getSubDirectory = (\n\t\tsubdirName: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getSubDirectory(subdirName);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\tsubDirectoryWithInterception.subdirectories = (): IterableIterator<[string, IDirectory]> => {\n\t\tconst localDirectoriesIterator = subDirectory.subdirectories();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, IDirectory]> {\n\t\t\t\tconst nextVal = localDirectoriesIterator.next();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\t\tif (nextVal.done) {\n\t\t\t\t\treturn { value: undefined, done: true };\n\t\t\t\t} else {\n\t\t\t\t\t// Wrap the stored subdirectory in the interception wrapper.\n\t\t\t\t\tconst subDir = createSubDirectoryWithInterception(\n\t\t\t\t\t\tbaseDirectory,\n\t\t\t\t\t\tnextVal.value[1],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [nextVal.value[0], subDir], done: false };\n\t\t\t\t}\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\tsubDirectoryWithInterception.getWorkingDirectory = (\n\t\trelativePath: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getWorkingDirectory(relativePath);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn subDirectoryWithInterception;\n}\n\n/**\n * - Create a new object from the passed IDirectory object.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this directory object is passed to it which is passed into\n * the interception callback.\n *\n * @param baseDirectory - The underlying object that is to be intercepted\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 IDirectory object that intercepts the set method and calls the setInterceptionCallback.\n * @internal\n */\nexport function createDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\treturn createSubDirectoryWithInterception(\n\t\tbaseDirectory,\n\t\tbaseDirectory,\n\t\tcontext,\n\t\tsetInterceptionCallback,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedDirectoryWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kCAAkC,CAC1C,aAAgB,EAChB,YAAe,EACf,OAA+B,EAC/B,uBAKS;IAET,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAM,CAAC;IAEtE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,4BAA4B,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAClE,IAAI,SAAS,CAAC;QACd,qGAAqG;QACrG,sBAAsB;QACtB,IAAA,iBAAM,EACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,6DAA6D,CACnE,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,uBAAuB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAClE,CAAC;oB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AE,IAAI,EAAE,KAAK,EAAE,CAAC;gBAC3D,CAAC;YACF,CAAC;YACD,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAChB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IAEF,4BAA4B,CAAC,mBAAmB,GAAG,CAClD,YAAoB,EACK,EAAE;QAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvE,OAAO,eAAe,KAAK,SAAS;YACnC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,kCAAkC,CAClC,aAAa,EACb,eAAe,EACf,OAAO,EACP,uBAAuB,CACvB,CAAC;IACL,CAAC,CAAC;IAEF,+DAA+D;IAC/D,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,+BAA+B,CAC9C,aAAgB,EAChB,OAA+B,EAC/B,uBAKS;IAET,OAAO,kCAAkC,CACxC,aAAa,EACb,aAAa,EACb,OAAO,EACP,uBAAuB,CACvB,CAAC;AACH,CAAC;AAhBD,0EAgBC","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/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\n\n/**\n * - Create a new object from the passed subDirectory.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this base directory object is passed to it which is passed\n * into the interception callback.\n *\n * @param baseDirectory - The base directory in the directory structure that is passed to the interception callback\n * @param subDirectory - The underlying object that is to be intercepted\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 sub directory that intercepts the set method and calls the setInterceptionCallback.\n */\nfunction createSubDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tsubDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\tconst subDirectoryWithInterception = Object.create(subDirectory) as T;\n\n\t// executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\tsubDirectoryWithInterception.set = (key: string, value: unknown) => {\n\t\tlet directory;\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\t0x0bf /* \"set called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\tdirectory = subDirectory.set(key, value);\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsetInterceptionCallback(baseDirectory, subDirectory, 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 directory;\n\t};\n\n\tsubDirectoryWithInterception.createSubDirectory = (subdirName: string): IDirectory => {\n\t\tconst subSubDirectory = subDirectory.createSubDirectory(subdirName);\n\t\treturn createSubDirectoryWithInterception(\n\t\t\tbaseDirectory,\n\t\t\tsubSubDirectory,\n\t\t\tcontext,\n\t\t\tsetInterceptionCallback,\n\t\t);\n\t};\n\n\tsubDirectoryWithInterception.getSubDirectory = (\n\t\tsubdirName: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getSubDirectory(subdirName);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\tsubDirectoryWithInterception.subdirectories = (): IterableIterator<[string, IDirectory]> => {\n\t\tconst localDirectoriesIterator = subDirectory.subdirectories();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, IDirectory]> {\n\t\t\t\tconst nextVal = localDirectoriesIterator.next();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\t\tif (nextVal.done) {\n\t\t\t\t\treturn { value: undefined, done: true };\n\t\t\t\t} else {\n\t\t\t\t\t// Wrap the stored subdirectory in the interception wrapper.\n\t\t\t\t\tconst subDir = createSubDirectoryWithInterception(\n\t\t\t\t\t\tbaseDirectory,\n\t\t\t\t\t\tnextVal.value[1],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [nextVal.value[0], subDir], done: false };\n\t\t\t\t}\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\tsubDirectoryWithInterception.getWorkingDirectory = (\n\t\trelativePath: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getWorkingDirectory(relativePath);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn subDirectoryWithInterception;\n}\n\n/**\n * - Create a new object from the passed IDirectory object.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this directory object is passed to it which is passed into\n * the interception callback.\n *\n * @param baseDirectory - The underlying object that is to be intercepted\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 IDirectory object that intercepts the set method and calls the setInterceptionCallback.\n * @internal\n */\nexport function createDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\treturn createSubDirectoryWithInterception(\n\t\tbaseDirectory,\n\t\tbaseDirectory,\n\t\tcontext,\n\t\tsetInterceptionCallback,\n\t);\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISharedMap } from "@fluidframework/map/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
5
|
+
import type { ISharedMap } from "@fluidframework/map/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* - Create a new object from the passed SharedMap.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedMapWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedMapWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAE3F;;;;;;;;;;;;;;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,OAAO,KAAK,IAAI,GACnF,UAAU,CA6BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedMapWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,+BAA+B,CAC9C,SAAqB,EACrB,OAA+B,EAC/B,uBAAqF;IAErF,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAe,CAAC;IAEzE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,yBAAyB,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC/D,IAAI,GAAG,CAAC;QACR,qGAAqG;QACrG,sBAAsB;QACtB,IAAA,iBAAM,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,CAAC;gBACJ,uBAAuB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC;AAClC,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/internal\";\nimport { ISharedMap } from \"@fluidframework/map/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\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: unknown) => void,\n): ISharedMap {\n\tconst sharedMapWithInterception = Object.create(sharedMap) as ISharedMap;\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: unknown) => {\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;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedMapWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,+BAA+B,CAC9C,SAAqB,EACrB,OAA+B,EAC/B,uBAAqF;IAErF,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAe,CAAC;IAEzE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,yBAAyB,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC/D,IAAI,GAAG,CAAC;QACR,qGAAqG;QACrG,sBAAsB;QACtB,IAAA,iBAAM,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,CAAC;gBACJ,uBAAuB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC;AAClC,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/internal\";\nimport type { ISharedMap } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\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: unknown) => void,\n): ISharedMap {\n\tconst sharedMapWithInterception = Object.create(sharedMap) as ISharedMap;\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: unknown) => {\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;\n}\n"]}
|
|
@@ -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 * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import { SharedString } from "@fluidframework/sequence/internal";
|
|
5
|
+
import type * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { SharedString } from "@fluidframework/sequence/internal";
|
|
8
8
|
/**
|
|
9
9
|
* - Create a new object from the passed SharedString.
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedStringWithInterception.d.ts","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,SAAS,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedStringWithInterception.d.ts","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,KAAK,SAAS,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;;;;;;;;;;;;;;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedStringWithInterception.js","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAK7D;;;;;;;;;;;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,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7E,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;OAKG;IACH,4BAA4B,CAAC,yBAAyB,GAAG,CACxD,GAAgC,EAChC,OAA8B,EAC7B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,IAAA,iBAAM,EACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,OAAO,CAAC,UAAU,GAAG,4BAA4B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACtE,YAAY,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAnQD,gFAmQC","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/internal\";\nimport * as MergeTree from \"@fluidframework/merge-tree/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SharedString } from \"@fluidframework/sequence/internal\";\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) as 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;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedStringWithInterception.js","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAK7D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,kCAAkC,CACjD,YAA0B,EAC1B,OAA+B,EAC/B,4BAAsF;IAEtF,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAiB,CAAC;IAEjF,iGAAiG;IACjG,yCAAyC;IACzC,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC;;;;;;OAMG;IACH,4BAA4B,CAAC,oBAAoB,GAAG,CACnD,YAAyC,EACzC,OAAgC,EAChC,KAA6B,EAC5B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,IAAA,iBAAM,EACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,YAAY,CAAC,oBAAoB,CAChC,YAAY,EACZ,OAAO,EACP,4BAA4B,CAAC,KAAK,CAAC,CACnC,CAAC;YACH,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;;OAMG;IACH,4BAA4B,CAAC,YAAY,GAAG,CAC3C,GAAW,EACX,OAAgC,EAChC,KAA6B,EAC5B,EAAE;QACH,IAAI,QAAQ,CAAC;QACb,2FAA2F;QAC3F,sBAAsB;QACtB,IAAA,iBAAM,EACL,iBAAi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FAmQC","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/internal\";\nimport type * as MergeTree from \"@fluidframework/merge-tree/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedString } from \"@fluidframework/sequence/internal\";\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) as 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;\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDirectory } from "@fluidframework/map/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
5
|
+
import type { IDirectory } from "@fluidframework/map/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* - Create a new object from the passed IDirectory object.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDirectoryWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedDirectoryWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAiI3F;;;;;;;;;;;;;;;;;;;;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,OAAO,KACV,IAAI,GACP,CAAC,CAOH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDirectoryWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kCAAkC,CAC1C,aAAgB,EAChB,YAAe,EACf,OAA+B,EAC/B,uBAKS;IAET,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAM,CAAC;IAEtE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,4BAA4B,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAClE,IAAI,SAAS,CAAC;QACd,qGAAqG;QACrG,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,6DAA6D,CACnE,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,uBAAuB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAClE,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC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;YACF,CAAC;YACD,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAChB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IAEF,4BAA4B,CAAC,mBAAmB,GAAG,CAClD,YAAoB,EACK,EAAE;QAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvE,OAAO,eAAe,KAAK,SAAS;YACnC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,kCAAkC,CAClC,aAAa,EACb,eAAe,EACf,OAAO,EACP,uBAAuB,CACvB,CAAC;IACL,CAAC,CAAC;IAEF,+DAA+D;IAC/D,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,+BAA+B,CAC9C,aAAgB,EAChB,OAA+B,EAC/B,uBAKS;IAET,OAAO,kCAAkC,CACxC,aAAa,EACb,aAAa,EACb,OAAO,EACP,uBAAuB,CACvB,CAAC;AACH,CAAC","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/internal\";\nimport { IDirectory } from \"@fluidframework/map/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\n\n/**\n * - Create a new object from the passed subDirectory.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this base directory object is passed to it which is passed\n * into the interception callback.\n *\n * @param baseDirectory - The base directory in the directory structure that is passed to the interception callback\n * @param subDirectory - The underlying object that is to be intercepted\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 sub directory that intercepts the set method and calls the setInterceptionCallback.\n */\nfunction createSubDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tsubDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\tconst subDirectoryWithInterception = Object.create(subDirectory) as T;\n\n\t// executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\tsubDirectoryWithInterception.set = (key: string, value: unknown) => {\n\t\tlet directory;\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\t0x0bf /* \"set called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\tdirectory = subDirectory.set(key, value);\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsetInterceptionCallback(baseDirectory, subDirectory, 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 directory;\n\t};\n\n\tsubDirectoryWithInterception.createSubDirectory = (subdirName: string): IDirectory => {\n\t\tconst subSubDirectory = subDirectory.createSubDirectory(subdirName);\n\t\treturn createSubDirectoryWithInterception(\n\t\t\tbaseDirectory,\n\t\t\tsubSubDirectory,\n\t\t\tcontext,\n\t\t\tsetInterceptionCallback,\n\t\t);\n\t};\n\n\tsubDirectoryWithInterception.getSubDirectory = (\n\t\tsubdirName: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getSubDirectory(subdirName);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\tsubDirectoryWithInterception.subdirectories = (): IterableIterator<[string, IDirectory]> => {\n\t\tconst localDirectoriesIterator = subDirectory.subdirectories();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, IDirectory]> {\n\t\t\t\tconst nextVal = localDirectoriesIterator.next();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\t\tif (nextVal.done) {\n\t\t\t\t\treturn { value: undefined, done: true };\n\t\t\t\t} else {\n\t\t\t\t\t// Wrap the stored subdirectory in the interception wrapper.\n\t\t\t\t\tconst subDir = createSubDirectoryWithInterception(\n\t\t\t\t\t\tbaseDirectory,\n\t\t\t\t\t\tnextVal.value[1],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [nextVal.value[0], subDir], done: false };\n\t\t\t\t}\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\tsubDirectoryWithInterception.getWorkingDirectory = (\n\t\trelativePath: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getWorkingDirectory(relativePath);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn subDirectoryWithInterception;\n}\n\n/**\n * - Create a new object from the passed IDirectory object.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this directory object is passed to it which is passed into\n * the interception callback.\n *\n * @param baseDirectory - The underlying object that is to be intercepted\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 IDirectory object that intercepts the set method and calls the setInterceptionCallback.\n * @internal\n */\nexport function createDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\treturn createSubDirectoryWithInterception(\n\t\tbaseDirectory,\n\t\tbaseDirectory,\n\t\tcontext,\n\t\tsetInterceptionCallback,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedDirectoryWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedDirectoryWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kCAAkC,CAC1C,aAAgB,EAChB,YAAe,EACf,OAA+B,EAC/B,uBAKS;IAET,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAM,CAAC;IAEtE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,4BAA4B,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAClE,IAAI,SAAS,CAAC;QACd,qGAAqG;QACrG,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,6DAA6D,CACnE,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAA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P,4DAA4D;oBAC5D,MAAM,MAAM,GAAG,kCAAkC,CAChD,aAAa,EACb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAChB,OAAO,EACP,uBAAuB,CACvB,CAAC;oBACF,OAAO,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBAC3D,CAAC;YACF,CAAC;YACD,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAChB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IAEF,4BAA4B,CAAC,mBAAmB,GAAG,CAClD,YAAoB,EACK,EAAE;QAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvE,OAAO,eAAe,KAAK,SAAS;YACnC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,kCAAkC,CAClC,aAAa,EACb,eAAe,EACf,OAAO,EACP,uBAAuB,CACvB,CAAC;IACL,CAAC,CAAC;IAEF,+DAA+D;IAC/D,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,+BAA+B,CAC9C,aAAgB,EAChB,OAA+B,EAC/B,uBAKS;IAET,OAAO,kCAAkC,CACxC,aAAa,EACb,aAAa,EACb,OAAO,EACP,uBAAuB,CACvB,CAAC;AACH,CAAC","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/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\n\n/**\n * - Create a new object from the passed subDirectory.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this base directory object is passed to it which is passed\n * into the interception callback.\n *\n * @param baseDirectory - The base directory in the directory structure that is passed to the interception callback\n * @param subDirectory - The underlying object that is to be intercepted\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 sub directory that intercepts the set method and calls the setInterceptionCallback.\n */\nfunction createSubDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tsubDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\tconst subDirectoryWithInterception = Object.create(subDirectory) as T;\n\n\t// executingCallback keeps track of whether set is called recursively from the setInterceptionCallback.\n\tlet executingCallback: boolean = false;\n\n\tsubDirectoryWithInterception.set = (key: string, value: unknown) => {\n\t\tlet directory;\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\t0x0bf /* \"set called recursively from the interception callback\" */,\n\t\t);\n\n\t\tcontext.containerRuntime.orderSequentially(() => {\n\t\t\tdirectory = subDirectory.set(key, value);\n\t\t\texecutingCallback = true;\n\t\t\ttry {\n\t\t\t\tsetInterceptionCallback(baseDirectory, subDirectory, 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 directory;\n\t};\n\n\tsubDirectoryWithInterception.createSubDirectory = (subdirName: string): IDirectory => {\n\t\tconst subSubDirectory = subDirectory.createSubDirectory(subdirName);\n\t\treturn createSubDirectoryWithInterception(\n\t\t\tbaseDirectory,\n\t\t\tsubSubDirectory,\n\t\t\tcontext,\n\t\t\tsetInterceptionCallback,\n\t\t);\n\t};\n\n\tsubDirectoryWithInterception.getSubDirectory = (\n\t\tsubdirName: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getSubDirectory(subdirName);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\tsubDirectoryWithInterception.subdirectories = (): IterableIterator<[string, IDirectory]> => {\n\t\tconst localDirectoriesIterator = subDirectory.subdirectories();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, IDirectory]> {\n\t\t\t\tconst nextVal = localDirectoriesIterator.next();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\t\tif (nextVal.done) {\n\t\t\t\t\treturn { value: undefined, done: true };\n\t\t\t\t} else {\n\t\t\t\t\t// Wrap the stored subdirectory in the interception wrapper.\n\t\t\t\t\tconst subDir = createSubDirectoryWithInterception(\n\t\t\t\t\t\tbaseDirectory,\n\t\t\t\t\t\tnextVal.value[1],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [nextVal.value[0], subDir], done: false };\n\t\t\t\t}\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\tsubDirectoryWithInterception.getWorkingDirectory = (\n\t\trelativePath: string,\n\t): IDirectory | undefined => {\n\t\tconst subSubDirectory = subDirectory.getWorkingDirectory(relativePath);\n\t\treturn subSubDirectory === undefined\n\t\t\t? subSubDirectory\n\t\t\t: createSubDirectoryWithInterception(\n\t\t\t\t\tbaseDirectory,\n\t\t\t\t\tsubSubDirectory,\n\t\t\t\t\tcontext,\n\t\t\t\t\tsetInterceptionCallback,\n\t\t\t\t);\n\t};\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn subDirectoryWithInterception;\n}\n\n/**\n * - Create a new object from the passed IDirectory object.\n *\n * - Modify the set method to call the setInterceptionCallback before calling set on the underlying object.\n *\n * - The setInterceptionCallback and the call to the underlying object are wrapped around an orderSequentially\n * call to batch any operations that might happen in the callback.\n *\n * - Modify the sub directory methods to create / return a wrapper object that in turn intercepts the set method and\n * calls the setInterceptionCallback.\n *\n * - When a sub directory is created from this directory, this directory object is passed to it which is passed into\n * the interception callback.\n *\n * @param baseDirectory - The underlying object that is to be intercepted\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 IDirectory object that intercepts the set method and calls the setInterceptionCallback.\n * @internal\n */\nexport function createDirectoryWithInterception<T extends IDirectory>(\n\tbaseDirectory: T,\n\tcontext: IFluidDataStoreContext,\n\tsetInterceptionCallback: (\n\t\tbaseDirectory: IDirectory,\n\t\tsubDirectory: IDirectory,\n\t\tkey: string,\n\t\tvalue: unknown,\n\t) => void,\n): T {\n\treturn createSubDirectoryWithInterception(\n\t\tbaseDirectory,\n\t\tbaseDirectory,\n\t\tcontext,\n\t\tsetInterceptionCallback,\n\t);\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISharedMap } from "@fluidframework/map/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
5
|
+
import type { ISharedMap } from "@fluidframework/map/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* - Create a new object from the passed SharedMap.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedMapWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedMapWithInterception.d.ts","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAE3F;;;;;;;;;;;;;;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,OAAO,KAAK,IAAI,GACnF,UAAU,CA6BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedMapWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,+BAA+B,CAC9C,SAAqB,EACrB,OAA+B,EAC/B,uBAAqF;IAErF,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAe,CAAC;IAEzE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,yBAAyB,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC/D,IAAI,GAAG,CAAC;QACR,qGAAqG;QACrG,sBAAsB;QACtB,MAAM,CACL,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,CAAC;gBACJ,uBAAuB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC;AAClC,CAAC","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/internal\";\nimport { ISharedMap } from \"@fluidframework/map/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\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: unknown) => void,\n): ISharedMap {\n\tconst sharedMapWithInterception = Object.create(sharedMap) as ISharedMap;\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: unknown) => {\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;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedMapWithInterception.js","sourceRoot":"","sources":["../../src/map/sharedMapWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,+BAA+B,CAC9C,SAAqB,EACrB,OAA+B,EAC/B,uBAAqF;IAErF,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAe,CAAC;IAEzE,uGAAuG;IACvG,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC,yBAAyB,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC/D,IAAI,GAAG,CAAC;QACR,qGAAqG;QACrG,sBAAsB;QACtB,MAAM,CACL,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,CAAC;gBACJ,uBAAuB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;QACH,+DAA+D;QAC/D,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC;AAClC,CAAC","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/internal\";\nimport type { ISharedMap } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\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: unknown) => void,\n): ISharedMap {\n\tconst sharedMapWithInterception = Object.create(sharedMap) as ISharedMap;\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: unknown) => {\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;\n}\n"]}
|
|
@@ -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 * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
6
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import { SharedString } from "@fluidframework/sequence/internal";
|
|
5
|
+
import type * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { SharedString } from "@fluidframework/sequence/internal";
|
|
8
8
|
/**
|
|
9
9
|
* - Create a new object from the passed SharedString.
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedStringWithInterception.d.ts","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,SAAS,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedStringWithInterception.d.ts","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,KAAK,SAAS,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;;;;;;;;;;;;;;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedStringWithInterception.js","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kCAAkC,CACjD,YAA0B,EAC1B,OAA+B,EAC/B,4BAAsF;IAEtF,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAiB,CAAC;IAEjF,iGAAiG;IACjG,yCAAyC;IACzC,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC;;;;;;OAMG;IACH,4BAA4B,CAAC,oBAAoB,GAAG,CACnD,YAAyC,EACzC,OAAgC,EAChC,KAA6B,EAC5B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,YAAY,CAAC,oBAAoB,CAChC,YAAY,EACZ,OAAO,EACP,4BAA4B,CAAC,KAAK,CAAC,CACnC,CAAC;YACH,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;;OAMG;IACH,4BAA4B,CAAC,YAAY,GAAG,CAC3C,GAAW,EACX,OAAgC,EAChC,KAA6B,EAC5B,EAAE;QACH,IAAI,QAAQ,CAAC;QACb,2FAA2F;QAC3F,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B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,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;;;OAOG;IACH,4BAA4B,CAAC,aAAa,GAAG,CAC5C,KAAa,EACb,GAAW,EACX,KAA4B,EAC3B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7E,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF;;;;;OAKG;IACH,4BAA4B,CAAC,yBAAyB,GAAG,CACxD,GAAgC,EAChC,OAA8B,EAC7B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,OAAO,CAAC,UAAU,GAAG,4BAA4B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACtE,YAAY,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,4BAA4B,CAAC;AACrC,CAAC","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/internal\";\nimport * as MergeTree from \"@fluidframework/merge-tree/internal\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SharedString } from \"@fluidframework/sequence/internal\";\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) as 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;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedStringWithInterception.js","sourceRoot":"","sources":["../../src/sequence/sharedStringWithInterception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kCAAkC,CACjD,YAA0B,EAC1B,OAA+B,EAC/B,4BAAsF;IAEtF,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAiB,CAAC;IAEjF,iGAAiG;IACjG,yCAAyC;IACzC,IAAI,iBAAiB,GAAY,KAAK,CAAC;IAEvC;;;;;;OAMG;IACH,4BAA4B,CAAC,oBAAoB,GAAG,CACnD,YAAyC,EACzC,OAAgC,EAChC,KAA6B,EAC5B,EAAE;QACH,2FAA2F;QAC3F,sBAAsB;QACtB,MAAM,CACL,iBAAiB,KAAK,KAAK,EAC3B,KAAK,CAAC,sFAAsF,CAC5F,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC/C,iBAAiB,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC;gBACJ,YAAY,CAAC,oBAAoB,CAChC,YAAY,EACZ,OAAO,EACP,4BAA4B,CAAC,KAAK,CAAC,CACnC,CAAC;YACH,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK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CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;oBAAS,CAAC;gBACV,iBAAiB,GAAG,KAAK,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,4BAA4B,CAAC;AACrC,CAAC","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/internal\";\nimport type * as MergeTree from \"@fluidframework/merge-tree/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedString } from \"@fluidframework/sequence/internal\";\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) as 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;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/dds-interceptions",
|
|
3
|
-
"version": "2.51.0
|
|
3
|
+
"version": "2.51.0",
|
|
4
4
|
"description": "Distributed Data Structures that support an interception callback",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"temp-directory": "nyc/.nyc_output"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@fluidframework/core-utils": "2.51.0
|
|
53
|
-
"@fluidframework/map": "2.51.0
|
|
54
|
-
"@fluidframework/merge-tree": "2.51.0
|
|
55
|
-
"@fluidframework/runtime-definitions": "2.51.0
|
|
56
|
-
"@fluidframework/sequence": "2.51.0
|
|
52
|
+
"@fluidframework/core-utils": "~2.51.0",
|
|
53
|
+
"@fluidframework/map": "~2.51.0",
|
|
54
|
+
"@fluidframework/merge-tree": "~2.51.0",
|
|
55
|
+
"@fluidframework/runtime-definitions": "~2.51.0",
|
|
56
|
+
"@fluidframework/sequence": "~2.51.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
60
60
|
"@biomejs/biome": "~1.9.3",
|
|
61
|
-
"@fluid-internal/mocha-test-setup": "2.51.0
|
|
61
|
+
"@fluid-internal/mocha-test-setup": "~2.51.0",
|
|
62
62
|
"@fluid-tools/build-cli": "^0.56.0",
|
|
63
63
|
"@fluidframework/build-common": "^2.0.3",
|
|
64
64
|
"@fluidframework/build-tools": "^0.56.0",
|
|
65
65
|
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
66
|
-
"@fluidframework/test-runtime-utils": "2.51.0
|
|
66
|
+
"@fluidframework/test-runtime-utils": "~2.51.0",
|
|
67
67
|
"@microsoft/api-extractor": "7.52.8",
|
|
68
68
|
"@types/diff": "^3.5.1",
|
|
69
69
|
"@types/mocha": "^10.0.10",
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import { IDirectory } from "@fluidframework/map/internal";
|
|
8
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { IDirectory } from "@fluidframework/map/internal";
|
|
8
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* - Create a new object from the passed subDirectory.
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import { ISharedMap } from "@fluidframework/map/internal";
|
|
8
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { ISharedMap } from "@fluidframework/map/internal";
|
|
8
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* - Create a new object from the passed SharedMap.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
8
|
-
import { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
9
|
-
import { SharedString } from "@fluidframework/sequence/internal";
|
|
7
|
+
import type * as MergeTree from "@fluidframework/merge-tree/internal";
|
|
8
|
+
import type { IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
|
|
9
|
+
import type { SharedString } from "@fluidframework/sequence/internal";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* - Create a new object from the passed SharedString.
|