mistagent 0.1.0 → 0.1.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.js +0 -0
- package/dist/src/components/LoginPrompt.d.ts.map +1 -1
- package/dist/src/components/LoginPrompt.js +28 -6
- package/dist/src/components/LoginPrompt.js.map +1 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +14 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/utils/constants.d.ts +2 -1
- package/dist/src/utils/constants.d.ts.map +1 -1
- package/dist/src/utils/constants.js +3 -1
- package/dist/src/utils/constants.js.map +1 -1
- package/dist/src/utils/updateChecker.d.ts +9 -0
- package/dist/src/utils/updateChecker.d.ts.map +1 -0
- package/dist/src/utils/updateChecker.js +47 -0
- package/dist/src/utils/updateChecker.js.map +1 -0
- package/package.json +3 -2
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
- package/dist/src/components/MultiLineInput.d.ts +0 -19
- package/dist/src/components/MultiLineInput.d.ts.map +0 -1
- package/dist/src/components/MultiLineInput.js +0 -108
- package/dist/src/components/MultiLineInput.js.map +0 -1
- package/dist/src/contexts/PasteContext.d.ts +0 -8
- package/dist/src/contexts/PasteContext.d.ts.map +0 -1
- package/dist/src/contexts/PasteContext.js +0 -12
- package/dist/src/contexts/PasteContext.js.map +0 -1
- package/dist/src/hooks/useMultiLineInput.d.ts +0 -37
- package/dist/src/hooks/useMultiLineInput.d.ts.map +0 -1
- package/dist/src/hooks/useMultiLineInput.js +0 -202
- package/dist/src/hooks/useMultiLineInput.js.map +0 -1
- package/dist/src/utils/pasteTransform.d.ts +0 -37
- package/dist/src/utils/pasteTransform.d.ts.map +0 -1
- package/dist/src/utils/pasteTransform.js +0 -161
- package/dist/src/utils/pasteTransform.js.map +0 -1
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graphology Leiden Utils
|
|
3
|
+
* ========================
|
|
4
|
+
*
|
|
5
|
+
* Miscellaneous utilities used by the Leiden algorithm.
|
|
6
|
+
*
|
|
7
|
+
* Vendored from: https://github.com/graphology/graphology/tree/master/src/communities-leiden
|
|
8
|
+
* License: MIT
|
|
9
|
+
*/
|
|
10
|
+
var SparseMap = require('mnemonist/sparse-map');
|
|
11
|
+
var createRandom = require('pandemonium/random').createRandom;
|
|
12
|
+
|
|
13
|
+
function addWeightToCommunity(map, community, weight) {
|
|
14
|
+
var currentWeight = map.get(community);
|
|
15
|
+
|
|
16
|
+
if (typeof currentWeight === 'undefined') currentWeight = 0;
|
|
17
|
+
|
|
18
|
+
currentWeight += weight;
|
|
19
|
+
|
|
20
|
+
map.set(community, currentWeight);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function UndirectedLeidenAddenda(index, options) {
|
|
24
|
+
options = options || {};
|
|
25
|
+
|
|
26
|
+
var rng = options.rng || Math.random;
|
|
27
|
+
var randomness = 'randomness' in options ? options.randomness : 0.01;
|
|
28
|
+
|
|
29
|
+
this.index = index;
|
|
30
|
+
this.random = createRandom(rng);
|
|
31
|
+
this.randomness = randomness;
|
|
32
|
+
this.rng = rng;
|
|
33
|
+
|
|
34
|
+
var NodesPointerArray = index.counts.constructor;
|
|
35
|
+
var WeightsArray = index.weights.constructor;
|
|
36
|
+
|
|
37
|
+
var order = index.C;
|
|
38
|
+
this.resolution = index.resolution;
|
|
39
|
+
|
|
40
|
+
// Used to group nodes by communities
|
|
41
|
+
this.B = index.C;
|
|
42
|
+
this.C = 0;
|
|
43
|
+
this.communitiesOffsets = new NodesPointerArray(order);
|
|
44
|
+
this.nodesSortedByCommunities = new NodesPointerArray(order);
|
|
45
|
+
this.communitiesBounds = new NodesPointerArray(order + 1);
|
|
46
|
+
|
|
47
|
+
// Used to merge nodes subsets
|
|
48
|
+
this.communityWeights = new WeightsArray(order);
|
|
49
|
+
this.degrees = new WeightsArray(order);
|
|
50
|
+
this.nonSingleton = new Uint8Array(order);
|
|
51
|
+
this.externalEdgeWeightPerCommunity = new WeightsArray(order);
|
|
52
|
+
this.belongings = new NodesPointerArray(order);
|
|
53
|
+
this.neighboringCommunities = new SparseMap(WeightsArray, order);
|
|
54
|
+
this.cumulativeIncrement = new Float64Array(order);
|
|
55
|
+
this.macroCommunities = null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
UndirectedLeidenAddenda.prototype.groupByCommunities = function () {
|
|
59
|
+
var index = this.index;
|
|
60
|
+
|
|
61
|
+
var n, i, c, b, o;
|
|
62
|
+
|
|
63
|
+
n = 0;
|
|
64
|
+
o = 0;
|
|
65
|
+
|
|
66
|
+
for (i = 0; i < index.C; i++) {
|
|
67
|
+
c = index.counts[i];
|
|
68
|
+
|
|
69
|
+
if (c !== 0) {
|
|
70
|
+
this.communitiesBounds[o++] = n;
|
|
71
|
+
n += c;
|
|
72
|
+
this.communitiesOffsets[i] = n;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.communitiesBounds[o] = n;
|
|
77
|
+
|
|
78
|
+
o = 0;
|
|
79
|
+
|
|
80
|
+
for (i = 0; i < index.C; i++) {
|
|
81
|
+
b = index.belongings[i];
|
|
82
|
+
o = --this.communitiesOffsets[b];
|
|
83
|
+
this.nodesSortedByCommunities[o] = i;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.B = index.C - index.U;
|
|
87
|
+
this.C = index.C;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
UndirectedLeidenAddenda.prototype.communities = function () {
|
|
91
|
+
var communities = new Array(this.B);
|
|
92
|
+
|
|
93
|
+
var i, j, community, start, stop;
|
|
94
|
+
|
|
95
|
+
for (i = 0; i < this.B; i++) {
|
|
96
|
+
start = this.communitiesBounds[i];
|
|
97
|
+
stop = this.communitiesBounds[i + 1];
|
|
98
|
+
community = [];
|
|
99
|
+
|
|
100
|
+
for (j = start; j < stop; j++) {
|
|
101
|
+
community.push(j);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
communities[i] = community;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return communities;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
UndirectedLeidenAddenda.prototype.mergeNodesSubset = function (start, stop) {
|
|
111
|
+
var index = this.index;
|
|
112
|
+
var currentMacroCommunity =
|
|
113
|
+
index.belongings[this.nodesSortedByCommunities[start]];
|
|
114
|
+
var neighboringCommunities = this.neighboringCommunities;
|
|
115
|
+
|
|
116
|
+
var totalNodeWeight = 0;
|
|
117
|
+
|
|
118
|
+
var i, j, w;
|
|
119
|
+
var ei, el, et;
|
|
120
|
+
|
|
121
|
+
// Initializing singletons
|
|
122
|
+
for (j = start; j < stop; j++) {
|
|
123
|
+
i = this.nodesSortedByCommunities[j];
|
|
124
|
+
|
|
125
|
+
this.belongings[i] = i;
|
|
126
|
+
this.nonSingleton[i] = 0;
|
|
127
|
+
this.degrees[i] = 0;
|
|
128
|
+
totalNodeWeight += index.loops[i] / 2;
|
|
129
|
+
|
|
130
|
+
this.communityWeights[i] = index.loops[i];
|
|
131
|
+
this.externalEdgeWeightPerCommunity[i] = 0;
|
|
132
|
+
|
|
133
|
+
ei = index.starts[i];
|
|
134
|
+
el = index.starts[i + 1];
|
|
135
|
+
|
|
136
|
+
for (; ei < el; ei++) {
|
|
137
|
+
et = index.neighborhood[ei];
|
|
138
|
+
w = index.weights[ei];
|
|
139
|
+
|
|
140
|
+
this.degrees[i] += w;
|
|
141
|
+
|
|
142
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
143
|
+
|
|
144
|
+
totalNodeWeight += w;
|
|
145
|
+
this.externalEdgeWeightPerCommunity[i] += w;
|
|
146
|
+
this.communityWeights[i] += w;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var microDegrees = this.externalEdgeWeightPerCommunity.slice();
|
|
151
|
+
|
|
152
|
+
var s, ri, ci;
|
|
153
|
+
var order = stop - start;
|
|
154
|
+
|
|
155
|
+
var degree,
|
|
156
|
+
bestCommunity,
|
|
157
|
+
qualityValueIncrement,
|
|
158
|
+
maxQualityValueIncrement,
|
|
159
|
+
totalTransformedQualityValueIncrement,
|
|
160
|
+
targetCommunity,
|
|
161
|
+
targetCommunityDegree,
|
|
162
|
+
targetCommunityWeight;
|
|
163
|
+
|
|
164
|
+
var r, lo, hi, mid, chosenCommunity;
|
|
165
|
+
|
|
166
|
+
ri = this.random(start, stop - 1);
|
|
167
|
+
|
|
168
|
+
for (s = start; s < stop; s++, ri++) {
|
|
169
|
+
j = start + (ri % order);
|
|
170
|
+
|
|
171
|
+
i = this.nodesSortedByCommunities[j];
|
|
172
|
+
|
|
173
|
+
if (this.nonSingleton[i] === 1) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (
|
|
178
|
+
this.externalEdgeWeightPerCommunity[i] <
|
|
179
|
+
this.communityWeights[i] *
|
|
180
|
+
(totalNodeWeight / 2 - this.communityWeights[i]) *
|
|
181
|
+
this.resolution
|
|
182
|
+
) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.communityWeights[i] = 0;
|
|
187
|
+
this.externalEdgeWeightPerCommunity[i] = 0;
|
|
188
|
+
|
|
189
|
+
neighboringCommunities.clear();
|
|
190
|
+
neighboringCommunities.set(i, 0);
|
|
191
|
+
|
|
192
|
+
degree = 0;
|
|
193
|
+
|
|
194
|
+
ei = index.starts[i];
|
|
195
|
+
el = index.starts[i + 1];
|
|
196
|
+
|
|
197
|
+
for (; ei < el; ei++) {
|
|
198
|
+
et = index.neighborhood[ei];
|
|
199
|
+
|
|
200
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
201
|
+
|
|
202
|
+
w = index.weights[ei];
|
|
203
|
+
|
|
204
|
+
degree += w;
|
|
205
|
+
|
|
206
|
+
addWeightToCommunity(neighboringCommunities, this.belongings[et], w);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
bestCommunity = i;
|
|
210
|
+
maxQualityValueIncrement = 0;
|
|
211
|
+
totalTransformedQualityValueIncrement = 0;
|
|
212
|
+
|
|
213
|
+
for (ci = 0; ci < neighboringCommunities.size; ci++) {
|
|
214
|
+
targetCommunity = neighboringCommunities.dense[ci];
|
|
215
|
+
targetCommunityDegree = neighboringCommunities.vals[ci];
|
|
216
|
+
targetCommunityWeight = this.communityWeights[targetCommunity];
|
|
217
|
+
|
|
218
|
+
if (
|
|
219
|
+
this.externalEdgeWeightPerCommunity[targetCommunity] >=
|
|
220
|
+
targetCommunityWeight *
|
|
221
|
+
(totalNodeWeight / 2 - targetCommunityWeight) *
|
|
222
|
+
this.resolution
|
|
223
|
+
) {
|
|
224
|
+
qualityValueIncrement =
|
|
225
|
+
targetCommunityDegree -
|
|
226
|
+
((degree + index.loops[i]) *
|
|
227
|
+
targetCommunityWeight *
|
|
228
|
+
this.resolution) /
|
|
229
|
+
totalNodeWeight;
|
|
230
|
+
|
|
231
|
+
if (qualityValueIncrement > maxQualityValueIncrement) {
|
|
232
|
+
bestCommunity = targetCommunity;
|
|
233
|
+
maxQualityValueIncrement = qualityValueIncrement;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (qualityValueIncrement >= 0)
|
|
237
|
+
totalTransformedQualityValueIncrement += Math.exp(
|
|
238
|
+
qualityValueIncrement / this.randomness
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this.cumulativeIncrement[ci] = totalTransformedQualityValueIncrement;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (
|
|
246
|
+
totalTransformedQualityValueIncrement < Number.MAX_VALUE &&
|
|
247
|
+
totalTransformedQualityValueIncrement < Infinity
|
|
248
|
+
) {
|
|
249
|
+
r = totalTransformedQualityValueIncrement * this.rng();
|
|
250
|
+
lo = -1;
|
|
251
|
+
hi = neighboringCommunities.size + 1;
|
|
252
|
+
|
|
253
|
+
while (lo < hi - 1) {
|
|
254
|
+
mid = (lo + hi) >>> 1;
|
|
255
|
+
|
|
256
|
+
if (this.cumulativeIncrement[mid] >= r) hi = mid;
|
|
257
|
+
else lo = mid;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
chosenCommunity = neighboringCommunities.dense[hi];
|
|
261
|
+
} else {
|
|
262
|
+
chosenCommunity = bestCommunity;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.communityWeights[chosenCommunity] += degree + index.loops[i];
|
|
266
|
+
|
|
267
|
+
ei = index.starts[i];
|
|
268
|
+
el = index.starts[i + 1];
|
|
269
|
+
|
|
270
|
+
for (; ei < el; ei++) {
|
|
271
|
+
et = index.neighborhood[ei];
|
|
272
|
+
|
|
273
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
274
|
+
|
|
275
|
+
targetCommunity = this.belongings[et];
|
|
276
|
+
|
|
277
|
+
if (targetCommunity === chosenCommunity) {
|
|
278
|
+
this.externalEdgeWeightPerCommunity[chosenCommunity] -=
|
|
279
|
+
microDegrees[et];
|
|
280
|
+
} else {
|
|
281
|
+
this.externalEdgeWeightPerCommunity[chosenCommunity] +=
|
|
282
|
+
microDegrees[et];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (chosenCommunity !== i) {
|
|
287
|
+
this.belongings[i] = chosenCommunity;
|
|
288
|
+
this.nonSingleton[chosenCommunity] = 1;
|
|
289
|
+
this.C--;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var microCommunities = this.neighboringCommunities;
|
|
294
|
+
microCommunities.clear();
|
|
295
|
+
|
|
296
|
+
for (j = start; j < stop; j++) {
|
|
297
|
+
i = this.nodesSortedByCommunities[j];
|
|
298
|
+
microCommunities.set(this.belongings[i], 1);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return microCommunities.dense.slice(0, microCommunities.size);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
UndirectedLeidenAddenda.prototype.refinePartition = function () {
|
|
305
|
+
this.groupByCommunities();
|
|
306
|
+
|
|
307
|
+
this.macroCommunities = new Array(this.B);
|
|
308
|
+
|
|
309
|
+
var i, start, stop, mapping;
|
|
310
|
+
|
|
311
|
+
var bounds = this.communitiesBounds;
|
|
312
|
+
|
|
313
|
+
for (i = 0; i < this.B; i++) {
|
|
314
|
+
start = bounds[i];
|
|
315
|
+
stop = bounds[i + 1];
|
|
316
|
+
|
|
317
|
+
mapping = this.mergeNodesSubset(start, stop);
|
|
318
|
+
this.macroCommunities[i] = mapping;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
UndirectedLeidenAddenda.prototype.split = function () {
|
|
323
|
+
var index = this.index;
|
|
324
|
+
var isolates = this.neighboringCommunities;
|
|
325
|
+
|
|
326
|
+
isolates.clear();
|
|
327
|
+
|
|
328
|
+
var i, community, isolated;
|
|
329
|
+
|
|
330
|
+
for (i = 0; i < index.C; i++) {
|
|
331
|
+
community = this.belongings[i];
|
|
332
|
+
|
|
333
|
+
if (i !== community) continue;
|
|
334
|
+
|
|
335
|
+
isolated = index.isolate(i, this.degrees[i]);
|
|
336
|
+
isolates.set(community, isolated);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
for (i = 0; i < index.C; i++) {
|
|
340
|
+
community = this.belongings[i];
|
|
341
|
+
|
|
342
|
+
if (i === community) continue;
|
|
343
|
+
|
|
344
|
+
isolated = isolates.get(community);
|
|
345
|
+
index.move(i, this.degrees[i], isolated);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
var j, macro;
|
|
349
|
+
|
|
350
|
+
for (i = 0; i < this.macroCommunities.length; i++) {
|
|
351
|
+
macro = this.macroCommunities[i];
|
|
352
|
+
|
|
353
|
+
for (j = 0; j < macro.length; j++) macro[j] = isolates.get(macro[j]);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
UndirectedLeidenAddenda.prototype.zoomOut = function () {
|
|
358
|
+
var index = this.index;
|
|
359
|
+
this.refinePartition();
|
|
360
|
+
this.split();
|
|
361
|
+
|
|
362
|
+
var newLabels = index.zoomOut();
|
|
363
|
+
|
|
364
|
+
var macro, leader, follower;
|
|
365
|
+
|
|
366
|
+
var i, j;
|
|
367
|
+
|
|
368
|
+
for (i = 0; i < this.macroCommunities.length; i++) {
|
|
369
|
+
macro = this.macroCommunities[i];
|
|
370
|
+
leader = newLabels[macro[0]];
|
|
371
|
+
|
|
372
|
+
for (j = 1; j < macro.length; j++) {
|
|
373
|
+
follower = newLabels[macro[j]];
|
|
374
|
+
index.expensiveMove(follower, leader);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
UndirectedLeidenAddenda.prototype.onlySingletons = function () {
|
|
380
|
+
var index = this.index;
|
|
381
|
+
|
|
382
|
+
var i;
|
|
383
|
+
|
|
384
|
+
for (i = 0; i < index.C; i++) {
|
|
385
|
+
if (index.counts[i] > 1) return false;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return true;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
exports.addWeightToCommunity = addWeightToCommunity;
|
|
392
|
+
exports.UndirectedLeidenAddenda = UndirectedLeidenAddenda;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
interface MultiLineInputProps {
|
|
2
|
-
value: string;
|
|
3
|
-
onChange: (value: string) => void;
|
|
4
|
-
onSubmit: (value: string) => void;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
focus?: boolean;
|
|
7
|
-
showCursor?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Multi-line text input for Ink.
|
|
11
|
-
*
|
|
12
|
-
* - Enter → submit
|
|
13
|
-
* - Shift+Enter → insert newline (requires kitty keyboard protocol)
|
|
14
|
-
* - Alt+Enter → insert newline (fallback for legacy terminals)
|
|
15
|
-
* - Backspace / Delete / Left / Right work across lines
|
|
16
|
-
*/
|
|
17
|
-
declare function MultiLineInput({ value: originalValue, placeholder, focus, showCursor, onChange, onSubmit, }: MultiLineInputProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export default MultiLineInput;
|
|
19
|
-
//# sourceMappingURL=MultiLineInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MultiLineInput.d.ts","sourceRoot":"","sources":["../../../src/components/MultiLineInput.tsx"],"names":[],"mappings":"AAIA,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,iBAAS,cAAc,CAAC,EACtB,KAAK,EAAE,aAAa,EACpB,WAAgB,EAChB,KAAY,EACZ,UAAiB,EACjB,QAAQ,EACR,QAAQ,GACT,EAAE,mBAAmB,2CAuHrB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect, useRef } from 'react';
|
|
3
|
-
import { Box, Text, useInput } from 'ink';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
/**
|
|
6
|
-
* Multi-line text input for Ink.
|
|
7
|
-
*
|
|
8
|
-
* - Enter → submit
|
|
9
|
-
* - Shift+Enter → insert newline (requires kitty keyboard protocol)
|
|
10
|
-
* - Alt+Enter → insert newline (fallback for legacy terminals)
|
|
11
|
-
* - Backspace / Delete / Left / Right work across lines
|
|
12
|
-
*/
|
|
13
|
-
function MultiLineInput({ value: originalValue, placeholder = '', focus = true, showCursor = true, onChange, onSubmit, }) {
|
|
14
|
-
const [cursorOffset, setCursorOffset] = useState(originalValue.length);
|
|
15
|
-
// Keep cursor within bounds when value changes externally
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
setCursorOffset((prev) => Math.min(prev, originalValue.length));
|
|
18
|
-
}, [originalValue]);
|
|
19
|
-
// Ref so useInput always reads the latest cursor
|
|
20
|
-
const cursorRef = useRef(cursorOffset);
|
|
21
|
-
cursorRef.current = cursorOffset;
|
|
22
|
-
const valueRef = useRef(originalValue);
|
|
23
|
-
valueRef.current = originalValue;
|
|
24
|
-
useInput((input, key) => {
|
|
25
|
-
// Ignore keys handled by Composer (arrows, Ctrl+C, Tab)
|
|
26
|
-
if (key.upArrow || key.downArrow || (key.ctrl && input === 'c') || key.tab || (key.shift && key.tab)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const val = valueRef.current;
|
|
30
|
-
const cur = cursorRef.current;
|
|
31
|
-
// --- newline insertion: Shift+Enter or Alt+Enter ---
|
|
32
|
-
if (key.return && (key.shift || key.meta)) {
|
|
33
|
-
const next = val.slice(0, cur) + '\n' + val.slice(cur);
|
|
34
|
-
setCursorOffset(cur + 1);
|
|
35
|
-
onChange(next);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
// --- plain Enter → submit ---
|
|
39
|
-
if (key.return) {
|
|
40
|
-
onSubmit(val);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
let nextCursor = cur;
|
|
44
|
-
let nextValue = val;
|
|
45
|
-
if (key.leftArrow) {
|
|
46
|
-
if (showCursor)
|
|
47
|
-
nextCursor = Math.max(0, cur - 1);
|
|
48
|
-
}
|
|
49
|
-
else if (key.rightArrow) {
|
|
50
|
-
if (showCursor)
|
|
51
|
-
nextCursor = Math.min(val.length, cur + 1);
|
|
52
|
-
}
|
|
53
|
-
else if (key.backspace || key.delete) {
|
|
54
|
-
if (cur > 0) {
|
|
55
|
-
nextValue = val.slice(0, cur - 1) + val.slice(cur);
|
|
56
|
-
nextCursor = cur - 1;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else if (input) {
|
|
60
|
-
nextValue = val.slice(0, cur) + input + val.slice(cur);
|
|
61
|
-
nextCursor = cur + input.length;
|
|
62
|
-
}
|
|
63
|
-
nextCursor = Math.max(0, Math.min(nextCursor, nextValue.length));
|
|
64
|
-
setCursorOffset(nextCursor);
|
|
65
|
-
if (nextValue !== val) {
|
|
66
|
-
onChange(nextValue);
|
|
67
|
-
}
|
|
68
|
-
}, { isActive: focus });
|
|
69
|
-
// ── Rendering ──
|
|
70
|
-
if (!originalValue && placeholder) {
|
|
71
|
-
if (showCursor && focus) {
|
|
72
|
-
return (_jsx(Text, { children: placeholder.length > 0
|
|
73
|
-
? chalk.inverse(placeholder[0]) + chalk.grey(placeholder.slice(1))
|
|
74
|
-
: chalk.inverse(' ') }));
|
|
75
|
-
}
|
|
76
|
-
return _jsx(Text, { children: chalk.grey(placeholder) });
|
|
77
|
-
}
|
|
78
|
-
const lines = originalValue.split('\n');
|
|
79
|
-
const renderedLines = [];
|
|
80
|
-
let charsSoFar = 0;
|
|
81
|
-
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
82
|
-
const line = lines[lineIdx];
|
|
83
|
-
let rendered = '';
|
|
84
|
-
if (showCursor && focus) {
|
|
85
|
-
for (let i = 0; i < line.length; i++) {
|
|
86
|
-
const globalPos = charsSoFar + i;
|
|
87
|
-
rendered += globalPos === cursorOffset ? chalk.inverse(line[i]) : line[i];
|
|
88
|
-
}
|
|
89
|
-
// Cursor at end of line
|
|
90
|
-
const endPos = charsSoFar + line.length;
|
|
91
|
-
if (cursorOffset === endPos) {
|
|
92
|
-
rendered += chalk.inverse(' ');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
rendered = line;
|
|
97
|
-
}
|
|
98
|
-
renderedLines.push(rendered);
|
|
99
|
-
charsSoFar += line.length + 1; // +1 for the '\n'
|
|
100
|
-
}
|
|
101
|
-
// Multi-line: render each line in its own <Text> within a vertical <Box>
|
|
102
|
-
if (lines.length > 1) {
|
|
103
|
-
return (_jsx(Box, { flexDirection: "column", children: renderedLines.map((line, i) => (_jsx(Text, { children: line || ' ' }, i))) }));
|
|
104
|
-
}
|
|
105
|
-
return _jsx(Text, { children: renderedLines[0] });
|
|
106
|
-
}
|
|
107
|
-
export default MultiLineInput;
|
|
108
|
-
//# sourceMappingURL=MultiLineInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MultiLineInput.js","sourceRoot":"","sources":["../../../src/components/MultiLineInput.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAe,MAAM,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,EACtB,KAAK,EAAE,aAAa,EACpB,WAAW,GAAG,EAAE,EAChB,KAAK,GAAG,IAAI,EACZ,UAAU,GAAG,IAAI,EACjB,QAAQ,EACR,QAAQ,GACY;IACpB,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAEvE,0DAA0D;IAC1D,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,iDAAiD;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC;IAEjC,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACvC,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC;I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;IACzE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CACL,KAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,YACxB,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC9B,KAAC,IAAI,cAAU,IAAI,IAAI,GAAG,IAAf,CAAC,CAAsB,CACnC,CAAC,GACE,CACP,CAAC;IACJ,CAAC;IAED,OAAO,KAAC,IAAI,cAAE,aAAa,CAAC,CAAC,CAAC,GAAQ,CAAC;AACzC,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { PasteTransform } from '../utils/pasteTransform.js';
|
|
3
|
-
export declare const PasteProvider: React.FC<{
|
|
4
|
-
value: PasteTransform;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function usePasteTransform(): PasteTransform;
|
|
8
|
-
//# sourceMappingURL=PasteContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PasteContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/PasteContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAEA,CAAC;AAEF,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
3
|
-
const PasteContext = createContext(null);
|
|
4
|
-
export const PasteProvider = ({ value, children }) => (_jsx(PasteContext.Provider, { value: value, children: children }));
|
|
5
|
-
export function usePasteTransform() {
|
|
6
|
-
const ctx = useContext(PasteContext);
|
|
7
|
-
if (!ctx) {
|
|
8
|
-
throw new Error('usePasteTransform must be used within a PasteProvider');
|
|
9
|
-
}
|
|
10
|
-
return ctx;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=PasteContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PasteContext.js","sourceRoot":"","sources":["../../../src/contexts/PasteContext.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGzD,MAAM,YAAY,GAAG,aAAa,CAAwB,IAAI,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,aAAa,GAGrB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC5B,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAyB,CACxE,CAAC;AAEF,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface CursorPos {
|
|
2
|
-
row: number;
|
|
3
|
-
col: number;
|
|
4
|
-
}
|
|
5
|
-
export interface MultiLineBuffer {
|
|
6
|
-
/** The full text (with \n for newlines) */
|
|
7
|
-
text: string;
|
|
8
|
-
/** Split into lines */
|
|
9
|
-
lines: string[];
|
|
10
|
-
/** Current cursor position [row, col] */
|
|
11
|
-
cursor: CursorPos;
|
|
12
|
-
/** Insert text at cursor */
|
|
13
|
-
insert: (ch: string) => void;
|
|
14
|
-
/** Insert a newline at cursor */
|
|
15
|
-
newline: () => void;
|
|
16
|
-
/** Delete character before cursor */
|
|
17
|
-
backspace: () => void;
|
|
18
|
-
/** Delete character at cursor */
|
|
19
|
-
del: () => void;
|
|
20
|
-
/** Move cursor */
|
|
21
|
-
moveLeft: () => void;
|
|
22
|
-
moveRight: () => void;
|
|
23
|
-
moveUp: () => void;
|
|
24
|
-
moveDown: () => void;
|
|
25
|
-
moveHome: () => void;
|
|
26
|
-
moveEnd: () => void;
|
|
27
|
-
/** Replace the entire text */
|
|
28
|
-
setText: (text: string) => void;
|
|
29
|
-
/** Clear all text */
|
|
30
|
-
clear: () => void;
|
|
31
|
-
/** Atomic: delete char before cursor then insert newline (for backslash+Enter) */
|
|
32
|
-
backspaceAndNewline: () => void;
|
|
33
|
-
}
|
|
34
|
-
/** Get the absolute text offset for a cursor position. */
|
|
35
|
-
export declare function getTextOffset(lines: string[], cursor: CursorPos): number;
|
|
36
|
-
export declare function useMultiLineInput(initialText?: string): MultiLineBuffer;
|
|
37
|
-
//# sourceMappingURL=useMultiLineInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMultiLineInput.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMultiLineInput.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yCAAyC;IACzC,MAAM,EAAE,SAAS,CAAC;IAClB,4BAA4B;IAC5B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,iCAAiC;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qCAAqC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,iCAAiC;IACjC,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,kBAAkB;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,qBAAqB;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kFAAkF;IAClF,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAqCD,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAOxE;AAwKD,wBAAgB,iBAAiB,CAAC,WAAW,SAAK,GAAG,eAAe,CAuCnE"}
|