@fluidframework/merge-tree 2.10.0-307399 → 2.11.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/CHANGELOG.md +83 -0
- package/api-report/merge-tree.legacy.alpha.api.md +2 -1
- package/dist/attributionPolicy.js +1 -1
- package/dist/attributionPolicy.js.map +1 -1
- package/dist/client.d.ts +6 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +20 -3
- package/dist/client.js.map +1 -1
- package/dist/mergeTree.d.ts +10 -3
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +11 -7
- package/dist/mergeTree.js.map +1 -1
- package/dist/opBuilder.d.ts +12 -2
- package/dist/opBuilder.d.ts.map +1 -1
- package/dist/opBuilder.js +19 -1
- package/dist/opBuilder.js.map +1 -1
- package/dist/ops.d.ts +1 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/segmentPropertiesManager.d.ts.map +1 -1
- package/dist/segmentPropertiesManager.js +3 -3
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +8 -12
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/test/client.applyMsg.spec.js +128 -0
- package/dist/test/client.applyMsg.spec.js.map +1 -1
- package/dist/test/client.applyStashedOpFarm.spec.js +2 -2
- package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/dist/test/client.conflictFarm.spec.js +1 -0
- package/dist/test/client.conflictFarm.spec.js.map +1 -1
- package/dist/test/client.reconnectFarm.spec.js +1 -1
- package/dist/test/client.reconnectFarm.spec.js.map +1 -1
- package/dist/test/client.rollbackFarm.spec.js +1 -1
- package/dist/test/client.rollbackFarm.spec.js.map +1 -1
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js +6 -6
- package/dist/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
- package/dist/test/mergeTree.annotate.spec.js +39 -44
- package/dist/test/mergeTree.annotate.spec.js.map +1 -1
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/dist/test/mergeTreeOperationRunner.js +19 -1
- package/dist/test/mergeTreeOperationRunner.js.map +1 -1
- package/dist/test/revertibleFarm.spec.js +1 -1
- package/dist/test/revertibleFarm.spec.js.map +1 -1
- package/lib/attributionPolicy.js +1 -1
- package/lib/attributionPolicy.js.map +1 -1
- package/lib/client.d.ts +6 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +21 -4
- package/lib/client.js.map +1 -1
- package/lib/mergeTree.d.ts +10 -3
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +11 -7
- package/lib/mergeTree.js.map +1 -1
- package/lib/opBuilder.d.ts +12 -2
- package/lib/opBuilder.d.ts.map +1 -1
- package/lib/opBuilder.js +17 -0
- package/lib/opBuilder.js.map +1 -1
- package/lib/ops.d.ts +1 -1
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js.map +1 -1
- package/lib/segmentPropertiesManager.d.ts.map +1 -1
- package/lib/segmentPropertiesManager.js +3 -3
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +8 -12
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/test/client.applyMsg.spec.js +128 -0
- package/lib/test/client.applyMsg.spec.js.map +1 -1
- package/lib/test/client.applyStashedOpFarm.spec.js +2 -2
- package/lib/test/client.applyStashedOpFarm.spec.js.map +1 -1
- package/lib/test/client.conflictFarm.spec.js +1 -0
- package/lib/test/client.conflictFarm.spec.js.map +1 -1
- package/lib/test/client.reconnectFarm.spec.js +1 -1
- package/lib/test/client.reconnectFarm.spec.js.map +1 -1
- package/lib/test/client.rollbackFarm.spec.js +1 -1
- package/lib/test/client.rollbackFarm.spec.js.map +1 -1
- package/lib/test/mergeTree.annotate.deltaCallback.spec.js +6 -6
- package/lib/test/mergeTree.annotate.deltaCallback.spec.js.map +1 -1
- package/lib/test/mergeTree.annotate.spec.js +39 -44
- package/lib/test/mergeTree.annotate.spec.js.map +1 -1
- package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/lib/test/mergeTreeOperationRunner.js +19 -1
- package/lib/test/mergeTreeOperationRunner.js.map +1 -1
- package/lib/test/revertibleFarm.spec.js +1 -1
- package/lib/test/revertibleFarm.spec.js.map +1 -1
- package/package.json +18 -97
- package/src/attributionPolicy.ts +1 -1
- package/src/client.ts +41 -13
- package/src/mergeTree.ts +21 -9
- package/src/opBuilder.ts +25 -1
- package/src/ops.ts +1 -0
- package/src/segmentPropertiesManager.ts +9 -3
- package/src/snapshotlegacy.ts +12 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @fluidframework/merge-tree
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.10.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- Unsupported merge-tree types and related exposed internals have been removed ([#22696](https://github.com/microsoft/FluidFramework/pull/22696)) [7a032533a6](https://github.com/microsoft/FluidFramework/commit/7a032533a6ee6a6f76fe154ef65dfa33f87e5a7b)
|
|
12
|
+
|
|
13
|
+
As part of ongoing improvements, several internal types and related APIs have been removed. These types are unnecessary for any supported scenarios and could lead to errors if used. Since directly using these types would likely result in errors, these changes are not likely to impact any Fluid Framework consumers.
|
|
14
|
+
|
|
15
|
+
Removed types:
|
|
16
|
+
|
|
17
|
+
- IMergeTreeTextHelper
|
|
18
|
+
- MergeNode
|
|
19
|
+
- ObliterateInfo
|
|
20
|
+
- PropertiesManager
|
|
21
|
+
- PropertiesRollback
|
|
22
|
+
- SegmentGroup
|
|
23
|
+
- SegmentGroupCollection
|
|
24
|
+
|
|
25
|
+
In addition to removing the above types, they are no longer exposed through the following interfaces and their implementations: `ISegment`, `ReferencePosition`, and `ISerializableInterval`.
|
|
26
|
+
|
|
27
|
+
Removed functions:
|
|
28
|
+
|
|
29
|
+
- addProperties
|
|
30
|
+
- ack
|
|
31
|
+
|
|
32
|
+
Removed properties:
|
|
33
|
+
|
|
34
|
+
- propertyManager
|
|
35
|
+
- segmentGroups
|
|
36
|
+
|
|
37
|
+
The initial deprecations of the now changed or removed types were announced in Fluid Framework v2.2.0:
|
|
38
|
+
[Fluid Framework v2.2.0](https://github.com/microsoft/FluidFramework/blob/main/RELEASE_NOTES/2.2.0.md)
|
|
39
|
+
|
|
40
|
+
- SharedString DDS annotateAdjustRange ([#22751](https://github.com/microsoft/FluidFramework/pull/22751)) [d54b9dde14](https://github.com/microsoft/FluidFramework/commit/d54b9dde14e9e0e5eb7999db8ebf6da98fdfb526)
|
|
41
|
+
|
|
42
|
+
This update introduces a new feature to the `SharedString` DDS, allowing for the adjustment of properties over a specified range. The `annotateAdjustRange` method enables users to apply adjustments to properties within a given range, providing more flexibility and control over property modifications.
|
|
43
|
+
|
|
44
|
+
An adjustment is a modification applied to a property value within a specified range. Adjustments can be used to increment or decrement property values dynamically. They are particularly useful in scenarios where property values need to be updated based on user interactions or other events. For example, in a rich text editor, adjustments can be used for modifying indentation levels or font sizes, where multiple users could apply differing numerical adjustments.
|
|
45
|
+
|
|
46
|
+
### Key Features and Use Cases:
|
|
47
|
+
|
|
48
|
+
- **Adjustments with Constraints**: Adjustments can include optional minimum and maximum constraints to ensure the final value falls within specified bounds. This is particularly useful for maintaining consistent formatting in rich text editors.
|
|
49
|
+
- **Consistent Property Changes**: The feature ensures that property changes are consistent, managing both local and remote changes effectively. This is essential for collaborative rich text editing where multiple users may be making adjustments simultaneously.
|
|
50
|
+
- **Rich Text Formatting**: Adjustments can be used to modify text properties such as font size, indentation, or other formatting attributes dynamically based on user actions.
|
|
51
|
+
|
|
52
|
+
### Configuration and Compatibility Requirements:
|
|
53
|
+
|
|
54
|
+
This feature is only available when the configuration `Fluid.Sequence.mergeTreeEnableAnnotateAdjust` is set to `true`. Additionally, all collaborating clients must have this feature enabled to use it. If any client does not have this feature enabled, it will lead to the client exiting collaboration. A future major version of Fluid will enable this feature by default.
|
|
55
|
+
|
|
56
|
+
### Usage Example:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
sharedString.annotateAdjustRange(start, end, {
|
|
60
|
+
key: { value: 5, min: 0, max: 10 },
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- MergeTree `Client` Legacy API Removed ([#22697](https://github.com/microsoft/FluidFramework/pull/22697)) [2aa0b5e794](https://github.com/microsoft/FluidFramework/commit/2aa0b5e7941efe52386782595f96ff847c786fc3)
|
|
65
|
+
|
|
66
|
+
The `Client` class in the merge-tree package has been removed. Types that directly or indirectly expose the merge-tree `Client` class have also been removed.
|
|
67
|
+
|
|
68
|
+
The removed types were not meant to be used directly, and direct usage was not supported:
|
|
69
|
+
|
|
70
|
+
- AttributionPolicy
|
|
71
|
+
- IClientEvents
|
|
72
|
+
- IMergeTreeAttributionOptions
|
|
73
|
+
- SharedSegmentSequence
|
|
74
|
+
- SharedStringClass
|
|
75
|
+
|
|
76
|
+
Some classes that referenced the `Client` class have been transitioned to interfaces. Direct instantiation of these classes was not supported or necessary for any supported scenario, so the change to an interface should not impact usage. This applies to the following types:
|
|
77
|
+
|
|
78
|
+
- SequenceInterval
|
|
79
|
+
- SequenceEvent
|
|
80
|
+
- SequenceDeltaEvent
|
|
81
|
+
- SequenceMaintenanceEvent
|
|
82
|
+
|
|
83
|
+
The initial deprecations of the now changed or removed types were announced in Fluid Framework v2.4.0:
|
|
84
|
+
[Several MergeTree Client Legacy APIs are now deprecated](https://github.com/microsoft/FluidFramework/blob/main/RELEASE_NOTES/2.4.0.md#several-mergetree-client-legacy-apis-are-now-deprecated-22629)
|
|
85
|
+
|
|
3
86
|
## 2.5.0
|
|
4
87
|
|
|
5
88
|
### Minor Changes
|
|
@@ -216,7 +216,7 @@ export interface IMergeTreeDeltaCallbackArgs<TOperationType extends MergeTreeDel
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// @alpha (undocumented)
|
|
219
|
-
export type IMergeTreeDeltaOp = IMergeTreeInsertMsg | IMergeTreeRemoveMsg | IMergeTreeAnnotateMsg | IMergeTreeObliterateMsg | IMergeTreeObliterateSidedMsg;
|
|
219
|
+
export type IMergeTreeDeltaOp = IMergeTreeInsertMsg | IMergeTreeRemoveMsg | IMergeTreeAnnotateMsg | IMergeTreeAnnotateAdjustMsg | IMergeTreeObliterateMsg | IMergeTreeObliterateSidedMsg;
|
|
220
220
|
|
|
221
221
|
// @alpha (undocumented)
|
|
222
222
|
export interface IMergeTreeDeltaOpArgs {
|
|
@@ -290,6 +290,7 @@ export type IMergeTreeOp = IMergeTreeDeltaOp | IMergeTreeGroupMsg;
|
|
|
290
290
|
export interface IMergeTreeOptions {
|
|
291
291
|
// (undocumented)
|
|
292
292
|
catchUpBlobName?: string;
|
|
293
|
+
mergeTreeEnableAnnotateAdjust?: boolean;
|
|
293
294
|
mergeTreeEnableObliterate?: boolean;
|
|
294
295
|
mergeTreeEnableObliterateReconnect?: boolean;
|
|
295
296
|
mergeTreeEnableSidedObliterate?: boolean;
|
|
@@ -84,7 +84,7 @@ function createPropertyTrackingMergeTreeCallbacks(...propNames) {
|
|
|
84
84
|
segment.properties?.[propName] !== undefined;
|
|
85
85
|
const shouldAttributeAnnotate = op.type === ops_js_1.MergeTreeDeltaType.ANNOTATE &&
|
|
86
86
|
// Only attribute annotations which change the tracked property
|
|
87
|
-
op.props[propName] !== undefined &&
|
|
87
|
+
(op.props?.[propName] !== undefined || op.adjust?.[propName] !== undefined) &&
|
|
88
88
|
(isLocal || (propertyDeltas !== undefined && propName in propertyDeltas));
|
|
89
89
|
if (shouldAttributeInsert || shouldAttributeAnnotate) {
|
|
90
90
|
segment.attribution?.update(channelName, new attributionCollection_js_1.AttributionCollection(segment.cachedLength, key));
|
|
@@ -1 +1 @@
|
|
|
1
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AS;gBAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACnD,CAAC;QACD,WAAW,EAAE,CAAC,GAAG,IAAI,EAAQ,EAAE;YAC9B,KAAK,MAAM,EAAE,WAAW,EAAE,IAAI,SAAS;gBAAE,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/D,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,gDAAgD;AAChD,SAAgB,iCAAiC;IAChD,OAAO,oCAAoC,CAC1C,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;KACpC,CAAC,CACF,CAAC;AACH,CAAC;AAPD,8EAOC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,8CAA8C,CAC7D,GAAG,SAAmB;AACtB,gDAAgD;;IAEhD,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAXD,wGAWC;AAED;;;;;GAKG;AACH,SAAgB,0DAA0D,CACzE,GAAG,SAAmB;AACtB,gDAAgD;;IAEhD,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAZD,gIAYC","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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { AttributionCollection } from \"./attributionCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { AttributionPolicy } from \"./mergeTree.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n\t// eslint-disable-next-line import/no-deprecated\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client): void => {\n\t\t\tassert(unsubscribe === undefined, 0x557 /* cannot attach to multiple clients at once */);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = (): void => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: (): void => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached(): boolean {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\t// eslint-disable-next-line import/no-deprecated\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(\n\t...propNames: string[]\n): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tisLocal: boolean,\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment, propertyDeltas } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\top.props[propName] !== undefined &&\n\t\t\t\t\t(isLocal || (propertyDeltas !== undefined && propName in propertyDeltas));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client): void => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tsequencedMessage === undefined,\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client): void => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\ttrue,\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args): void => {\n\t\t\tfor (const { delta } of callbacks) delta(...args);\n\t\t},\n\t\tmaintenance: (...args): void => {\n\t\t\tfor (const { maintenance } of callbacks) maintenance(...args);\n\t\t},\n\t};\n}\n\n/**\n * Creates an {@link AttributionPolicy} which only tracks initial insertion of content.\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * Creates an {@link AttributionPolicy} for tracking annotation of specific properties.\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @internal\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n\t// eslint-disable-next-line import/no-deprecated\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @internal\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n\t// eslint-disable-next-line import/no-deprecated\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,yEAAmE;AAKnE,2EAMqC;AACrC,qCAA8C;AAoB9C,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW;AACX,gDAAgD;EAC1B;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,gDAAgD;QAChD,MAAM,EAAE,CAAC,MAAc,EAAQ,EAAE;YAChC,IAAA,iBAAM,EAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAEzF,MAAM,eAAe,GAAkC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAC5E,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAClC,MAAM,qBAAqB,GAAwC,CAAC,IA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AgD;;IAEhD,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAXD,wGAWC;AAED;;;;;GAKG;AACH,SAAgB,0DAA0D,CACzE,GAAG,SAAmB;AACtB,gDAAgD;;IAEhD,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAZD,gIAYC","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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { AttributionCollection } from \"./attributionCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { AttributionPolicy } from \"./mergeTree.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n\t// eslint-disable-next-line import/no-deprecated\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client): void => {\n\t\t\tassert(unsubscribe === undefined, 0x557 /* cannot attach to multiple clients at once */);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = (): void => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: (): void => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached(): boolean {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\t// eslint-disable-next-line import/no-deprecated\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(\n\t...propNames: string[]\n): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tisLocal: boolean,\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment, propertyDeltas } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\t(op.props?.[propName] !== undefined || op.adjust?.[propName] !== undefined) &&\n\t\t\t\t\t(isLocal || (propertyDeltas !== undefined && propName in propertyDeltas));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client): void => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tsequencedMessage === undefined,\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client): void => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\ttrue,\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args): void => {\n\t\t\tfor (const { delta } of callbacks) delta(...args);\n\t\t},\n\t\tmaintenance: (...args): void => {\n\t\t\tfor (const { maintenance } of callbacks) maintenance(...args);\n\t\t},\n\t};\n}\n\n/**\n * Creates an {@link AttributionPolicy} which only tracks initial insertion of content.\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * Creates an {@link AttributionPolicy} for tracking annotation of specific properties.\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @internal\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n\t// eslint-disable-next-line import/no-deprecated\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @internal\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n\t// eslint-disable-next-line import/no-deprecated\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ import { LocalReferencePosition, SlidingPreference } from "./localReference.js";
|
|
|
13
13
|
import { type IMergeTreeOptionsInternal } from "./mergeTree.js";
|
|
14
14
|
import type { IMergeTreeDeltaCallbackArgs, IMergeTreeDeltaOpArgs, IMergeTreeMaintenanceCallbackArgs } from "./mergeTreeDeltaCallback.js";
|
|
15
15
|
import { CollaborationWindow, ISegment, ISegmentAction, Marker, SegmentGroup } from "./mergeTreeNodes.js";
|
|
16
|
-
import { IJSONSegment, IMergeTreeAnnotateMsg, IMergeTreeGroupMsg, IMergeTreeInsertMsg, IMergeTreeObliterateMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ReferenceType, type IMergeTreeObliterateSidedMsg } from "./ops.js";
|
|
17
|
-
import { PropertySet } from "./properties.js";
|
|
16
|
+
import { IJSONSegment, IMergeTreeAnnotateMsg, IMergeTreeGroupMsg, IMergeTreeInsertMsg, IMergeTreeObliterateMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ReferenceType, type AdjustParams, type IMergeTreeAnnotateAdjustMsg, type IMergeTreeObliterateSidedMsg } from "./ops.js";
|
|
17
|
+
import { PropertySet, type MapLike } from "./properties.js";
|
|
18
18
|
import { ReferencePosition } from "./referencePositions.js";
|
|
19
19
|
import { type InteriorSequencePlace } from "./sequencePlace.js";
|
|
20
20
|
import { IMergeTreeTextHelper } from "./textSegment.js";
|
|
@@ -93,6 +93,10 @@ export declare class Client extends TypedEventEmitter<IClientEvents> {
|
|
|
93
93
|
* @returns The annotate op if valid, otherwise undefined
|
|
94
94
|
*/
|
|
95
95
|
annotateRangeLocal(start: number, end: number, props: PropertySet): IMergeTreeAnnotateMsg | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* adjusts a value
|
|
98
|
+
*/
|
|
99
|
+
annotateAdjustRangeLocal(start: number, end: number, adjust: MapLike<AdjustParams>): IMergeTreeAnnotateAdjustMsg;
|
|
96
100
|
/**
|
|
97
101
|
* Removes the range
|
|
98
102
|
*
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAAK,qBAAqB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAEN,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAGN,KAAK,yBAAyB,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEX,2BAA2B,EAC3B,qBAAqB,EACrB,iCAAiC,EACjC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEN,mBAAmB,EACnB,QAAQ,EACR,cAAc,EAEd,MAAM,EAEN,YAAY,EAGZ,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA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B,OAAO,CAAC;QAAE,WAAW,EAAE,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAA;KAAE,CAAC;IAMjE,OAAO,CAAC,sBAAsB;IAM9B,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IA+BnD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIlC,oBAAoB,CAAC,CAAC,SAAS,QAAQ,EACtC,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,yBAAyB,GAAG,UAAU,CAAC,EACtF,QAAQ,CAAC,EAAE,MAAM,GACf;QACF,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;QACvB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B;IAWD,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAU7D,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG;QACvC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC;IAaD,aAAa,IAAI,MAAM;IAIvB,WAAW,IAAI,MAAM;IAIrB,SAAS,IAAI,MAAM;IAInB,0BAA0B,CACzB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,SAAI,EACV,UAAU,SAAI,GACZ,IAAI;IAyBP;;;;;;;;OAQG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,MAAM,GAAG,SAAS;CAI3F"}
|
package/dist/client.js
CHANGED
|
@@ -108,6 +108,19 @@ class Client extends client_utils_1.TypedEventEmitter {
|
|
|
108
108
|
this.applyAnnotateRangeOp({ op: annotateOp });
|
|
109
109
|
return annotateOp;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* adjusts a value
|
|
113
|
+
*/
|
|
114
|
+
annotateAdjustRangeLocal(start, end, adjust) {
|
|
115
|
+
const annotateOp = (0, opBuilder_js_1.createAdjustRangeOp)(start, end, adjust);
|
|
116
|
+
for (const [key, value] of Object.entries(adjust)) {
|
|
117
|
+
if (value.min !== undefined && value.max !== undefined && value.min > value.max) {
|
|
118
|
+
throw new internal_4.UsageError(`min is greater than max for ${key}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.applyAnnotateRangeOp({ op: annotateOp });
|
|
122
|
+
return annotateOp;
|
|
123
|
+
}
|
|
111
124
|
/**
|
|
112
125
|
* Removes the range
|
|
113
126
|
*
|
|
@@ -300,7 +313,7 @@ class Client extends client_utils_1.TypedEventEmitter {
|
|
|
300
313
|
const op = opArgs.op;
|
|
301
314
|
const clientArgs = this.getClientSequenceArgs(opArgs);
|
|
302
315
|
const range = this.getValidOpRange(op, clientArgs);
|
|
303
|
-
this._mergeTree.annotateRange(range.start, range.end, op
|
|
316
|
+
this._mergeTree.annotateRange(range.start, range.end, op, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, opArgs);
|
|
304
317
|
}
|
|
305
318
|
/**
|
|
306
319
|
* Performs the insert based on the provided op
|
|
@@ -545,7 +558,8 @@ class Client extends client_utils_1.TypedEventEmitter {
|
|
|
545
558
|
let newOp;
|
|
546
559
|
switch (resetOp.type) {
|
|
547
560
|
case ops_js_1.MergeTreeDeltaType.ANNOTATE: {
|
|
548
|
-
(0, internal_1.assert)(segment.propertyManager?.hasPendingProperties(resetOp.props) ===
|
|
561
|
+
(0, internal_1.assert)(segment.propertyManager?.hasPendingProperties(resetOp.props ?? resetOp.adjust) ===
|
|
562
|
+
true, 0x036 /* "Segment has no pending properties" */);
|
|
549
563
|
// if the segment has been removed or obliterated, there's no need to send the annotate op
|
|
550
564
|
// unless the remove was local, in which case the annotate must have come
|
|
551
565
|
// before the remove
|
|
@@ -555,7 +569,10 @@ class Client extends client_utils_1.TypedEventEmitter {
|
|
|
555
569
|
(segment.movedSeq === undefined ||
|
|
556
570
|
(segment.localMovedSeq !== undefined &&
|
|
557
571
|
segment.movedSeq === constants_js_1.UnassignedSequenceNumber))) {
|
|
558
|
-
newOp =
|
|
572
|
+
newOp =
|
|
573
|
+
resetOp.props === undefined
|
|
574
|
+
? (0, opBuilder_js_1.createAdjustRangeOp)(segmentPosition, segmentPosition + segment.cachedLength, resetOp.adjust)
|
|
575
|
+
: (0, opBuilder_js_1.createAnnotateRangeOp)(segmentPosition, segmentPosition + segment.cachedLength, resetOp.props);
|
|
559
576
|
}
|
|
560
577
|
break;
|
|
561
578
|
}
|