@casual-simulation/aux-common 3.2.6 → 3.2.7-alpha.6227012901
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/Errors.d.ts +29 -0
- package/Errors.js +2 -0
- package/Errors.js.map +1 -0
- package/{aux-format-2 → bots}/AuxStateHelpers.d.ts +2 -33
- package/{aux-format-2 → bots}/AuxStateHelpers.js +1 -116
- package/bots/AuxStateHelpers.js.map +1 -0
- package/bots/Bot.d.ts +1 -1
- package/bots/BotCalculations.d.ts +4 -1
- package/bots/BotCalculations.js +62 -0
- package/bots/BotCalculations.js.map +1 -1
- package/bots/BotEvents.d.ts +859 -3401
- package/bots/BotEvents.js +133 -1529
- package/bots/BotEvents.js.map +1 -1
- package/bots/StateUpdatedEvent.d.ts +1 -1
- package/bots/StateUpdatedEvent.js +1 -1
- package/bots/StateUpdatedEvent.js.map +1 -1
- package/bots/index.d.ts +1 -0
- package/bots/index.js +1 -0
- package/bots/index.js.map +1 -1
- package/common/Action.d.ts +17 -0
- package/common/Action.js +2 -0
- package/common/Action.js.map +1 -0
- package/common/ConnectionIndicator.d.ts +29 -0
- package/common/ConnectionIndicator.js +23 -0
- package/common/ConnectionIndicator.js.map +1 -0
- package/common/ConnectionInfo.d.ts +30 -0
- package/common/ConnectionInfo.js +14 -0
- package/common/ConnectionInfo.js.map +1 -0
- package/common/ConnectionToken.d.ts +37 -0
- package/common/ConnectionToken.js +93 -0
- package/common/ConnectionToken.js.map +1 -0
- package/common/CurrentVersion.d.ts +26 -0
- package/common/CurrentVersion.js +2 -0
- package/common/CurrentVersion.js.map +1 -0
- package/common/Iterators.d.ts +19 -0
- package/common/Iterators.js +39 -0
- package/common/Iterators.js.map +1 -0
- package/common/LoadingProgress.d.ts +26 -0
- package/common/LoadingProgress.js +2 -0
- package/common/LoadingProgress.js.map +1 -0
- package/common/RemoteActions.d.ts +558 -0
- package/common/RemoteActions.js +128 -0
- package/common/RemoteActions.js.map +1 -0
- package/common/StatusUpdate.d.ts +108 -0
- package/common/StatusUpdate.js +2 -0
- package/common/StatusUpdate.js.map +1 -0
- package/common/StatusUpdateUtils.d.ts +3 -0
- package/common/StatusUpdateUtils.js +11 -0
- package/common/StatusUpdateUtils.js.map +1 -0
- package/common/index.d.ts +11 -0
- package/common/index.js +11 -0
- package/common/index.js.map +1 -0
- package/index.d.ts +4 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/package.json +3 -4
- package/partitions/AuxPartition.d.ts +1 -11
- package/partitions/AuxPartition.js.map +1 -1
- package/partitions/AuxPartitionConfig.d.ts +39 -123
- package/partitions/MemoryPartition.d.ts +2 -2
- package/partitions/MemoryPartition.js +2 -2
- package/partitions/MemoryPartition.js.map +1 -1
- package/partitions/OtherPlayersPartition.d.ts +6 -7
- package/partitions/OtherPlayersPartition.js +40 -54
- package/partitions/OtherPlayersPartition.js.map +1 -1
- package/partitions/PartitionUtils.d.ts +28 -1
- package/partitions/PartitionUtils.js +174 -1
- package/partitions/PartitionUtils.js.map +1 -1
- package/partitions/ProxyBridgePartition.d.ts +1 -3
- package/partitions/ProxyBridgePartition.js +0 -14
- package/partitions/ProxyBridgePartition.js.map +1 -1
- package/partitions/RemoteYjsPartition.d.ts +7 -6
- package/partitions/RemoteYjsPartition.js +55 -75
- package/partitions/RemoteYjsPartition.js.map +1 -1
- package/partitions/YjsPartition.d.ts +1 -2
- package/partitions/YjsPartition.js +3 -6
- package/partitions/YjsPartition.js.map +1 -1
- package/partitions/index.d.ts +1 -7
- package/partitions/index.js +1 -7
- package/partitions/index.js.map +1 -1
- package/test/FuzzingHelpers.d.ts +1 -1
- package/test/FuzzingHelpers.js +1 -1
- package/test/FuzzingHelpers.js.map +1 -1
- package/test/TestHelpers.d.ts +8 -0
- package/test/TestHelpers.js +23 -0
- package/test/TestHelpers.js.map +1 -1
- package/utils.d.ts +10 -5
- package/utils.js +19 -7
- package/utils.js.map +1 -1
- package/websockets/AuthenticatedConnectionClient.d.ts +26 -0
- package/websockets/AuthenticatedConnectionClient.js +61 -0
- package/websockets/AuthenticatedConnectionClient.js.map +1 -0
- package/websockets/ConnectionClient.d.ts +59 -0
- package/websockets/ConnectionClient.js +2 -0
- package/websockets/ConnectionClient.js.map +1 -0
- package/websockets/InstRecordsClient.d.ts +118 -0
- package/websockets/InstRecordsClient.js +387 -0
- package/websockets/InstRecordsClient.js.map +1 -0
- package/websockets/InstRecordsClientTimeSyncConnection.d.ts +13 -0
- package/websockets/InstRecordsClientTimeSyncConnection.js +16 -0
- package/websockets/InstRecordsClientTimeSyncConnection.js.map +1 -0
- package/websockets/MemoryConnectionClient.d.ts +19 -0
- package/websockets/MemoryConnectionClient.js +41 -0
- package/websockets/MemoryConnectionClient.js.map +1 -0
- package/websockets/WebsocketEvents.d.ts +2670 -0
- package/websockets/WebsocketEvents.js +189 -0
- package/websockets/WebsocketEvents.js.map +1 -0
- package/websockets/index.d.ts +7 -0
- package/websockets/index.js +7 -0
- package/websockets/index.js.map +1 -0
- package/yjs/YjsHelpers.d.ts +1 -1
- package/LoadingProgress.d.ts +0 -54
- package/LoadingProgress.js +0 -105
- package/LoadingProgress.js.map +0 -1
- package/aux-format-2/AuxCausalTree2.d.ts +0 -98
- package/aux-format-2/AuxCausalTree2.js +0 -616
- package/aux-format-2/AuxCausalTree2.js.map +0 -1
- package/aux-format-2/AuxOpTypes.d.ts +0 -268
- package/aux-format-2/AuxOpTypes.js +0 -240
- package/aux-format-2/AuxOpTypes.js.map +0 -1
- package/aux-format-2/AuxStateHelpers.js.map +0 -1
- package/aux-format-2/AuxWeaveHelpers.d.ts +0 -132
- package/aux-format-2/AuxWeaveHelpers.js +0 -335
- package/aux-format-2/AuxWeaveHelpers.js.map +0 -1
- package/aux-format-2/AuxWeaveReducer.d.ts +0 -37
- package/aux-format-2/AuxWeaveReducer.js +0 -980
- package/aux-format-2/AuxWeaveReducer.js.map +0 -1
- package/aux-format-2/index.d.ts +0 -7
- package/aux-format-2/index.js +0 -7
- package/aux-format-2/index.js.map +0 -1
- package/partitions/AuxPartitionRealtimeEditModeProvider.d.ts +0 -9
- package/partitions/AuxPartitionRealtimeEditModeProvider.js +0 -21
- package/partitions/AuxPartitionRealtimeEditModeProvider.js.map +0 -1
- package/partitions/BotClient.d.ts +0 -24
- package/partitions/BotClient.js +0 -2
- package/partitions/BotClient.js.map +0 -1
- package/partitions/BotPartition.d.ts +0 -45
- package/partitions/BotPartition.js +0 -186
- package/partitions/BotPartition.js.map +0 -1
- package/partitions/CausalRepoPartition.d.ts +0 -45
- package/partitions/CausalRepoPartition.js +0 -157
- package/partitions/CausalRepoPartition.js.map +0 -1
- package/partitions/MemoryBotClient.d.ts +0 -11
- package/partitions/MemoryBotClient.js +0 -41
- package/partitions/MemoryBotClient.js.map +0 -1
- package/partitions/RemoteCausalRepoHistoryPartition.d.ts +0 -53
- package/partitions/RemoteCausalRepoHistoryPartition.js +0 -206
- package/partitions/RemoteCausalRepoHistoryPartition.js.map +0 -1
- package/partitions/RemoteCausalRepoPartition.d.ts +0 -72
- package/partitions/RemoteCausalRepoPartition.js +0 -468
- package/partitions/RemoteCausalRepoPartition.js.map +0 -1
- package/runtime/AuxCompiler.d.ts +0 -258
- package/runtime/AuxCompiler.js +0 -722
- package/runtime/AuxCompiler.js.map +0 -1
- package/runtime/AuxDevice.d.ts +0 -28
- package/runtime/AuxDevice.js +0 -2
- package/runtime/AuxDevice.js.map +0 -1
- package/runtime/AuxGlobalContext.d.ts +0 -571
- package/runtime/AuxGlobalContext.js +0 -606
- package/runtime/AuxGlobalContext.js.map +0 -1
- package/runtime/AuxLibrary.d.ts +0 -2702
- package/runtime/AuxLibrary.js +0 -11046
- package/runtime/AuxLibrary.js.map +0 -1
- package/runtime/AuxLibraryDefinitions.def +0 -13139
- package/runtime/AuxRealtimeEditModeProvider.d.ts +0 -35
- package/runtime/AuxRealtimeEditModeProvider.js +0 -34
- package/runtime/AuxRealtimeEditModeProvider.js.map +0 -1
- package/runtime/AuxResults.d.ts +0 -77
- package/runtime/AuxResults.js +0 -6
- package/runtime/AuxResults.js.map +0 -1
- package/runtime/AuxRuntime.d.ts +0 -253
- package/runtime/AuxRuntime.js +0 -2700
- package/runtime/AuxRuntime.js.map +0 -1
- package/runtime/AuxRuntimeDynamicImports.d.ts +0 -14
- package/runtime/AuxRuntimeDynamicImports.js +0 -24
- package/runtime/AuxRuntimeDynamicImports.js.map +0 -1
- package/runtime/AuxVersion.d.ts +0 -39
- package/runtime/AuxVersion.js +0 -2
- package/runtime/AuxVersion.js.map +0 -1
- package/runtime/CasualOSError.d.ts +0 -37
- package/runtime/CasualOSError.js +0 -25
- package/runtime/CasualOSError.js.map +0 -1
- package/runtime/CompiledBot.d.ts +0 -106
- package/runtime/CompiledBot.js +0 -44
- package/runtime/CompiledBot.js.map +0 -1
- package/runtime/PerformanceNowPolyfill.d.ts +0 -1
- package/runtime/PerformanceNowPolyfill.js +0 -8
- package/runtime/PerformanceNowPolyfill.js.map +0 -1
- package/runtime/RuntimeBot.d.ts +0 -176
- package/runtime/RuntimeBot.js +0 -732
- package/runtime/RuntimeBot.js.map +0 -1
- package/runtime/RuntimeStateVersion.d.ts +0 -23
- package/runtime/RuntimeStateVersion.js +0 -22
- package/runtime/RuntimeStateVersion.js.map +0 -1
- package/runtime/Transpiler.d.ts +0 -174
- package/runtime/Transpiler.js +0 -611
- package/runtime/Transpiler.js.map +0 -1
- package/runtime/Utils.d.ts +0 -74
- package/runtime/Utils.js +0 -488
- package/runtime/Utils.js.map +0 -1
- package/runtime/index.d.ts +0 -9
- package/runtime/index.js +0 -9
- package/runtime/index.js.map +0 -1
- package/runtime/test/RuntimeTestHelpers.d.ts +0 -11
- package/runtime/test/RuntimeTestHelpers.js +0 -26
- package/runtime/test/RuntimeTestHelpers.js.map +0 -1
- package/runtime/test/TestScriptBotFactory.d.ts +0 -16
- package/runtime/test/TestScriptBotFactory.js +0 -107
- package/runtime/test/TestScriptBotFactory.js.map +0 -1
- /package/{runtime/BlobPolyfill.d.ts → BlobPolyfill.d.ts} +0 -0
- /package/{runtime/BlobPolyfill.js → BlobPolyfill.js} +0 -0
- /package/{runtime/BlobPolyfill.js.map → BlobPolyfill.js.map} +0 -0
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
import { applyResult as applyTreeResult, addAtom, tree, mergeResults, addedAtom, insertAtom, removeAtom, addResults, first, calculateTimeFromId, iterateChildren, addedWeaveAtoms, } from '@casual-simulation/causal-trees/core2';
|
|
2
|
-
import { tag, value, bot, deleteOp, signedCert, signedValue, signedRevocation, tagMask, insertOp, AuxOpType, } from './AuxOpTypes';
|
|
3
|
-
import reducer, { certificateId, getTextEditNodes } from './AuxWeaveReducer';
|
|
4
|
-
import { merge } from '../utils';
|
|
5
|
-
import { apply, updates as stateUpdates, isTagEdit, mergeEdits, } from './AuxStateHelpers';
|
|
6
|
-
import { enqueueAsyncResult, enqueueAsyncError, } from '../bots/BotEvents';
|
|
7
|
-
import { findTagNode, findValueNode, findBotNode, findBotNodes, findValueNodeByValue, findTagMaskNodes, findEditPosition, calculateFinalEditValue, } from './AuxWeaveHelpers';
|
|
8
|
-
import { merge as lodashMerge } from 'lodash';
|
|
9
|
-
import { v4 as uuid } from 'uuid';
|
|
10
|
-
import { ensureTagIsSerializable } from '../runtime/Utils';
|
|
11
|
-
import { hasValue } from '../bots/BotCalculations';
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new AUX tree with the given ID.
|
|
14
|
-
* @param id The ID.
|
|
15
|
-
* @param remoteId The remote ID. If given true then a remote ID will be auto generated.
|
|
16
|
-
*/
|
|
17
|
-
export function auxTree(id, remoteId) {
|
|
18
|
-
return Object.assign(Object.assign({}, tree(id, undefined, remoteId === true
|
|
19
|
-
? uuid()
|
|
20
|
-
: remoteId === false
|
|
21
|
-
? undefined
|
|
22
|
-
: remoteId)), { state: {} });
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Adds a new atom to the given tree with the given cause, operation, and priority.
|
|
26
|
-
* Returns a result that can be applied to the tree to get the updated state.
|
|
27
|
-
* @param tree The tree.
|
|
28
|
-
* @param cause The cause of the operation.
|
|
29
|
-
* @param op The operation.
|
|
30
|
-
* @param priority The priority.
|
|
31
|
-
* @param space The space that new bots should be placed in.
|
|
32
|
-
*/
|
|
33
|
-
export function addAuxAtom(tree, cause, op, priority, space, cardinality) {
|
|
34
|
-
const treeResult = addAtom(tree, cause, op, priority, cardinality);
|
|
35
|
-
const update = reducer(tree.weave, treeResult.results[0], undefined, space);
|
|
36
|
-
return Object.assign(Object.assign({}, treeResult), { update });
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Inserts the given atom into the given tree.
|
|
40
|
-
* @param tree The tree.
|
|
41
|
-
* @param atom The atom.
|
|
42
|
-
*/
|
|
43
|
-
export function insertAuxAtom(tree, atom) {
|
|
44
|
-
const treeResult = insertAtom(tree, atom);
|
|
45
|
-
const update = reducer(tree.weave, treeResult.results[0]);
|
|
46
|
-
return Object.assign(Object.assign({}, treeResult), { update });
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Removes the atom with the given hash from the given tree.
|
|
50
|
-
* @param tree The tree.
|
|
51
|
-
* @param hash The atom hash.
|
|
52
|
-
*/
|
|
53
|
-
export function removeAuxAtom(tree, hash) {
|
|
54
|
-
const treeResult = removeAtom(tree, hash);
|
|
55
|
-
if (treeResult.results.length > 0) {
|
|
56
|
-
const update = reducer(tree.weave, treeResult.results[0]);
|
|
57
|
-
return Object.assign(Object.assign({}, treeResult), { update });
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return Object.assign(Object.assign({}, treeResult), { update: {} });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Merges two AUX results into a single final result.
|
|
65
|
-
* @param first The first result.
|
|
66
|
-
* @param second The second result.
|
|
67
|
-
*/
|
|
68
|
-
export function mergeAuxResults(first, second) {
|
|
69
|
-
let merged = merge(first.update, second.update);
|
|
70
|
-
// Check the merged state for tag edits
|
|
71
|
-
// that may need to be merged together specially
|
|
72
|
-
for (let id in merged) {
|
|
73
|
-
let bot = merged[id];
|
|
74
|
-
let bot1 = first.update[id];
|
|
75
|
-
let bot2 = second.update[id];
|
|
76
|
-
if (bot && bot1 && bot2) {
|
|
77
|
-
let tags = bot.tags;
|
|
78
|
-
let tags1 = bot1.tags;
|
|
79
|
-
let tags2 = bot2.tags;
|
|
80
|
-
for (let tag in tags) {
|
|
81
|
-
let value1 = tags1[tag];
|
|
82
|
-
let value2 = tags2[tag];
|
|
83
|
-
if (isTagEdit(value1) && isTagEdit(value2)) {
|
|
84
|
-
tags[tag] = mergeEdits(value1, value2);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
let masks = bot.masks;
|
|
88
|
-
let masks1 = bot1.masks;
|
|
89
|
-
let masks2 = bot2.masks;
|
|
90
|
-
for (let space in masks) {
|
|
91
|
-
let tags = masks[space];
|
|
92
|
-
let tags1 = masks1[space];
|
|
93
|
-
let tags2 = masks2[space];
|
|
94
|
-
for (let tag in tags) {
|
|
95
|
-
let value1 = tags1[tag];
|
|
96
|
-
let value2 = tags2[tag];
|
|
97
|
-
if (isTagEdit(value1) && isTagEdit(value2)) {
|
|
98
|
-
tags[tag] = mergeEdits(value1, value2);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return Object.assign(Object.assign({}, mergeResults(first, second)), { update: merged });
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Adds the results from the second result to the first result.
|
|
108
|
-
* @param first The first result.
|
|
109
|
-
* @param second The second result.
|
|
110
|
-
*/
|
|
111
|
-
export function addAuxResults(first, second) {
|
|
112
|
-
addResults(first, second);
|
|
113
|
-
first.update = merge(first.update, second.update);
|
|
114
|
-
return first;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Applies the given AuxResult to the tree.
|
|
118
|
-
* @param tree The tree.
|
|
119
|
-
* @param result The result.
|
|
120
|
-
*/
|
|
121
|
-
export function applyAuxResult(tree, result) {
|
|
122
|
-
const newTree = applyTreeResult(tree, result);
|
|
123
|
-
return Object.assign(Object.assign({}, newTree), { state: apply(tree.state, result.update) });
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Gets the identity AuxResult.
|
|
127
|
-
* That is, an AuxResult that when merged with another AuxResult returns the other AuxResult.
|
|
128
|
-
*/
|
|
129
|
-
export function auxResultIdentity() {
|
|
130
|
-
return {
|
|
131
|
-
results: [],
|
|
132
|
-
newSite: null,
|
|
133
|
-
update: {},
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Applies the given bot actions to the given tree.
|
|
138
|
-
* Returns the new tree and the list of updates that occurred.
|
|
139
|
-
* @param tree The tree that the events should be applied on top of.
|
|
140
|
-
* @param actions The actions that should be applied.
|
|
141
|
-
* @param space The space that new bots should be placed in.
|
|
142
|
-
*/
|
|
143
|
-
// TODO: Cleanup this function. It creates way too many extra objects and doesn't manage the return data very well.
|
|
144
|
-
export function applyEvents(tree, actions, space) {
|
|
145
|
-
const addAtomToTree = (cause, op, priority, cardinality) => {
|
|
146
|
-
const result = addAuxAtom(tree, cause, op, priority, space, cardinality);
|
|
147
|
-
tree = applyAuxResult(tree, result);
|
|
148
|
-
return result;
|
|
149
|
-
};
|
|
150
|
-
const updateTag = (node, currentVal, val) => {
|
|
151
|
-
// let valueResult: AuxResult;
|
|
152
|
-
if (isTagEdit(val)) {
|
|
153
|
-
let update = {};
|
|
154
|
-
let updatedTree = tree;
|
|
155
|
-
let results = [];
|
|
156
|
-
const version = Object.assign(Object.assign({}, val.version), { [tree.site.id]: tree.site.time });
|
|
157
|
-
if (!currentVal) {
|
|
158
|
-
const valueResult = addAtom(updatedTree, node.atom, value(''));
|
|
159
|
-
updatedTree = applyTreeResult(updatedTree, valueResult);
|
|
160
|
-
const newAtom = addedAtom(valueResult.results[0]);
|
|
161
|
-
currentVal = updatedTree.weave.getNode(newAtom.id);
|
|
162
|
-
for (let result of valueResult.results) {
|
|
163
|
-
update = reducer(updatedTree.weave, result, update, space);
|
|
164
|
-
}
|
|
165
|
-
results.push(...valueResult.results);
|
|
166
|
-
}
|
|
167
|
-
for (let ops of val.operations) {
|
|
168
|
-
let index = 0;
|
|
169
|
-
for (let op of ops) {
|
|
170
|
-
if (op.type === 'preserve') {
|
|
171
|
-
index += op.count;
|
|
172
|
-
}
|
|
173
|
-
else if (op.type === 'insert') {
|
|
174
|
-
if (op.text.length <= 0) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const editPos = findEditPosition(currentVal, version, index);
|
|
178
|
-
if (!editPos) {
|
|
179
|
-
console.warn('[AuxCausalTree2] Unable to find edit position for insert. This likely means that the given edit version is incorrect.');
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
const insertResult = addAtom(updatedTree, editPos.node.atom, insertOp(editPos.index, op.text), undefined, undefined, val.isRemote);
|
|
183
|
-
updatedTree = applyTreeResult(updatedTree, insertResult);
|
|
184
|
-
for (let result of insertResult.results) {
|
|
185
|
-
update = reducer(updatedTree.weave, result, update, space);
|
|
186
|
-
}
|
|
187
|
-
results.push(...insertResult.results);
|
|
188
|
-
index += op.text.length;
|
|
189
|
-
}
|
|
190
|
-
else if (op.type === 'delete') {
|
|
191
|
-
if (op.count <= 0) {
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
const editPos = findEditPosition(currentVal, version, index, op.count);
|
|
195
|
-
if (!editPos || editPos.length <= 0) {
|
|
196
|
-
console.warn('[AuxCausalTree2] Unable to find edit position for delete. This likely means that the given edit version is incorrect.');
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
for (let pos of editPos) {
|
|
200
|
-
const deleteResult = addAtom(updatedTree, pos.node.atom, deleteOp(pos.index, pos.index + pos.count), 1, undefined, val.isRemote);
|
|
201
|
-
updatedTree = applyTreeResult(updatedTree, deleteResult);
|
|
202
|
-
for (let result of deleteResult.results) {
|
|
203
|
-
update = reducer(updatedTree.weave, result, update, space);
|
|
204
|
-
}
|
|
205
|
-
results.push(...deleteResult.results);
|
|
206
|
-
}
|
|
207
|
-
// Increment the index because deletions do not affect the value node character indexes.
|
|
208
|
-
index += op.count;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
version[updatedTree.site.id] = updatedTree.site.time;
|
|
212
|
-
if (updatedTree.remoteSite) {
|
|
213
|
-
version[updatedTree.remoteSite.id] =
|
|
214
|
-
updatedTree.remoteSite.time;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
let auxResult = {
|
|
218
|
-
newSite: updatedTree.site,
|
|
219
|
-
newRemoteSite: updatedTree.remoteSite,
|
|
220
|
-
results: results,
|
|
221
|
-
update: update,
|
|
222
|
-
};
|
|
223
|
-
tree = applyAuxResult(tree, auxResult);
|
|
224
|
-
return auxResult;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
return addAtomToTree(node.atom, value(val));
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
const updateTags = (bot, tags) => {
|
|
231
|
-
let result = auxResultIdentity();
|
|
232
|
-
for (let key in tags) {
|
|
233
|
-
let node = findTagNode(bot, key);
|
|
234
|
-
const val = ensureTagIsSerializable(tags[key]);
|
|
235
|
-
if (!node) {
|
|
236
|
-
// create new tag
|
|
237
|
-
const tagResult = addAtomToTree(bot.atom, tag(key));
|
|
238
|
-
result = mergeAuxResults(result, tagResult);
|
|
239
|
-
const newAtom = addedAtom(tagResult.results[0]);
|
|
240
|
-
if (!newAtom) {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
node = tree.weave.getNode(newAtom.id);
|
|
244
|
-
}
|
|
245
|
-
const currentVal = findValueNode(node);
|
|
246
|
-
if (!hasValue(val) && !hasValue(currentVal === null || currentVal === void 0 ? void 0 : currentVal.atom.value.value)) {
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
if (!currentVal ||
|
|
250
|
-
val !== (currentVal === null || currentVal === void 0 ? void 0 : currentVal.atom.value.value) ||
|
|
251
|
-
Array.isArray(val) ||
|
|
252
|
-
first(iterateChildren(currentVal)) !== undefined) {
|
|
253
|
-
const valueResult = updateTag(node, currentVal, val);
|
|
254
|
-
result = mergeAuxResults(result, valueResult);
|
|
255
|
-
const newAtom = addedAtom(valueResult.results[0]);
|
|
256
|
-
if (newAtom && newAtom.value.type === AuxOpType.Value) {
|
|
257
|
-
const weaveResult = tree.weave.removeSiblingsBefore(newAtom);
|
|
258
|
-
result = mergeAuxResults(result, {
|
|
259
|
-
results: [weaveResult],
|
|
260
|
-
newSite: null,
|
|
261
|
-
update: {},
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return result;
|
|
267
|
-
};
|
|
268
|
-
const updateTagMasks = (botId, tags) => {
|
|
269
|
-
let result = auxResultIdentity();
|
|
270
|
-
for (let key in tags) {
|
|
271
|
-
let node = first(findTagMaskNodes(tree.weave, botId, key));
|
|
272
|
-
const val = ensureTagIsSerializable(tags[key]);
|
|
273
|
-
if (!node) {
|
|
274
|
-
// create new tag
|
|
275
|
-
const tagResult = addAtomToTree(null, tagMask(botId, key));
|
|
276
|
-
result = mergeAuxResults(result, tagResult);
|
|
277
|
-
const newAtom = addedAtom(tagResult.results[0]);
|
|
278
|
-
if (!newAtom) {
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
node = tree.weave.getNode(newAtom.id);
|
|
282
|
-
}
|
|
283
|
-
const currentVal = findValueNode(node);
|
|
284
|
-
if (!currentVal ||
|
|
285
|
-
val !== currentVal.atom.value.value ||
|
|
286
|
-
Array.isArray(val) ||
|
|
287
|
-
first(iterateChildren(currentVal)) !== undefined) {
|
|
288
|
-
const valueResult = updateTag(node, currentVal, val);
|
|
289
|
-
result = mergeAuxResults(result, valueResult);
|
|
290
|
-
const newAtom = addedAtom(valueResult.results[0]);
|
|
291
|
-
if (newAtom && newAtom.value.type === AuxOpType.Value) {
|
|
292
|
-
const weaveResult = tree.weave.removeSiblingsBefore(newAtom);
|
|
293
|
-
result = mergeAuxResults(result, {
|
|
294
|
-
results: [weaveResult],
|
|
295
|
-
newSite: null,
|
|
296
|
-
update: {},
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return result;
|
|
302
|
-
};
|
|
303
|
-
const prevState = tree.state;
|
|
304
|
-
let result = auxResultIdentity();
|
|
305
|
-
let returnActions = [];
|
|
306
|
-
for (let event of actions) {
|
|
307
|
-
let newResult = auxResultIdentity();
|
|
308
|
-
if (event.type === 'add_bot') {
|
|
309
|
-
const botResult = addAtomToTree(null, bot(event.id));
|
|
310
|
-
const botAtom = addedAtom(botResult.results[0]);
|
|
311
|
-
if (botAtom) {
|
|
312
|
-
const botNode = tree.weave.getNode(botAtom.id);
|
|
313
|
-
const tagsResult = updateTags(botNode, event.bot.tags);
|
|
314
|
-
newResult = mergeAuxResults(botResult, tagsResult);
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
newResult = botResult;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
else if (event.type === 'update_bot') {
|
|
321
|
-
let oldResult = newResult;
|
|
322
|
-
if (event.update.tags) {
|
|
323
|
-
const node = findBotNode(tree.weave, event.id);
|
|
324
|
-
if (node) {
|
|
325
|
-
newResult = updateTags(node, event.update.tags);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (event.update.masks && space && event.update.masks[space]) {
|
|
329
|
-
newResult = updateTagMasks(event.id, event.update.masks[space]);
|
|
330
|
-
}
|
|
331
|
-
if (newResult === oldResult) {
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else if (event.type == 'remove_bot') {
|
|
336
|
-
for (let node of findBotNodes(tree.weave, event.id)) {
|
|
337
|
-
newResult = addAtomToTree(node.atom, deleteOp(), 1);
|
|
338
|
-
const newAtom = addedAtom(newResult.results[0]);
|
|
339
|
-
if (newAtom) {
|
|
340
|
-
const weaveResult = tree.weave.removeSiblingsBefore(newAtom);
|
|
341
|
-
newResult = mergeAuxResults(newResult, {
|
|
342
|
-
results: [weaveResult],
|
|
343
|
-
newSite: null,
|
|
344
|
-
update: {},
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
else if (event.type === 'create_certificate') {
|
|
350
|
-
if (!event.signingBotId) {
|
|
351
|
-
const certOp = signedCert(null, event.signingPassword, event.keypair);
|
|
352
|
-
if (!certOp) {
|
|
353
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
354
|
-
continue;
|
|
355
|
-
}
|
|
356
|
-
newResult = addAtomToTree(null, certOp, undefined, {
|
|
357
|
-
group: 'certificates',
|
|
358
|
-
number: 1,
|
|
359
|
-
});
|
|
360
|
-
const newAtom = addedAtom(newResult.results[0]);
|
|
361
|
-
if (newAtom) {
|
|
362
|
-
const id = certificateId(newAtom);
|
|
363
|
-
const newBot = tree.state[id];
|
|
364
|
-
if (newBot) {
|
|
365
|
-
enqueueAsyncResult(returnActions, event, newBot, true);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
const signingBot = tree.state[event.signingBotId];
|
|
377
|
-
if (!signingBot) {
|
|
378
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
try {
|
|
382
|
-
const certOp = signedCert(signingBot.tags.atom, event.signingPassword, event.keypair);
|
|
383
|
-
if (!certOp) {
|
|
384
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
newResult = addAtomToTree(signingBot.tags.atom, certOp);
|
|
388
|
-
const newAtom = addedAtom(newResult.results[0]);
|
|
389
|
-
if (newAtom) {
|
|
390
|
-
const id = certificateId(newAtom);
|
|
391
|
-
const newBot = tree.state[id];
|
|
392
|
-
if (newBot) {
|
|
393
|
-
enqueueAsyncResult(returnActions, event, newBot, true);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
catch (err) {
|
|
404
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create certificate.'));
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
else if (event.type === 'sign_tag') {
|
|
410
|
-
const signingBot = tree.state[event.signingBotId];
|
|
411
|
-
if (!signingBot) {
|
|
412
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
const botNode = findBotNode(tree.weave, event.botId);
|
|
416
|
-
if (!botNode) {
|
|
417
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
const tagNode = findTagNode(botNode, event.tag);
|
|
421
|
-
if (!tagNode) {
|
|
422
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
const valueNode = findValueNodeByValue(tagNode, event.value);
|
|
426
|
-
if (!valueNode) {
|
|
427
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
428
|
-
continue;
|
|
429
|
-
}
|
|
430
|
-
try {
|
|
431
|
-
const signOp = signedValue(signingBot.tags.atom, event.signingPassword, valueNode.atom);
|
|
432
|
-
if (!signOp) {
|
|
433
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
newResult = addAtomToTree(signingBot.tags.atom, signOp);
|
|
437
|
-
const newAtom = addedAtom(newResult.results[0]);
|
|
438
|
-
if (newAtom) {
|
|
439
|
-
enqueueAsyncResult(returnActions, event, undefined);
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
catch (err) {
|
|
446
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to create signature.'));
|
|
447
|
-
continue;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
else if (event.type === 'revoke_certificate') {
|
|
451
|
-
const signingBot = tree.state[event.signingBotId];
|
|
452
|
-
if (!signingBot) {
|
|
453
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to revoke certificate. Signing certificate does not exist!'));
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
const certificateBot = tree.state[event.certificateBotId];
|
|
457
|
-
if (!certificateBot) {
|
|
458
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to revoke certificate. Certificate does not exist!'));
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
try {
|
|
462
|
-
const revokeOp = signedRevocation(signingBot.tags.atom, event.signingPassword, certificateBot.tags.atom);
|
|
463
|
-
if (!revokeOp) {
|
|
464
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to revoke certificate.'));
|
|
465
|
-
continue;
|
|
466
|
-
}
|
|
467
|
-
newResult = addAtomToTree(signingBot.tags.atom, revokeOp);
|
|
468
|
-
const newAtom = addedAtom(newResult.results[0]);
|
|
469
|
-
if (newAtom) {
|
|
470
|
-
enqueueAsyncResult(returnActions, event, undefined);
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to revoke certificate.'));
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
catch (err) {
|
|
477
|
-
enqueueAsyncError(returnActions, event, new Error('Unable to revoke certificate.'));
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
result = mergeAuxResults(result, newResult);
|
|
482
|
-
}
|
|
483
|
-
const updates = stateUpdates(prevState, result.update);
|
|
484
|
-
return {
|
|
485
|
-
tree,
|
|
486
|
-
updates,
|
|
487
|
-
result,
|
|
488
|
-
actions: returnActions,
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Applies the given atoms to the given tree.
|
|
493
|
-
* Returns the new tree and list of updates that occurred.
|
|
494
|
-
* @param tree The tree.
|
|
495
|
-
* @param atoms The atoms.
|
|
496
|
-
* @param removedAtoms The atoms that were removed.
|
|
497
|
-
* @param space The space that the bots should have.
|
|
498
|
-
* @param delta Whether the atoms are the initial atoms being added to the tree.
|
|
499
|
-
*/
|
|
500
|
-
export function applyAtoms(tree, atoms, removedAtoms, space, initial = false) {
|
|
501
|
-
let update = {};
|
|
502
|
-
let results = [];
|
|
503
|
-
let editedTags = new Map();
|
|
504
|
-
if (atoms) {
|
|
505
|
-
for (let atom of atoms) {
|
|
506
|
-
const result = tree.weave.insert(atom);
|
|
507
|
-
if (result.type === 'cause_not_found' &&
|
|
508
|
-
!result.savedInReorderBuffer) {
|
|
509
|
-
console.warn('[AuxCausalTree] Atom cause was not found and was not saved in reorder buffer! This may cause sync failure.', result);
|
|
510
|
-
}
|
|
511
|
-
results.push(result);
|
|
512
|
-
reducer(tree.weave, result, update, space, initial);
|
|
513
|
-
const addedAtoms = addedWeaveAtoms(result);
|
|
514
|
-
if (addedAtoms) {
|
|
515
|
-
for (let added of addedAtoms) {
|
|
516
|
-
tree.site.time = calculateTimeFromId(tree.site.id, tree.site.time, added.id.site, added.id.timestamp);
|
|
517
|
-
tree.version[added.id.site] = Math.max(added.id.timestamp, tree.version[added.id.site] || 0);
|
|
518
|
-
// If this is the initial load then
|
|
519
|
-
// we should check the added atoms to see if
|
|
520
|
-
// there are any inserts that we need to resolve the final value of later.
|
|
521
|
-
if (initial) {
|
|
522
|
-
if (atom.value.type === AuxOpType.Insert) {
|
|
523
|
-
const { botId, tag, isTagMask, value } = getBotIdAndTagNameForEdit(tree.weave, atom);
|
|
524
|
-
if (!!botId && !!tag) {
|
|
525
|
-
editedTags.set(`${botId}.${tag}`, [
|
|
526
|
-
botId,
|
|
527
|
-
tag,
|
|
528
|
-
isTagMask,
|
|
529
|
-
value,
|
|
530
|
-
]);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
else if (atom.value.type === AuxOpType.Delete) {
|
|
534
|
-
const parent = tree.weave.getNode(atom.cause);
|
|
535
|
-
if (parent.atom.value.type === AuxOpType.Insert ||
|
|
536
|
-
parent.atom.value.type === AuxOpType.Value) {
|
|
537
|
-
const { botId, tag, isTagMask, value } = getBotIdAndTagNameForEdit(tree.weave, atom);
|
|
538
|
-
if (!!botId && !!tag) {
|
|
539
|
-
editedTags.set(`${botId}.${tag}`, [
|
|
540
|
-
botId,
|
|
541
|
-
tag,
|
|
542
|
-
isTagMask,
|
|
543
|
-
value,
|
|
544
|
-
]);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
if (removedAtoms) {
|
|
554
|
-
for (let hash of removedAtoms) {
|
|
555
|
-
const node = tree.weave.getNodeByHash(hash);
|
|
556
|
-
if (node) {
|
|
557
|
-
const result = tree.weave.remove(node.atom);
|
|
558
|
-
results.push(result);
|
|
559
|
-
reducer(tree.weave, result, update, space, initial);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
// Resolve the final value of the edited tags.
|
|
564
|
-
for (let [id, tag, isTagMask, value] of editedTags.values()) {
|
|
565
|
-
const finalValue = calculateFinalEditValue(value);
|
|
566
|
-
if (isTagMask) {
|
|
567
|
-
lodashMerge(update, {
|
|
568
|
-
[id]: {
|
|
569
|
-
masks: {
|
|
570
|
-
[space]: {
|
|
571
|
-
[tag]: finalValue,
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
lodashMerge(update, {
|
|
579
|
-
[id]: {
|
|
580
|
-
tags: {
|
|
581
|
-
[tag]: finalValue,
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
const prevState = tree.state;
|
|
588
|
-
const finalState = apply(prevState, update);
|
|
589
|
-
const updates = stateUpdates(prevState, update);
|
|
590
|
-
tree.state = finalState;
|
|
591
|
-
return { tree, updates, results, update };
|
|
592
|
-
}
|
|
593
|
-
function getBotIdAndTagNameForEdit(weave, atom) {
|
|
594
|
-
const { tag: tagOrValue, bot: botOrTagMask, value, } = getTextEditNodes(weave, atom);
|
|
595
|
-
let botId;
|
|
596
|
-
let tag;
|
|
597
|
-
let isTagMask = false;
|
|
598
|
-
if (botOrTagMask.atom.value.type === AuxOpType.Bot) {
|
|
599
|
-
botId = botOrTagMask.atom.value.id;
|
|
600
|
-
if (tagOrValue.atom.value.type === AuxOpType.Tag) {
|
|
601
|
-
tag = tagOrValue.atom.value.name;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
else if (botOrTagMask.atom.value.type === AuxOpType.TagMask) {
|
|
605
|
-
botId = botOrTagMask.atom.value.botId;
|
|
606
|
-
tag = botOrTagMask.atom.value.name;
|
|
607
|
-
isTagMask = true;
|
|
608
|
-
}
|
|
609
|
-
return {
|
|
610
|
-
botId,
|
|
611
|
-
tag,
|
|
612
|
-
isTagMask,
|
|
613
|
-
value: value,
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
//# sourceMappingURL=AuxCausalTree2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuxCausalTree2.js","sourceRoot":"","sources":["AuxCausalTree2.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,WAAW,IAAI,eAAe,EAC9B,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,EAET,UAAU,EACV,UAAU,EACV,UAAU,EAKV,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,GAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEH,GAAG,EAEH,KAAK,EACL,GAAG,EACH,QAAQ,EAGR,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,OAAO,EAEP,QAAQ,EAER,SAAS,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,OAAO,EAAE,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EACH,KAAK,EACL,OAAO,IAAI,YAAY,EAEvB,SAAS,EACT,UAAU,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKH,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAgBnD;;;;GAIG;AACH,MAAM,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