@graphprotocol/grc-20 0.2.0 → 0.2.2
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/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/src/core/account.js +2 -2
- package/dist/src/core/account.js.map +1 -1
- package/dist/src/core/base58.test.js +1 -1
- package/dist/src/core/base58.test.js.map +1 -1
- package/dist/src/core/blocks/data.js +2 -2
- package/dist/src/core/blocks/data.js.map +1 -1
- package/dist/src/core/blocks/text.js +2 -2
- package/dist/src/core/blocks/text.js.map +1 -1
- package/dist/src/core/image.js +2 -2
- package/dist/src/core/image.js.map +1 -1
- package/dist/src/core/relation.d.ts +4 -4
- package/dist/src/core/relation.d.ts.map +1 -1
- package/dist/src/core/relation.js +2 -2
- package/dist/src/core/relation.js.map +1 -1
- package/dist/src/core/triple.d.ts +4 -4
- package/dist/src/core/triple.d.ts.map +1 -1
- package/dist/src/id.d.ts +2 -2
- package/dist/src/id.d.ts.map +1 -1
- package/dist/src/id.js +3 -3
- package/dist/src/id.js.map +1 -1
- package/dist/src/id.test.js +2 -2
- package/dist/src/id.test.js.map +1 -1
- package/dist/src/ipfs.d.ts +34 -0
- package/dist/src/ipfs.d.ts.map +1 -0
- package/dist/src/ipfs.js +59 -0
- package/dist/src/ipfs.js.map +1 -0
- package/dist/src/proto/edit.d.ts +3 -3
- package/dist/src/proto/edit.d.ts.map +1 -1
- package/dist/src/proto/edit.js +2 -2
- package/dist/src/proto/edit.js.map +1 -1
- package/package.json +11 -10
- package/dist/error.d.ts +0 -2
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -8
- package/dist/error.js.map +0 -1
- package/dist/example.d.ts +0 -2
- package/dist/example.d.ts.map +0 -1
- package/dist/example.js +0 -27
- package/dist/example.js.map +0 -1
- package/dist/run.d.ts +0 -2
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -4
- package/dist/run.js.map +0 -1
- package/dist/src/base58.d.ts +0 -36
- package/dist/src/base58.d.ts.map +0 -1
- package/dist/src/base58.js +0 -62
- package/dist/src/base58.js.map +0 -1
- package/dist/src/base58.test.d.ts +0 -2
- package/dist/src/base58.test.d.ts.map +0 -1
- package/dist/src/base58.test.js +0 -2
- package/dist/src/base58.test.js.map +0 -1
- package/dist/src/core/ids/generate.d.ts +0 -2
- package/dist/src/core/ids/generate.d.ts.map +0 -1
- package/dist/src/core/ids/generate.js +0 -4
- package/dist/src/core/ids/generate.js.map +0 -1
- package/dist/src/core/position-strings/cursors.d.ts +0 -56
- package/dist/src/core/position-strings/cursors.d.ts.map +0 -1
- package/dist/src/core/position-strings/cursors.js +0 -69
- package/dist/src/core/position-strings/cursors.js.map +0 -1
- package/dist/src/core/position-strings/find-position.d.ts +0 -24
- package/dist/src/core/position-strings/find-position.d.ts.map +0 -1
- package/dist/src/core/position-strings/find-position.js +0 -38
- package/dist/src/core/position-strings/find-position.js.map +0 -1
- package/dist/src/core/position-strings/ids.d.ts +0 -37
- package/dist/src/core/position-strings/ids.d.ts.map +0 -1
- package/dist/src/core/position-strings/ids.js +0 -79
- package/dist/src/core/position-strings/ids.js.map +0 -1
- package/dist/src/core/position-strings/index.d.ts +0 -5
- package/dist/src/core/position-strings/index.d.ts.map +0 -1
- package/dist/src/core/position-strings/index.js +0 -6
- package/dist/src/core/position-strings/index.js.map +0 -1
- package/dist/src/core/position-strings/position-source.d.ts +0 -128
- package/dist/src/core/position-strings/position-source.d.ts.map +0 -1
- package/dist/src/core/position-strings/position-source.js +0 -314
- package/dist/src/core/position-strings/position-source.js.map +0 -1
- package/dist/src/core/position-strings/test/cursors.test.d.ts +0 -2
- package/dist/src/core/position-strings/test/cursors.test.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/cursors.test.js +0 -104
- package/dist/src/core/position-strings/test/cursors.test.js.map +0 -1
- package/dist/src/core/position-strings/test/find-position.test.d.ts +0 -2
- package/dist/src/core/position-strings/test/find-position.test.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/find-position.test.js +0 -48
- package/dist/src/core/position-strings/test/find-position.test.js.map +0 -1
- package/dist/src/core/position-strings/test/fuzz.test.d.ts +0 -2
- package/dist/src/core/position-strings/test/fuzz.test.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/fuzz.test.js +0 -78
- package/dist/src/core/position-strings/test/fuzz.test.js.map +0 -1
- package/dist/src/core/position-strings/test/ids.test.d.ts +0 -2
- package/dist/src/core/position-strings/test/ids.test.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/ids.test.js +0 -17
- package/dist/src/core/position-strings/test/ids.test.js.map +0 -1
- package/dist/src/core/position-strings/test/manual.test.d.ts +0 -2
- package/dist/src/core/position-strings/test/manual.test.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/manual.test.js +0 -307
- package/dist/src/core/position-strings/test/manual.test.js.map +0 -1
- package/dist/src/core/position-strings/test/util.d.ts +0 -6
- package/dist/src/core/position-strings/test/util.d.ts.map +0 -1
- package/dist/src/core/position-strings/test/util.js +0 -26
- package/dist/src/core/position-strings/test/util.js.map +0 -1
- package/dist/src/core/position-strings/util.d.ts +0 -8
- package/dist/src/core/position-strings/util.d.ts.map +0 -1
- package/dist/src/core/position-strings/util.js +0 -26
- package/dist/src/core/position-strings/util.js.map +0 -1
- package/dist/src/proto/create-edit-proposal.d.ts +0 -9
- package/dist/src/proto/create-edit-proposal.d.ts.map +0 -1
- package/dist/src/proto/create-edit-proposal.js +0 -54
- package/dist/src/proto/create-edit-proposal.js.map +0 -1
- package/dist/src/proto/create-edit-proposal.test.d.ts +0 -2
- package/dist/src/proto/create-edit-proposal.test.d.ts.map +0 -1
- package/dist/src/proto/create-edit-proposal.test.js +0 -140
- package/dist/src/proto/create-edit-proposal.test.js.map +0 -1
- package/dist/src/proto/create-membership-proposal.d.ts +0 -7
- package/dist/src/proto/create-membership-proposal.d.ts.map +0 -1
- package/dist/src/proto/create-membership-proposal.js +0 -26
- package/dist/src/proto/create-membership-proposal.js.map +0 -1
- package/dist/src/proto/create-subspace-proposal.d.ts +0 -7
- package/dist/src/proto/create-subspace-proposal.d.ts.map +0 -1
- package/dist/src/proto/create-subspace-proposal.js +0 -12
- package/dist/src/proto/create-subspace-proposal.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { IDs } from './ids.js';
|
|
2
|
-
import { LastInternal, assert, precond } from './util.js';
|
|
3
|
-
/**
|
|
4
|
-
* A source of lexicographically-ordered "position strings" for
|
|
5
|
-
* collaborative lists and text.
|
|
6
|
-
*
|
|
7
|
-
* In a collaborative list (or text string), you need a way to refer
|
|
8
|
-
* to "positions" within that list that:
|
|
9
|
-
* 1. Point to a specific list element (or text character).
|
|
10
|
-
* 2. Are global (all users agree on them) and immutable (they do not
|
|
11
|
-
* change over time).
|
|
12
|
-
* 3. Can be sorted.
|
|
13
|
-
* 4. Are unique, even if different users concurrently create positions
|
|
14
|
-
* at the same place.
|
|
15
|
-
*
|
|
16
|
-
* `PositionSource` gives you such positions, in the form
|
|
17
|
-
* of lexicographically-ordered strings. Specifically, `createBetween`
|
|
18
|
-
* returns a new "position string" in between two existing position strings.
|
|
19
|
-
*
|
|
20
|
-
* These strings have the bonus properties:
|
|
21
|
-
* - 5. (Non-Interleaving) If two `PositionSource`s concurrently create a (forward or backward)
|
|
22
|
-
* sequence of positions at the same place,
|
|
23
|
-
* their sequences will not be interleaved.
|
|
24
|
-
* For example, if
|
|
25
|
-
* Alice types "Hello" while Bob types "World" at the same place,
|
|
26
|
-
* and they each use a `PositionSource` to create a position for each
|
|
27
|
-
* character, then
|
|
28
|
-
* the resulting order will be "HelloWorld" or "WorldHello", not
|
|
29
|
-
* "HWeolrllod".
|
|
30
|
-
* - 6. If a `PositionSource` creates positions in a forward (increasing)
|
|
31
|
-
* sequence, their lengths as strings will only grow logarithmically,
|
|
32
|
-
* not linearly.
|
|
33
|
-
*
|
|
34
|
-
* Position strings are printable ASCII. Specifically, they
|
|
35
|
-
* contain alphanumeric characters, `','`, and `'.'`.
|
|
36
|
-
* Also, the special string `PositionSource.LAST` is `'~'`.
|
|
37
|
-
*
|
|
38
|
-
* Further reading:
|
|
39
|
-
* - [Fractional indexing](https://www.figma.com/blog/realtime-editing-of-ordered-sequences/#fractional-indexing),
|
|
40
|
-
* a related scheme that satisfies 1-3 but not 4-6.
|
|
41
|
-
* - [List CRDTs](https://mattweidner.com/2022/10/21/basic-list-crdt.html)
|
|
42
|
-
* and how they map to position strings. `PositionSource` uses an optimized
|
|
43
|
-
* variant of that link's string implementation.
|
|
44
|
-
* - [Paper about interleaving](https://www.repository.cam.ac.uk/handle/1810/290391)
|
|
45
|
-
* in collaborative text editors.
|
|
46
|
-
*/
|
|
47
|
-
export class PositionSource {
|
|
48
|
-
/**
|
|
49
|
-
* A string that is less than all positions.
|
|
50
|
-
*
|
|
51
|
-
* Value: `""`.
|
|
52
|
-
*/
|
|
53
|
-
static FIRST = '';
|
|
54
|
-
/**
|
|
55
|
-
* A string that is greater than all positions.
|
|
56
|
-
*
|
|
57
|
-
* Value: `"~"`.
|
|
58
|
-
*/
|
|
59
|
-
static LAST = LastInternal;
|
|
60
|
-
/**
|
|
61
|
-
* The unique ID for this `PositionSource`.
|
|
62
|
-
*/
|
|
63
|
-
ID;
|
|
64
|
-
/**
|
|
65
|
-
* Our waypoints' long name: `,${ID}.`.
|
|
66
|
-
*/
|
|
67
|
-
longName;
|
|
68
|
-
/**
|
|
69
|
-
* Variant of longName used for a position's first ID: `${ID}.`.
|
|
70
|
-
* (Otherwise every position would start with a redundant ','.)
|
|
71
|
-
*/
|
|
72
|
-
firstName;
|
|
73
|
-
/**
|
|
74
|
-
* For each waypoint that we created, maps a prefix (see getPrefix)
|
|
75
|
-
* for that waypoint to its last (most recent) valueSeq.
|
|
76
|
-
* We always store the right-side version (odd valueSeq).
|
|
77
|
-
*/
|
|
78
|
-
lastValueSeqs = new Map();
|
|
79
|
-
/**
|
|
80
|
-
* Constructs a new `PositionSource`.
|
|
81
|
-
*
|
|
82
|
-
* It is okay to share a single `PositionSource` between
|
|
83
|
-
* all documents (lists/text strings) in the same JavaScript runtime.
|
|
84
|
-
*
|
|
85
|
-
* For efficiency (shorter position strings),
|
|
86
|
-
* within each JavaScript runtime, you should not use
|
|
87
|
-
* more than one `PositionSource` for the same document.
|
|
88
|
-
* An exception is if multiple logical users share the same runtime;
|
|
89
|
-
* we then recommend one `PositionSource` per user.
|
|
90
|
-
*
|
|
91
|
-
* @param options.ID A unique ID for this `PositionSource`. Defaults to
|
|
92
|
-
* `IDs.random()`.
|
|
93
|
-
*
|
|
94
|
-
* If provided, `options.ID` must satisfy:
|
|
95
|
-
* - It is unique across the entire collaborative application, i.e.,
|
|
96
|
-
* all `PositionSource`s whose positions may be compared to ours. This
|
|
97
|
-
* includes past `PositionSource`s, even if they correspond to the same
|
|
98
|
-
* user/device.
|
|
99
|
-
* - It does not contain `','` or `'.'`.
|
|
100
|
-
* - The first character is lexicographically less than `'~'` (code point 126).
|
|
101
|
-
*
|
|
102
|
-
* If `options.ID` contains non-alphanumeric characters, then created
|
|
103
|
-
* positions will contain those characters in addition to
|
|
104
|
-
* alphanumeric characters, `','`, and `'.'`.
|
|
105
|
-
*/
|
|
106
|
-
constructor(options) {
|
|
107
|
-
if (options?.ID !== undefined) {
|
|
108
|
-
IDs.validate(options.ID);
|
|
109
|
-
}
|
|
110
|
-
this.ID = options?.ID ?? IDs.random();
|
|
111
|
-
this.longName = `,${this.ID}.`;
|
|
112
|
-
this.firstName = `${this.ID}.`;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Returns a new position between `left` and `right`
|
|
116
|
-
* (`left < new < right`).
|
|
117
|
-
*
|
|
118
|
-
* The new position is unique across the entire collaborative application,
|
|
119
|
-
* even in the face of concurrent calls to this method on other
|
|
120
|
-
* `PositionSource`s.
|
|
121
|
-
*
|
|
122
|
-
* @param left Defaults to `PositionSource.FIRST` (insert at the beginning).
|
|
123
|
-
*
|
|
124
|
-
* @param right Defaults to `PositionSource.LAST` (insert at the end).
|
|
125
|
-
*/
|
|
126
|
-
createBetween(left = PositionSource.FIRST, right = PositionSource.LAST) {
|
|
127
|
-
precond(left < right, 'left must be less than right:', left, '!<', right);
|
|
128
|
-
precond(right <= PositionSource.LAST, 'right must be less than or equal to LAST:', right, '!<=', PositionSource.LAST);
|
|
129
|
-
const leftFixed = left === PositionSource.FIRST ? null : left;
|
|
130
|
-
const rightFixed = right === PositionSource.LAST ? null : right;
|
|
131
|
-
let ans;
|
|
132
|
-
if (rightFixed !== null && (leftFixed === null || rightFixed.startsWith(leftFixed))) {
|
|
133
|
-
// Left child of right. This always appends a waypoint.
|
|
134
|
-
const ancestor = leftVersion(rightFixed);
|
|
135
|
-
ans = this.appendWaypoint(ancestor);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Right child of left.
|
|
139
|
-
if (leftFixed === null) {
|
|
140
|
-
// ancestor is FIRST.
|
|
141
|
-
ans = this.appendWaypoint('');
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
// Check if we can reuse left's prefix.
|
|
145
|
-
// It needs to be one of ours, and right can't use the same
|
|
146
|
-
// prefix (otherwise we would get ans > right by comparing right's
|
|
147
|
-
// older valueIndex to our new valueIndex).
|
|
148
|
-
const prefix = getPrefix(leftFixed);
|
|
149
|
-
const lastValueSeq = this.lastValueSeqs.get(prefix);
|
|
150
|
-
if (lastValueSeq !== undefined && !(rightFixed !== null && rightFixed.startsWith(prefix))) {
|
|
151
|
-
// Reuse.
|
|
152
|
-
const valueSeq = nextOddValueSeq(lastValueSeq);
|
|
153
|
-
ans = prefix + stringifyBase52(valueSeq);
|
|
154
|
-
this.lastValueSeqs.set(prefix, valueSeq);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
// Append waypoint.
|
|
158
|
-
ans = this.appendWaypoint(leftFixed);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
assert(left < ans && ans < right, 'Bad position:', left, ans, right);
|
|
163
|
-
return ans;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Appends a wayoint to the given ancestor (= prefix adjusted for
|
|
167
|
-
* side), returning a unique new position using that waypoint.
|
|
168
|
-
*
|
|
169
|
-
* lastValueSeqs is also updated as needed for the waypoint.
|
|
170
|
-
*/
|
|
171
|
-
appendWaypoint(ancestor) {
|
|
172
|
-
let waypointName = ancestor === '' ? this.firstName : this.longName;
|
|
173
|
-
// If our ID already appears in ancestor, instead use a short
|
|
174
|
-
// name for the waypoint.
|
|
175
|
-
// Here we use the uniqueness of ',' and '.' to
|
|
176
|
-
// claim that if this.longName (= `,${ID}.`) appears in ancestor, then it
|
|
177
|
-
// must actually be from a waypoint that we created.
|
|
178
|
-
let existing = ancestor.lastIndexOf(this.longName);
|
|
179
|
-
if (ancestor.startsWith(this.firstName))
|
|
180
|
-
existing = 0;
|
|
181
|
-
if (existing !== -1) {
|
|
182
|
-
// Find the index of existing among the long-name
|
|
183
|
-
// waypoints, in backwards order. Here we use the fact that
|
|
184
|
-
// each longName ends with '.' and that '.' does not appear otherwise.
|
|
185
|
-
let index = -1;
|
|
186
|
-
for (let i = existing; i < ancestor.length; i++) {
|
|
187
|
-
if (ancestor[i] === '.')
|
|
188
|
-
index++;
|
|
189
|
-
}
|
|
190
|
-
waypointName = stringifyShortName(index);
|
|
191
|
-
}
|
|
192
|
-
const prefix = ancestor + waypointName;
|
|
193
|
-
const lastValueSeq = this.lastValueSeqs.get(prefix);
|
|
194
|
-
// Use next odd (right-side) valueSeq (1 if it's a new waypoint).
|
|
195
|
-
const valueSeq = lastValueSeq === undefined ? 1 : nextOddValueSeq(lastValueSeq);
|
|
196
|
-
this.lastValueSeqs.set(prefix, valueSeq);
|
|
197
|
-
return prefix + stringifyBase52(valueSeq);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Returns position's *prefix*: the string through the last waypoint
|
|
202
|
-
* name, or equivalently, without the final valueSeq.
|
|
203
|
-
*/
|
|
204
|
-
function getPrefix(position) {
|
|
205
|
-
// Last waypoint char is the last '.' (for long names) or
|
|
206
|
-
// digit (for short names). Note that neither appear in valueSeq,
|
|
207
|
-
// which is all letters.
|
|
208
|
-
for (let i = position.length - 2; i >= 0; i--) {
|
|
209
|
-
const char = position[i];
|
|
210
|
-
if (char === '.' || ('0' <= char && char <= '9')) {
|
|
211
|
-
// i is the last waypoint char, i.e., the end of the prefix.
|
|
212
|
-
return position.slice(0, i + 1);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
assert(false, 'No last waypoint char found (not a position?)', position);
|
|
216
|
-
return '';
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Returns the variant of position ending with a "left" marker
|
|
220
|
-
* instead of the default "right" marker.
|
|
221
|
-
*
|
|
222
|
-
* I.e., the ancestor for position's left descendants.
|
|
223
|
-
*/
|
|
224
|
-
function leftVersion(position) {
|
|
225
|
-
// We need to subtract one from the (odd) valueSeq, equivalently, from
|
|
226
|
-
// its last base52 digit.
|
|
227
|
-
const last = parseBase52(position[position.length - 1]);
|
|
228
|
-
assert(last % 2 === 1, 'Bad valueSeq (not a position?)', last, position);
|
|
229
|
-
return position.slice(0, -1) + stringifyBase52(last - 1);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Base 52, except for last digit, which is base 10 using
|
|
233
|
-
* digits. That makes it easy to find the end of a short name
|
|
234
|
-
* in getPrefix: it ends at the last digit.
|
|
235
|
-
*/
|
|
236
|
-
function stringifyShortName(n) {
|
|
237
|
-
if (n < 10)
|
|
238
|
-
return String.fromCharCode(48 + n);
|
|
239
|
-
else
|
|
240
|
-
return stringifyBase52(Math.floor(n / 10)) + String.fromCharCode(48 + (n % 10));
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Base 52 encoding using letters (with "digits" in order by code point).
|
|
244
|
-
*/
|
|
245
|
-
function stringifyBase52(n) {
|
|
246
|
-
if (n === 0)
|
|
247
|
-
return 'A';
|
|
248
|
-
const codes = [];
|
|
249
|
-
while (n > 0) {
|
|
250
|
-
const digit = n % 52;
|
|
251
|
-
codes.unshift((digit >= 26 ? 71 : 65) + digit);
|
|
252
|
-
n = Math.floor(n / 52);
|
|
253
|
-
}
|
|
254
|
-
return String.fromCharCode(...codes);
|
|
255
|
-
}
|
|
256
|
-
function parseBase52(s) {
|
|
257
|
-
let n = 0;
|
|
258
|
-
for (let i = 0; i < s.length; i++) {
|
|
259
|
-
const code = s.charCodeAt(i);
|
|
260
|
-
const digit = code - (code >= 97 ? 71 : 65);
|
|
261
|
-
n = 52 * n + digit;
|
|
262
|
-
}
|
|
263
|
-
return n;
|
|
264
|
-
}
|
|
265
|
-
const log52 = Math.log(52);
|
|
266
|
-
/**
|
|
267
|
-
* Returns the next odd valueSeq in the special sequence.
|
|
268
|
-
* This is equivalent to mapping n to its valueIndex, adding 2,
|
|
269
|
-
* then mapping back.
|
|
270
|
-
*
|
|
271
|
-
* The sequence has the following properties:
|
|
272
|
-
* 1. Each number is a nonnegative integer (however, not all
|
|
273
|
-
* nonnegative integers are enumerated).
|
|
274
|
-
* 2. The numbers' base-52 representations are enumerated in
|
|
275
|
-
* lexicographic order, with no prefixes (i.e., no string
|
|
276
|
-
* representation is a prefix of another).
|
|
277
|
-
* 3. The n-th enumerated number has O(log(n)) base-52 digits.
|
|
278
|
-
*
|
|
279
|
-
* Properties (2) and (3) are analogous to normal counting, except
|
|
280
|
-
* that we order by the (base-52) lexicographic order instead of the
|
|
281
|
-
* usual order by magnitude. It is also the case that
|
|
282
|
-
* the numbers are in order by magnitude, although we do not
|
|
283
|
-
* use this property.
|
|
284
|
-
*
|
|
285
|
-
* The specific sequence is as follows:
|
|
286
|
-
* - Start with 0.
|
|
287
|
-
* - Enumerate 26^1 numbers (A, B, ..., Z).
|
|
288
|
-
* - Add 1, multiply by 52, then enumerate 26^2 numbers
|
|
289
|
-
* (aA, aB, ..., mz).
|
|
290
|
-
* - Add 1, multiply by 52, then enumerate 26^3 numbers
|
|
291
|
-
* (nAA, nAB, ..., tZz).
|
|
292
|
-
* - Repeat this pattern indefinitely, enumerating
|
|
293
|
-
* 26^d d-digit numbers for each d >= 1. Imagining a decimal place
|
|
294
|
-
* in front of each number, each d consumes 2^(-d) of the unit interval,
|
|
295
|
-
* so we never "reach 1" (overflow to d+1 digits when
|
|
296
|
-
* we meant to use d digits).
|
|
297
|
-
*
|
|
298
|
-
* I believe this is related to
|
|
299
|
-
* [Elias gamma coding](https://en.wikipedia.org/wiki/Elias_gamma_coding).
|
|
300
|
-
*/
|
|
301
|
-
function nextOddValueSeq(n) {
|
|
302
|
-
const d = n === 0 ? 1 : Math.floor(Math.log(n) / log52) + 1;
|
|
303
|
-
// You can calculate that the last d-digit number is 52^d - 26^d - 1.
|
|
304
|
-
if (n === Math.pow(52, d) - Math.pow(26, d) - 1) {
|
|
305
|
-
// First step is a new length: n -> (n + 1) * 52.
|
|
306
|
-
// Second step is n -> n + 1.
|
|
307
|
-
return (n + 1) * 52 + 1;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
// n -> n + 1 twice.
|
|
311
|
-
return n + 2;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
//# sourceMappingURL=position-source.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position-source.js","sourceRoot":"","sources":["../../../../src/core/position-strings/position-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAU,KAAK,GAAW,EAAE,CAAC;IACnC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K,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5D,qEAAqE;IACrE,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,iDAAiD;QACjD,6BAA6B;QAC7B,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,oBAAoB;QACpB,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursors.test.d.ts","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/cursors.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
import seedrandom from "seedrandom";
|
|
3
|
-
import { Cursors, IDs, PositionSource } from "../src";
|
|
4
|
-
describe("Cursors", () => {
|
|
5
|
-
let rng;
|
|
6
|
-
let source;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
rng = seedrandom("42");
|
|
9
|
-
source = new PositionSource({ ID: IDs.pseudoRandom(rng) });
|
|
10
|
-
});
|
|
11
|
-
function testLength(len) {
|
|
12
|
-
let list;
|
|
13
|
-
describe(`length ${len}`, () => {
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
list = [];
|
|
16
|
-
for (let i = 0; i < len; i++) {
|
|
17
|
-
list.push(source.createBetween(list.at(-1), undefined));
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
it("present", () => {
|
|
21
|
-
for (let i = 0; i <= list.length; i++) {
|
|
22
|
-
const cursor = Cursors.fromIndex(i, list);
|
|
23
|
-
assert.strictEqual(Cursors.toIndex(cursor, list), i);
|
|
24
|
-
if (i !== 0) {
|
|
25
|
-
// Insert a char in the next gap to the left, shifting the cursor.
|
|
26
|
-
const list2 = [
|
|
27
|
-
...list.slice(0, i - 1),
|
|
28
|
-
source.createBetween(list[i - 2], list[i - 1]),
|
|
29
|
-
...list.slice(i - 1),
|
|
30
|
-
];
|
|
31
|
-
assert.strictEqual(Cursors.toIndex(cursor, list2), i + 1);
|
|
32
|
-
}
|
|
33
|
-
if (i !== list.length) {
|
|
34
|
-
// Insert a char in the next gap to the right, which shouldn't shift the cursor.
|
|
35
|
-
const list3 = [
|
|
36
|
-
...list.slice(0, i + 1),
|
|
37
|
-
source.createBetween(list[i], list[i + 1]),
|
|
38
|
-
...list.slice(i),
|
|
39
|
-
];
|
|
40
|
-
assert.strictEqual(Cursors.toIndex(cursor, list3), i);
|
|
41
|
-
}
|
|
42
|
-
// Insert a char in the cursor's gap, which
|
|
43
|
-
// still shouldn't shift the cursor, since we
|
|
44
|
-
// bind to the left char.
|
|
45
|
-
const list4 = [
|
|
46
|
-
...list.slice(0, i),
|
|
47
|
-
source.createBetween(list[i - 1], list[i]),
|
|
48
|
-
...list.slice(i),
|
|
49
|
-
];
|
|
50
|
-
assert.strictEqual(Cursors.toIndex(cursor, list4), i);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
it("not present", () => {
|
|
54
|
-
for (let i = 0; i <= list.length; i++) {
|
|
55
|
-
// Set the cursor to a new position that we "delete"
|
|
56
|
-
// (actually just leave not-present) in list.
|
|
57
|
-
const listExtended = [
|
|
58
|
-
...list.slice(0, i),
|
|
59
|
-
source.createBetween(list[i - 1], list[i]),
|
|
60
|
-
...list.slice(i),
|
|
61
|
-
];
|
|
62
|
-
const cursor = Cursors.fromIndex(i + 1, listExtended);
|
|
63
|
-
// In list, the index falls back by 1 to i.
|
|
64
|
-
assert.strictEqual(Cursors.toIndex(cursor, list), i);
|
|
65
|
-
if (i !== 0) {
|
|
66
|
-
// Insert a char in the next gap to the left, shifting the cursor.
|
|
67
|
-
const list2 = [
|
|
68
|
-
...list.slice(0, i - 1),
|
|
69
|
-
source.createBetween(list[i - 2], list[i - 1]),
|
|
70
|
-
...list.slice(i - 1),
|
|
71
|
-
];
|
|
72
|
-
assert.strictEqual(Cursors.toIndex(cursor, list2), i + 1);
|
|
73
|
-
}
|
|
74
|
-
if (i !== list.length) {
|
|
75
|
-
// Insert a char in the next gap to the right, which shouldn't shift the cursor.
|
|
76
|
-
const list3 = [
|
|
77
|
-
...list.slice(0, i + 1),
|
|
78
|
-
source.createBetween(list[i], list[i + 1]),
|
|
79
|
-
...list.slice(i),
|
|
80
|
-
];
|
|
81
|
-
assert.strictEqual(Cursors.toIndex(cursor, list3), i);
|
|
82
|
-
}
|
|
83
|
-
// Insert a char in the cursor's gap, which
|
|
84
|
-
// may or may not shift the cursor, depending on how
|
|
85
|
-
// the new position compares to the cursor's.
|
|
86
|
-
const list4 = [
|
|
87
|
-
...list.slice(0, i),
|
|
88
|
-
source.createBetween(list[i - 1], list[i]),
|
|
89
|
-
...list.slice(i),
|
|
90
|
-
];
|
|
91
|
-
const index4 = Cursors.toIndex(cursor, list4);
|
|
92
|
-
assert(i <= index4 && index4 <= i + 1);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
testLength(32);
|
|
98
|
-
testLength(31);
|
|
99
|
-
testLength(33);
|
|
100
|
-
testLength(23);
|
|
101
|
-
testLength(1);
|
|
102
|
-
testLength(0);
|
|
103
|
-
});
|
|
104
|
-
//# sourceMappingURL=cursors.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursors.test.js","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/cursors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,QAAQ,C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AAC,EAAE,CAAC,GAAG,CAAC,CAAC;4BACvB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;4BAC1C,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;yBACjB,CAAC;wBACF,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;oBACxD,CAAC;oBACD,2CAA2C;oBAC3C,oDAAoD;oBACpD,6CAA6C;oBAC7C,MAAM,KAAK,GAAG;wBACZ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;wBACnB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;wBAC1C,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;qBACjB,CAAC;oBACF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC9C,MAAM,CAAC,CAAC,IAAI,MAAM,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,CAAC,CAAC,CAAC;IACd,UAAU,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-position.test.d.ts","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/find-position.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { assert } from 'chai';
|
|
2
|
-
import { beforeEach, describe, it } from 'vitest';
|
|
3
|
-
import { findPosition } from '../find-position.js';
|
|
4
|
-
import { IDs } from '../ids.js';
|
|
5
|
-
import { PositionSource } from '../position-source.js';
|
|
6
|
-
describe('findPosition', () => {
|
|
7
|
-
let source;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
source = new PositionSource({ ID: IDs.random() });
|
|
10
|
-
});
|
|
11
|
-
function testLength(len) {
|
|
12
|
-
let list;
|
|
13
|
-
describe(`length ${len}`, () => {
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
list = [];
|
|
16
|
-
for (let i = 0; i < len; i++) {
|
|
17
|
-
list.push(source.createBetween(list.at(-1), undefined));
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
it('present', () => {
|
|
21
|
-
for (let i = 0; i < list.length; i++) {
|
|
22
|
-
assert.deepStrictEqual(findPosition(list[i], list), {
|
|
23
|
-
index: i,
|
|
24
|
-
isPresent: true,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
it('not present', () => {
|
|
29
|
-
for (let i = 0; i <= list.length; i++) {
|
|
30
|
-
const newPos = source.createBetween(list[i - 1], list[i]);
|
|
31
|
-
// newPos would be at index i if present (between the current
|
|
32
|
-
// i - 1 & i).
|
|
33
|
-
assert.deepStrictEqual(findPosition(newPos, list), {
|
|
34
|
-
index: i,
|
|
35
|
-
isPresent: false,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
testLength(32);
|
|
42
|
-
testLength(31);
|
|
43
|
-
testLength(33);
|
|
44
|
-
testLength(23);
|
|
45
|
-
testLength(1);
|
|
46
|
-
testLength(0);
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=find-position.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-position.test.js","sourceRoot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E,CAAC;wBACR,SAAS,EAAE,IAAI;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;gBACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACtC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1D,6DAA6D;oBAC7D,cAAc;oBACd,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;wBACjD,KAAK,EAAE,CAAC;wBACR,SAAS,EAAE,KAAK;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,UAAU,CAAC,CAAC,CAAC,CAAC;IACd,UAAU,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fuzz.test.d.ts","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/fuzz.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import seedrandom from "seedrandom";
|
|
2
|
-
import { assertIsOrdered, newSources, testUniqueAfterDelete } from "./util";
|
|
3
|
-
describe("fuzz", () => {
|
|
4
|
-
describe("sequential", () => {
|
|
5
|
-
describe("1 user", () => sequential(1));
|
|
6
|
-
describe("10 users", () => sequential(10));
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
function sequential(numUsers) {
|
|
10
|
-
let rng;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
rng = seedrandom("42");
|
|
13
|
-
});
|
|
14
|
-
it("random", () => {
|
|
15
|
-
const sources = newSources(rng, numUsers);
|
|
16
|
-
// Randomly create positions in a single list, simulating sequential access.
|
|
17
|
-
const list = [];
|
|
18
|
-
for (let i = 0; i < 1000; i++) {
|
|
19
|
-
const source = sources[Math.floor(rng() * sources.length)];
|
|
20
|
-
const index = Math.floor(rng() * (list.length + 1));
|
|
21
|
-
// Out-of-bounds okay.
|
|
22
|
-
const newPosition = source.createBetween(list[index - 1], list[index]);
|
|
23
|
-
list.splice(index, 0, newPosition);
|
|
24
|
-
}
|
|
25
|
-
assertIsOrdered(list);
|
|
26
|
-
testUniqueAfterDelete(list, sources[0]);
|
|
27
|
-
});
|
|
28
|
-
it("random LtR runs", () => {
|
|
29
|
-
const sources = newSources(rng, numUsers);
|
|
30
|
-
// Randomly create positions in a single list, simulating sequential access.
|
|
31
|
-
// This time, create short LtR runs at a time.
|
|
32
|
-
const list = [];
|
|
33
|
-
for (let i = 0; i < 200; i++) {
|
|
34
|
-
const source = sources[Math.floor(rng() * sources.length)];
|
|
35
|
-
const index = Math.floor(rng() * (list.length + 1));
|
|
36
|
-
// Out-of-bounds okay.
|
|
37
|
-
for (let j = 0; j < 5; j++) {
|
|
38
|
-
const newPosition = source.createBetween(list[index - 1 + j], list[index + j]);
|
|
39
|
-
list.splice(index + j, 0, newPosition);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
assertIsOrdered(list);
|
|
43
|
-
testUniqueAfterDelete(list, sources[0]);
|
|
44
|
-
});
|
|
45
|
-
it("random RtL runs", () => {
|
|
46
|
-
const sources = newSources(rng, numUsers);
|
|
47
|
-
// Randomly create positions in a single list, simulating sequential access.
|
|
48
|
-
// This time, create short RtL runs at a time.
|
|
49
|
-
const list = [];
|
|
50
|
-
for (let i = 0; i < 200; i++) {
|
|
51
|
-
const source = sources[Math.floor(rng() * sources.length)];
|
|
52
|
-
const index = Math.floor(rng() * (list.length + 1));
|
|
53
|
-
// Out-of-bounds okay.
|
|
54
|
-
for (let j = 0; j < 5; j++) {
|
|
55
|
-
const newPosition = source.createBetween(list[index - 1], list[index]);
|
|
56
|
-
list.splice(index, 0, newPosition);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
assertIsOrdered(list);
|
|
60
|
-
testUniqueAfterDelete(list, sources[0]);
|
|
61
|
-
});
|
|
62
|
-
it("biased", () => {
|
|
63
|
-
const sources = newSources(rng, numUsers);
|
|
64
|
-
// Randomly create positions in a single list, simulating sequential access.
|
|
65
|
-
// This time, bias towards smaller indices using a sqrt.
|
|
66
|
-
const list = [];
|
|
67
|
-
for (let i = 0; i < 1000; i++) {
|
|
68
|
-
const source = sources[Math.floor(Math.sqrt(rng() * sources.length * sources.length))];
|
|
69
|
-
const index = Math.floor(rng() * (list.length + 1));
|
|
70
|
-
// Out-of-bounds okay.
|
|
71
|
-
const newPosition = source.createBetween(list[index - 1], list[index]);
|
|
72
|
-
list.splice(index, 0, newPosition);
|
|
73
|
-
}
|
|
74
|
-
assertIsOrdered(list);
|
|
75
|
-
testUniqueAfterDelete(list, sources[0]);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=fuzz.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fuzz.test.js","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/fuzz.test.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAE5E,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;Q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W,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;QACrC,CAAC;QAED,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ids.test.d.ts","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/ids.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
import { PositionSource } from "../src";
|
|
3
|
-
describe("IDs", () => {
|
|
4
|
-
describe("validate", () => {
|
|
5
|
-
it("rejects period", () => {
|
|
6
|
-
assert.throws(() => new PositionSource({ ID: "ali.ce" }));
|
|
7
|
-
});
|
|
8
|
-
it("rejects comma", () => {
|
|
9
|
-
assert.throws(() => new PositionSource({ ID: "ali,ce" }));
|
|
10
|
-
});
|
|
11
|
-
it("rejects LAST or greater", () => {
|
|
12
|
-
assert.throws(() => new PositionSource({ ID: PositionSource.LAST }));
|
|
13
|
-
assert.throws(() => new PositionSource({ ID: PositionSource.LAST + "alice" }));
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=ids.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ids.test.js","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/ids.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;IACnB,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;YACxB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACrE,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,IAAI,GAAG,OAAO,EAAE,CAAC,CAChE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manual.test.d.ts","sourceRoot":"","sources":["../../../../../src/core/position-strings/test/manual.test.ts"],"names":[],"mappings":""}
|