@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,335 +0,0 @@
|
|
|
1
|
-
import { AuxOpType, } from './AuxOpTypes';
|
|
2
|
-
import { iterateCausalGroup, first, idEquals, } from '@casual-simulation/causal-trees/core2';
|
|
3
|
-
import { isEqual } from 'lodash';
|
|
4
|
-
import { splice } from '../utils';
|
|
5
|
-
import { convertToString } from '../bots/BotCalculations';
|
|
6
|
-
/**
|
|
7
|
-
* Finds the first weave node that defines a bot with the given ID.
|
|
8
|
-
* @param weave The weave to search through.
|
|
9
|
-
* @param id The bot ID.
|
|
10
|
-
*/
|
|
11
|
-
export function findBotNode(weave, id) {
|
|
12
|
-
return first(findBotNodes(weave, id)) || null;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Finds all of the weave nodes that define a bot with the given ID.
|
|
16
|
-
* @param weave The weave to search through.
|
|
17
|
-
* @param id The bot ID.
|
|
18
|
-
*/
|
|
19
|
-
export function* findBotNodes(weave, id) {
|
|
20
|
-
for (let root of weave.roots) {
|
|
21
|
-
if (root.atom.value.type === AuxOpType.Bot &&
|
|
22
|
-
root.atom.value.id === id) {
|
|
23
|
-
const firstAtom = first(iterateCausalGroup(root));
|
|
24
|
-
if (!firstAtom || firstAtom.atom.value.type !== AuxOpType.Delete) {
|
|
25
|
-
yield root;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Finds the weave node that represents the given tag on the given bot node.
|
|
32
|
-
* @param bot The bot node that should be searched.
|
|
33
|
-
* @param tag The tag to find.
|
|
34
|
-
*/
|
|
35
|
-
export function findTagNode(bot, tag) {
|
|
36
|
-
for (let node of iterateCausalGroup(bot)) {
|
|
37
|
-
if (node.atom.value.type === AuxOpType.Tag &&
|
|
38
|
-
node.atom.value.name === tag) {
|
|
39
|
-
return node;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Finds the tag mask node for the given bot ID and tag.
|
|
46
|
-
* @param weave The weave.
|
|
47
|
-
* @param botId The ID of the bot.
|
|
48
|
-
* @param tag The tag.
|
|
49
|
-
*/
|
|
50
|
-
export function* findTagMaskNodes(weave, botId, tag) {
|
|
51
|
-
for (let root of weave.roots) {
|
|
52
|
-
if (root.atom.value.type === AuxOpType.TagMask &&
|
|
53
|
-
root.atom.value.botId === botId &&
|
|
54
|
-
root.atom.value.name === tag) {
|
|
55
|
-
const firstAtom = first(iterateCausalGroup(root));
|
|
56
|
-
if (!firstAtom || firstAtom.atom.value.type !== AuxOpType.Delete) {
|
|
57
|
-
yield root;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Finds the first value weave node for the given tag node.
|
|
64
|
-
* @param tag The tag node that should be searched.
|
|
65
|
-
*/
|
|
66
|
-
export function findValueNode(tag) {
|
|
67
|
-
for (let node of iterateCausalGroup(tag)) {
|
|
68
|
-
if (node.atom.value.type === AuxOpType.Value) {
|
|
69
|
-
return node;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Finds the first value weave node for the given tag node and value.
|
|
76
|
-
* @param tag The tag node that should be searched.
|
|
77
|
-
* @param value The value that should be matched.
|
|
78
|
-
*/
|
|
79
|
-
export function findValueNodeByValue(tag, value) {
|
|
80
|
-
for (let node of iterateCausalGroup(tag)) {
|
|
81
|
-
if (node.atom.value.type === AuxOpType.Value &&
|
|
82
|
-
isEqual(node.atom.value.value, value)) {
|
|
83
|
-
return node;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Finds the node and index at which the given edit should happen at.
|
|
90
|
-
* Useful for applying edits to a causal tree.
|
|
91
|
-
* @param value The value node.
|
|
92
|
-
* @param version The last timestamps that were available when the edit was made.
|
|
93
|
-
* @param index The index at which the edit should happen.
|
|
94
|
-
* @param deleteCount The number of characters that get deleted starting at the index.
|
|
95
|
-
*/
|
|
96
|
-
export function findEditPosition(value, version, index, deleteCount) {
|
|
97
|
-
if (value.atom.value.type !== AuxOpType.Value) {
|
|
98
|
-
throw new Error('Invalid Argument. The weave node must be a value node.');
|
|
99
|
-
}
|
|
100
|
-
const children = [value, ...iterateCausalGroup(value)];
|
|
101
|
-
const filtered = children.filter((c) => {
|
|
102
|
-
const timestamp = version[c.atom.id.site] || -1;
|
|
103
|
-
return c.atom.id.timestamp <= timestamp;
|
|
104
|
-
});
|
|
105
|
-
const edits = calculateOrderedEdits(filtered);
|
|
106
|
-
if (edits.length <= 0 && typeof deleteCount === 'undefined') {
|
|
107
|
-
return {
|
|
108
|
-
index: 0,
|
|
109
|
-
node: value,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (typeof deleteCount === 'number') {
|
|
113
|
-
return [
|
|
114
|
-
...findMultipleEditPositions(index, deleteCount, edits, 'right'),
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return findSingleEditPosition(index, edits);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Finds the list of edit positions that an edit at the given index and the given delete count should cover.
|
|
123
|
-
* @param index The index.
|
|
124
|
-
* @param deleteCount The delete count.
|
|
125
|
-
* @param edits The text segments.
|
|
126
|
-
* @param afinity Whether edits that fall directly between two segments should be associated with the left edit or the right edit.
|
|
127
|
-
*/
|
|
128
|
-
export function* findMultipleEditPositions(index, deleteCount, edits, afinity) {
|
|
129
|
-
let count = 0;
|
|
130
|
-
let remaining = deleteCount;
|
|
131
|
-
for (let edit of edits) {
|
|
132
|
-
let reachedStart = afinity === 'left'
|
|
133
|
-
? count + edit.text.length >= index
|
|
134
|
-
: count + edit.text.length > index;
|
|
135
|
-
if (reachedStart) {
|
|
136
|
-
const relativeIndex = Math.abs(count - index);
|
|
137
|
-
const countUntilEnd = edit.text.length - relativeIndex;
|
|
138
|
-
// TODO: Reconcile the relative index of the edit text and
|
|
139
|
-
// the index that is needed inside the marked text.
|
|
140
|
-
let relativeIndexOffset = 0;
|
|
141
|
-
for (let i = 0, b = 0; i < relativeIndex && b < edit.marked.length;) {
|
|
142
|
-
let normalChar = edit.text[i];
|
|
143
|
-
let markedChar = edit.marked[b];
|
|
144
|
-
if (normalChar === markedChar) {
|
|
145
|
-
i += 1;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
relativeIndexOffset += 1;
|
|
149
|
-
}
|
|
150
|
-
b += 1;
|
|
151
|
-
}
|
|
152
|
-
const finalOffset = relativeIndex + relativeIndexOffset;
|
|
153
|
-
const nodeDeleteCount = Math.min(countUntilEnd, remaining);
|
|
154
|
-
const textAfter = edit.marked.slice(finalOffset, edit.marked.length);
|
|
155
|
-
let removedCharacterCount = 0;
|
|
156
|
-
let deleteCountOffset = 0;
|
|
157
|
-
let afterIndex = 0;
|
|
158
|
-
// Count all the deleted characters immediately after
|
|
159
|
-
// the insert/delete point
|
|
160
|
-
for (; afterIndex < textAfter.length; afterIndex++) {
|
|
161
|
-
if (textAfter[afterIndex] === '\0') {
|
|
162
|
-
removedCharacterCount += 1;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// Count all the deleted characters between the start point and end points
|
|
169
|
-
let extraCharactersIndex = 0;
|
|
170
|
-
for (; afterIndex < textAfter.length; afterIndex++) {
|
|
171
|
-
if (extraCharactersIndex >= nodeDeleteCount) {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
if (textAfter[afterIndex] === '\0') {
|
|
175
|
-
deleteCountOffset += 1;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
extraCharactersIndex += 1;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
yield {
|
|
182
|
-
index: finalOffset + removedCharacterCount + edit.offset,
|
|
183
|
-
count: nodeDeleteCount + deleteCountOffset,
|
|
184
|
-
node: edit.node,
|
|
185
|
-
};
|
|
186
|
-
remaining -= nodeDeleteCount;
|
|
187
|
-
count += relativeIndex;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
count += edit.text.length;
|
|
191
|
-
}
|
|
192
|
-
if (remaining <= 0) {
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Finds the single position that an edit at the given index should be added at.
|
|
199
|
-
* @param index The index.
|
|
200
|
-
* @param edits The edits.
|
|
201
|
-
*/
|
|
202
|
-
export function findSingleEditPosition(index, edits) {
|
|
203
|
-
return first(findMultipleEditPositions(index, 1, edits, 'left'));
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Calculates the list of ordered edits for the given value node.
|
|
207
|
-
* This iterates each insert op and delete op and returns a list of text segments that have been derived from the value.
|
|
208
|
-
* @param nodes The list of nodes that the edits should be calculated from.
|
|
209
|
-
* @param preserveEmptyEdits Whether to preserve empty edits in the output list.
|
|
210
|
-
*/
|
|
211
|
-
export function calculateOrderedEdits(nodes, preserveEmptyEdits = false) {
|
|
212
|
-
let segments = [];
|
|
213
|
-
for (let node of nodes) {
|
|
214
|
-
const atomValue = node.atom.value;
|
|
215
|
-
if (atomValue.type === AuxOpType.Value) {
|
|
216
|
-
let text = convertToString(atomValue.value);
|
|
217
|
-
let segment = {
|
|
218
|
-
text: text,
|
|
219
|
-
node: node,
|
|
220
|
-
offset: 0,
|
|
221
|
-
totalLength: atomValue.value.length,
|
|
222
|
-
};
|
|
223
|
-
segments.push(segment);
|
|
224
|
-
}
|
|
225
|
-
else if (atomValue.type === AuxOpType.Insert) {
|
|
226
|
-
const segment = {
|
|
227
|
-
text: atomValue.text,
|
|
228
|
-
node: node,
|
|
229
|
-
offset: 0,
|
|
230
|
-
totalLength: atomValue.text.length,
|
|
231
|
-
};
|
|
232
|
-
let count = 0;
|
|
233
|
-
let lastCausalGroupIndex = 0;
|
|
234
|
-
let isInCausalGroup = false;
|
|
235
|
-
let lastCauseTime = -1;
|
|
236
|
-
let added = false;
|
|
237
|
-
for (let i = 0; i < segments.length; i++) {
|
|
238
|
-
const lastSegment = segments[i];
|
|
239
|
-
if (!idEquals(lastSegment.node.atom.id, node.atom.cause)) {
|
|
240
|
-
if (isInCausalGroup) {
|
|
241
|
-
// We know that we are outside the last causal group
|
|
242
|
-
// because every child/grandchild of the cause must have a timestamp
|
|
243
|
-
// higher than the cause timestamp.
|
|
244
|
-
// So if we run across a segment with a timestamp less than the cause time
|
|
245
|
-
// then we are outside the causal group.
|
|
246
|
-
if (lastSegment.node.atom.id.timestamp < lastCauseTime) {
|
|
247
|
-
isInCausalGroup = false;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
// if we are still in the causal group, then we can count the current
|
|
251
|
-
// index as the last causal group point.
|
|
252
|
-
lastCausalGroupIndex = i;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
isInCausalGroup = true;
|
|
258
|
-
lastCauseTime = lastSegment.node.atom.id.timestamp;
|
|
259
|
-
lastCausalGroupIndex = i;
|
|
260
|
-
if (atomValue.index <= 0) {
|
|
261
|
-
segments.splice(i, 0, segment);
|
|
262
|
-
added = true;
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
else if (atomValue.index - count < +lastSegment.text.length) {
|
|
266
|
-
const first = {
|
|
267
|
-
text: lastSegment.text.slice(0, atomValue.index - count),
|
|
268
|
-
node: lastSegment.node,
|
|
269
|
-
offset: lastSegment.offset + 0,
|
|
270
|
-
totalLength: lastSegment.totalLength,
|
|
271
|
-
};
|
|
272
|
-
const second = {
|
|
273
|
-
text: lastSegment.text.slice(atomValue.index - count),
|
|
274
|
-
offset: lastSegment.offset + (atomValue.index - count),
|
|
275
|
-
node: lastSegment.node,
|
|
276
|
-
totalLength: lastSegment.totalLength,
|
|
277
|
-
};
|
|
278
|
-
segments.splice(i, 1, first, segment, second);
|
|
279
|
-
added = true;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
count += lastSegment.text.length;
|
|
283
|
-
}
|
|
284
|
-
if (!added) {
|
|
285
|
-
segments.splice(lastCausalGroupIndex + 1, 0, segment);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
else if (atomValue.type === AuxOpType.Delete) {
|
|
289
|
-
let lastSegment = segments.find((s) => idEquals(s.node.atom.id, node.atom.cause));
|
|
290
|
-
if (lastSegment) {
|
|
291
|
-
for (let i = atomValue.start; i < atomValue.end; i++) {
|
|
292
|
-
lastSegment.text = splice(lastSegment.text, i, 1, '\0');
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return segments
|
|
298
|
-
.map((s) => ({
|
|
299
|
-
text: s.text.replace(/\0/g, ''),
|
|
300
|
-
marked: s.text,
|
|
301
|
-
offset: s.offset,
|
|
302
|
-
node: s.node,
|
|
303
|
-
}))
|
|
304
|
-
.filter((s) => preserveEmptyEdits || s.text.length > 0);
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Calculates the final text value for the given value node.
|
|
308
|
-
* @param weave The weave.
|
|
309
|
-
* @param value The value node.
|
|
310
|
-
*/
|
|
311
|
-
export function calculateFinalEditValue(value) {
|
|
312
|
-
const children = [value, ...iterateCausalGroup(value)];
|
|
313
|
-
const edits = calculateOrderedEdits(children);
|
|
314
|
-
return edits.map((e) => e.text).join('');
|
|
315
|
-
}
|
|
316
|
-
// /**
|
|
317
|
-
// * Adds the given atom to the weave.
|
|
318
|
-
// * Returns the new site status, weave result, atom that was added, and status update.
|
|
319
|
-
// * @param weave The weave.
|
|
320
|
-
// * @param site The site.
|
|
321
|
-
// * @param atom The atom.
|
|
322
|
-
// */
|
|
323
|
-
// export function addAuxAtom<T extends AuxOp>(
|
|
324
|
-
// weave: Weave<T>,
|
|
325
|
-
// site: SiteStatus,
|
|
326
|
-
// atom: Atom<T>
|
|
327
|
-
// ) {
|
|
328
|
-
// const info = addAtom(weave, site, atom);
|
|
329
|
-
// const update = reducer(weave, info.result);
|
|
330
|
-
// return {
|
|
331
|
-
// ...info,
|
|
332
|
-
// update,
|
|
333
|
-
// };
|
|
334
|
-
// }
|
|
335
|
-
//# sourceMappingURL=AuxWeaveHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuxWeaveHelpers.js","sourceRoot":"","sources":["AuxWeaveHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,GAQZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAGH,kBAAkB,EAIlB,KAAK,EAEL,QAAQ,GAIX,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAY,MAAM,yBAAyB,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAmB,EAAE,EAAU;IACvD,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,SAAS,CAAC,CAAC,YAAY,CACzB,KAAmB,EACnB,EAAU;IAEV,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;QAC1B,IACI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,GAAG;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAC3B;YACE,MAAM,SAAS,GAAG,KAAK,CAAC,kB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/core2';
|
|
2
|
-
import { AuxOp, DeleteOp } from './AuxOpTypes';
|
|
3
|
-
import { PartialBotsState } from '../bots/Bot';
|
|
4
|
-
import { TextSegment } from './AuxWeaveHelpers';
|
|
5
|
-
export declare const CERT_ID_NAMESPACE = "a1307e2b-8d80-4945-9792-2cd483c45e24";
|
|
6
|
-
export declare const CERTIFIED_SPACE = "certified";
|
|
7
|
-
/**
|
|
8
|
-
* Calculates the state update needed for the given weave result from the given weave.
|
|
9
|
-
* @param weave The weave.
|
|
10
|
-
* @param result The result from the weave.
|
|
11
|
-
* @param state The object that the updates should be stored in. Use this when batching updates to reduce intermediate object allocations.
|
|
12
|
-
* @param space The space that new bots should use.
|
|
13
|
-
* @param initial Whether this is the initial update for the weave. Used to skip expensive inserts/deletes during the first load.
|
|
14
|
-
*/
|
|
15
|
-
export default function reducer(weave: Weave<AuxOp>, result: WeaveResult, state?: PartialBotsState, space?: string, initial?: boolean): PartialBotsState;
|
|
16
|
-
/**
|
|
17
|
-
* Finds all of the points that should be deleted for the given delete op and text segments.
|
|
18
|
-
* @param edits The edits.
|
|
19
|
-
* @param atom The delete atom.
|
|
20
|
-
* @param value The delete op.
|
|
21
|
-
*/
|
|
22
|
-
export declare function findDeletePoints(edits: TextSegment[], atom: Atom<DeleteOp>, value: DeleteOp): Generator<{
|
|
23
|
-
count: number;
|
|
24
|
-
length: number;
|
|
25
|
-
}, void, unknown>;
|
|
26
|
-
/**
|
|
27
|
-
* Gets the weave nodes needed for a text edit.
|
|
28
|
-
* Returns the bot node, tag node, and value/insert nodes.
|
|
29
|
-
*/
|
|
30
|
-
export declare function getTextEditNodes(weave: Weave<AuxOp>, atom: Atom<AuxOp>): {
|
|
31
|
-
tag: WeaveNode<AuxOp>;
|
|
32
|
-
bot: WeaveNode<AuxOp>;
|
|
33
|
-
value: WeaveNode<AuxOp>;
|
|
34
|
-
values: WeaveNode<AuxOp>[];
|
|
35
|
-
};
|
|
36
|
-
export declare function certificateId(atom: Atom<any>): string;
|
|
37
|
-
//# sourceMappingURL=AuxWeaveReducer.d.ts.map
|