@opentui/core 0.1.83 → 0.1.84
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/3d.js +1 -1
- package/{index-a215gqtt.js → index-qr7b6cvh.js} +22 -4
- package/{index-a215gqtt.js.map → index-qr7b6cvh.js.map} +2 -2
- package/index.js +201 -644
- package/index.js.map +6 -15
- package/package.json +7 -7
- package/parser.worker.js +1 -1
- package/parser.worker.js.map +1 -1
- package/renderables/Markdown.d.ts +6 -2
- package/renderables/ScrollBox.d.ts +8 -1
- package/renderables/TextTable.d.ts +11 -1
- package/testing.js +1 -1
package/index.js
CHANGED
|
@@ -153,7 +153,7 @@ import {
|
|
|
153
153
|
white,
|
|
154
154
|
wrapWithDelegates,
|
|
155
155
|
yellow
|
|
156
|
-
} from "./index-
|
|
156
|
+
} from "./index-qr7b6cvh.js";
|
|
157
157
|
// src/text-buffer-view.ts
|
|
158
158
|
class TextBufferView {
|
|
159
159
|
lib;
|
|
@@ -4140,617 +4140,6 @@ class LineNumberRenderable extends Renderable {
|
|
|
4140
4140
|
}
|
|
4141
4141
|
}
|
|
4142
4142
|
}
|
|
4143
|
-
|
|
4144
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/base.js
|
|
4145
|
-
class Diff {
|
|
4146
|
-
diff(oldStr, newStr, options = {}) {
|
|
4147
|
-
let callback;
|
|
4148
|
-
if (typeof options === "function") {
|
|
4149
|
-
callback = options;
|
|
4150
|
-
options = {};
|
|
4151
|
-
} else if ("callback" in options) {
|
|
4152
|
-
callback = options.callback;
|
|
4153
|
-
}
|
|
4154
|
-
const oldString = this.castInput(oldStr, options);
|
|
4155
|
-
const newString = this.castInput(newStr, options);
|
|
4156
|
-
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
4157
|
-
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
4158
|
-
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
4159
|
-
}
|
|
4160
|
-
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
4161
|
-
var _a;
|
|
4162
|
-
const done = (value) => {
|
|
4163
|
-
value = this.postProcess(value, options);
|
|
4164
|
-
if (callback) {
|
|
4165
|
-
setTimeout(function() {
|
|
4166
|
-
callback(value);
|
|
4167
|
-
}, 0);
|
|
4168
|
-
return;
|
|
4169
|
-
} else {
|
|
4170
|
-
return value;
|
|
4171
|
-
}
|
|
4172
|
-
};
|
|
4173
|
-
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
4174
|
-
let editLength = 1;
|
|
4175
|
-
let maxEditLength = newLen + oldLen;
|
|
4176
|
-
if (options.maxEditLength != null) {
|
|
4177
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
4178
|
-
}
|
|
4179
|
-
const maxExecutionTime = (_a = options.timeout) !== null && _a !== undefined ? _a : Infinity;
|
|
4180
|
-
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
4181
|
-
const bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
4182
|
-
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
4183
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
4184
|
-
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
4185
|
-
}
|
|
4186
|
-
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
4187
|
-
const execEditLength = () => {
|
|
4188
|
-
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
4189
|
-
let basePath;
|
|
4190
|
-
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
4191
|
-
if (removePath) {
|
|
4192
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
4193
|
-
}
|
|
4194
|
-
let canAdd = false;
|
|
4195
|
-
if (addPath) {
|
|
4196
|
-
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
4197
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
4198
|
-
}
|
|
4199
|
-
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
4200
|
-
if (!canAdd && !canRemove) {
|
|
4201
|
-
bestPath[diagonalPath] = undefined;
|
|
4202
|
-
continue;
|
|
4203
|
-
}
|
|
4204
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
4205
|
-
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
4206
|
-
} else {
|
|
4207
|
-
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
4208
|
-
}
|
|
4209
|
-
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
4210
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
4211
|
-
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
4212
|
-
} else {
|
|
4213
|
-
bestPath[diagonalPath] = basePath;
|
|
4214
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
4215
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
4216
|
-
}
|
|
4217
|
-
if (newPos + 1 >= newLen) {
|
|
4218
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
4219
|
-
}
|
|
4220
|
-
}
|
|
4221
|
-
}
|
|
4222
|
-
editLength++;
|
|
4223
|
-
};
|
|
4224
|
-
if (callback) {
|
|
4225
|
-
(function exec() {
|
|
4226
|
-
setTimeout(function() {
|
|
4227
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
4228
|
-
return callback(undefined);
|
|
4229
|
-
}
|
|
4230
|
-
if (!execEditLength()) {
|
|
4231
|
-
exec();
|
|
4232
|
-
}
|
|
4233
|
-
}, 0);
|
|
4234
|
-
})();
|
|
4235
|
-
} else {
|
|
4236
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
4237
|
-
const ret = execEditLength();
|
|
4238
|
-
if (ret) {
|
|
4239
|
-
return ret;
|
|
4240
|
-
}
|
|
4241
|
-
}
|
|
4242
|
-
}
|
|
4243
|
-
}
|
|
4244
|
-
addToPath(path, added, removed, oldPosInc, options) {
|
|
4245
|
-
const last = path.lastComponent;
|
|
4246
|
-
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
4247
|
-
return {
|
|
4248
|
-
oldPos: path.oldPos + oldPosInc,
|
|
4249
|
-
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
4250
|
-
};
|
|
4251
|
-
} else {
|
|
4252
|
-
return {
|
|
4253
|
-
oldPos: path.oldPos + oldPosInc,
|
|
4254
|
-
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
4255
|
-
};
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
4259
|
-
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
4260
|
-
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
4261
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
4262
|
-
newPos++;
|
|
4263
|
-
oldPos++;
|
|
4264
|
-
commonCount++;
|
|
4265
|
-
if (options.oneChangePerToken) {
|
|
4266
|
-
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
4267
|
-
}
|
|
4268
|
-
}
|
|
4269
|
-
if (commonCount && !options.oneChangePerToken) {
|
|
4270
|
-
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
4271
|
-
}
|
|
4272
|
-
basePath.oldPos = oldPos;
|
|
4273
|
-
return newPos;
|
|
4274
|
-
}
|
|
4275
|
-
equals(left, right, options) {
|
|
4276
|
-
if (options.comparator) {
|
|
4277
|
-
return options.comparator(left, right);
|
|
4278
|
-
} else {
|
|
4279
|
-
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
4280
|
-
}
|
|
4281
|
-
}
|
|
4282
|
-
removeEmpty(array) {
|
|
4283
|
-
const ret = [];
|
|
4284
|
-
for (let i = 0;i < array.length; i++) {
|
|
4285
|
-
if (array[i]) {
|
|
4286
|
-
ret.push(array[i]);
|
|
4287
|
-
}
|
|
4288
|
-
}
|
|
4289
|
-
return ret;
|
|
4290
|
-
}
|
|
4291
|
-
castInput(value, options) {
|
|
4292
|
-
return value;
|
|
4293
|
-
}
|
|
4294
|
-
tokenize(value, options) {
|
|
4295
|
-
return Array.from(value);
|
|
4296
|
-
}
|
|
4297
|
-
join(chars) {
|
|
4298
|
-
return chars.join("");
|
|
4299
|
-
}
|
|
4300
|
-
postProcess(changeObjects, options) {
|
|
4301
|
-
return changeObjects;
|
|
4302
|
-
}
|
|
4303
|
-
get useLongestToken() {
|
|
4304
|
-
return false;
|
|
4305
|
-
}
|
|
4306
|
-
buildValues(lastComponent, newTokens, oldTokens) {
|
|
4307
|
-
const components = [];
|
|
4308
|
-
let nextComponent;
|
|
4309
|
-
while (lastComponent) {
|
|
4310
|
-
components.push(lastComponent);
|
|
4311
|
-
nextComponent = lastComponent.previousComponent;
|
|
4312
|
-
delete lastComponent.previousComponent;
|
|
4313
|
-
lastComponent = nextComponent;
|
|
4314
|
-
}
|
|
4315
|
-
components.reverse();
|
|
4316
|
-
const componentLen = components.length;
|
|
4317
|
-
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
4318
|
-
for (;componentPos < componentLen; componentPos++) {
|
|
4319
|
-
const component = components[componentPos];
|
|
4320
|
-
if (!component.removed) {
|
|
4321
|
-
if (!component.added && this.useLongestToken) {
|
|
4322
|
-
let value = newTokens.slice(newPos, newPos + component.count);
|
|
4323
|
-
value = value.map(function(value2, i) {
|
|
4324
|
-
const oldValue = oldTokens[oldPos + i];
|
|
4325
|
-
return oldValue.length > value2.length ? oldValue : value2;
|
|
4326
|
-
});
|
|
4327
|
-
component.value = this.join(value);
|
|
4328
|
-
} else {
|
|
4329
|
-
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
4330
|
-
}
|
|
4331
|
-
newPos += component.count;
|
|
4332
|
-
if (!component.added) {
|
|
4333
|
-
oldPos += component.count;
|
|
4334
|
-
}
|
|
4335
|
-
} else {
|
|
4336
|
-
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
4337
|
-
oldPos += component.count;
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
|
-
return components;
|
|
4341
|
-
}
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/character.js
|
|
4345
|
-
class CharacterDiff extends Diff {
|
|
4346
|
-
}
|
|
4347
|
-
var characterDiff = new CharacterDiff;
|
|
4348
|
-
|
|
4349
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/util/string.js
|
|
4350
|
-
function longestCommonPrefix(str1, str2) {
|
|
4351
|
-
let i;
|
|
4352
|
-
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
4353
|
-
if (str1[i] != str2[i]) {
|
|
4354
|
-
return str1.slice(0, i);
|
|
4355
|
-
}
|
|
4356
|
-
}
|
|
4357
|
-
return str1.slice(0, i);
|
|
4358
|
-
}
|
|
4359
|
-
function longestCommonSuffix(str1, str2) {
|
|
4360
|
-
let i;
|
|
4361
|
-
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
4362
|
-
return "";
|
|
4363
|
-
}
|
|
4364
|
-
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
4365
|
-
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
4366
|
-
return str1.slice(-i);
|
|
4367
|
-
}
|
|
4368
|
-
}
|
|
4369
|
-
return str1.slice(-i);
|
|
4370
|
-
}
|
|
4371
|
-
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
4372
|
-
if (string.slice(0, oldPrefix.length) != oldPrefix) {
|
|
4373
|
-
throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
|
|
4374
|
-
}
|
|
4375
|
-
return newPrefix + string.slice(oldPrefix.length);
|
|
4376
|
-
}
|
|
4377
|
-
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
4378
|
-
if (!oldSuffix) {
|
|
4379
|
-
return string + newSuffix;
|
|
4380
|
-
}
|
|
4381
|
-
if (string.slice(-oldSuffix.length) != oldSuffix) {
|
|
4382
|
-
throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
|
|
4383
|
-
}
|
|
4384
|
-
return string.slice(0, -oldSuffix.length) + newSuffix;
|
|
4385
|
-
}
|
|
4386
|
-
function removePrefix(string, oldPrefix) {
|
|
4387
|
-
return replacePrefix(string, oldPrefix, "");
|
|
4388
|
-
}
|
|
4389
|
-
function removeSuffix(string, oldSuffix) {
|
|
4390
|
-
return replaceSuffix(string, oldSuffix, "");
|
|
4391
|
-
}
|
|
4392
|
-
function maximumOverlap(string1, string2) {
|
|
4393
|
-
return string2.slice(0, overlapCount(string1, string2));
|
|
4394
|
-
}
|
|
4395
|
-
function overlapCount(a, b) {
|
|
4396
|
-
let startA = 0;
|
|
4397
|
-
if (a.length > b.length) {
|
|
4398
|
-
startA = a.length - b.length;
|
|
4399
|
-
}
|
|
4400
|
-
let endB = b.length;
|
|
4401
|
-
if (a.length < b.length) {
|
|
4402
|
-
endB = a.length;
|
|
4403
|
-
}
|
|
4404
|
-
const map = Array(endB);
|
|
4405
|
-
let k = 0;
|
|
4406
|
-
map[0] = 0;
|
|
4407
|
-
for (let j = 1;j < endB; j++) {
|
|
4408
|
-
if (b[j] == b[k]) {
|
|
4409
|
-
map[j] = map[k];
|
|
4410
|
-
} else {
|
|
4411
|
-
map[j] = k;
|
|
4412
|
-
}
|
|
4413
|
-
while (k > 0 && b[j] != b[k]) {
|
|
4414
|
-
k = map[k];
|
|
4415
|
-
}
|
|
4416
|
-
if (b[j] == b[k]) {
|
|
4417
|
-
k++;
|
|
4418
|
-
}
|
|
4419
|
-
}
|
|
4420
|
-
k = 0;
|
|
4421
|
-
for (let i = startA;i < a.length; i++) {
|
|
4422
|
-
while (k > 0 && a[i] != b[k]) {
|
|
4423
|
-
k = map[k];
|
|
4424
|
-
}
|
|
4425
|
-
if (a[i] == b[k]) {
|
|
4426
|
-
k++;
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
return k;
|
|
4430
|
-
}
|
|
4431
|
-
function trailingWs(string) {
|
|
4432
|
-
let i;
|
|
4433
|
-
for (i = string.length - 1;i >= 0; i--) {
|
|
4434
|
-
if (!string[i].match(/\s/)) {
|
|
4435
|
-
break;
|
|
4436
|
-
}
|
|
4437
|
-
}
|
|
4438
|
-
return string.substring(i + 1);
|
|
4439
|
-
}
|
|
4440
|
-
function leadingWs(string) {
|
|
4441
|
-
const match = string.match(/^\s*/);
|
|
4442
|
-
return match ? match[0] : "";
|
|
4443
|
-
}
|
|
4444
|
-
|
|
4445
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/word.js
|
|
4446
|
-
var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
4447
|
-
var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
|
|
4448
|
-
|
|
4449
|
-
class WordDiff extends Diff {
|
|
4450
|
-
equals(left, right, options) {
|
|
4451
|
-
if (options.ignoreCase) {
|
|
4452
|
-
left = left.toLowerCase();
|
|
4453
|
-
right = right.toLowerCase();
|
|
4454
|
-
}
|
|
4455
|
-
return left.trim() === right.trim();
|
|
4456
|
-
}
|
|
4457
|
-
tokenize(value, options = {}) {
|
|
4458
|
-
let parts;
|
|
4459
|
-
if (options.intlSegmenter) {
|
|
4460
|
-
const segmenter = options.intlSegmenter;
|
|
4461
|
-
if (segmenter.resolvedOptions().granularity != "word") {
|
|
4462
|
-
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
4463
|
-
}
|
|
4464
|
-
parts = Array.from(segmenter.segment(value), (segment) => segment.segment);
|
|
4465
|
-
} else {
|
|
4466
|
-
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
4467
|
-
}
|
|
4468
|
-
const tokens = [];
|
|
4469
|
-
let prevPart = null;
|
|
4470
|
-
parts.forEach((part) => {
|
|
4471
|
-
if (/\s/.test(part)) {
|
|
4472
|
-
if (prevPart == null) {
|
|
4473
|
-
tokens.push(part);
|
|
4474
|
-
} else {
|
|
4475
|
-
tokens.push(tokens.pop() + part);
|
|
4476
|
-
}
|
|
4477
|
-
} else if (prevPart != null && /\s/.test(prevPart)) {
|
|
4478
|
-
if (tokens[tokens.length - 1] == prevPart) {
|
|
4479
|
-
tokens.push(tokens.pop() + part);
|
|
4480
|
-
} else {
|
|
4481
|
-
tokens.push(prevPart + part);
|
|
4482
|
-
}
|
|
4483
|
-
} else {
|
|
4484
|
-
tokens.push(part);
|
|
4485
|
-
}
|
|
4486
|
-
prevPart = part;
|
|
4487
|
-
});
|
|
4488
|
-
return tokens;
|
|
4489
|
-
}
|
|
4490
|
-
join(tokens) {
|
|
4491
|
-
return tokens.map((token, i) => {
|
|
4492
|
-
if (i == 0) {
|
|
4493
|
-
return token;
|
|
4494
|
-
} else {
|
|
4495
|
-
return token.replace(/^\s+/, "");
|
|
4496
|
-
}
|
|
4497
|
-
}).join("");
|
|
4498
|
-
}
|
|
4499
|
-
postProcess(changes, options) {
|
|
4500
|
-
if (!changes || options.oneChangePerToken) {
|
|
4501
|
-
return changes;
|
|
4502
|
-
}
|
|
4503
|
-
let lastKeep = null;
|
|
4504
|
-
let insertion = null;
|
|
4505
|
-
let deletion = null;
|
|
4506
|
-
changes.forEach((change) => {
|
|
4507
|
-
if (change.added) {
|
|
4508
|
-
insertion = change;
|
|
4509
|
-
} else if (change.removed) {
|
|
4510
|
-
deletion = change;
|
|
4511
|
-
} else {
|
|
4512
|
-
if (insertion || deletion) {
|
|
4513
|
-
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
4514
|
-
}
|
|
4515
|
-
lastKeep = change;
|
|
4516
|
-
insertion = null;
|
|
4517
|
-
deletion = null;
|
|
4518
|
-
}
|
|
4519
|
-
});
|
|
4520
|
-
if (insertion || deletion) {
|
|
4521
|
-
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
4522
|
-
}
|
|
4523
|
-
return changes;
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
var wordDiff = new WordDiff;
|
|
4527
|
-
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
4528
|
-
if (deletion && insertion) {
|
|
4529
|
-
const oldWsPrefix = leadingWs(deletion.value);
|
|
4530
|
-
const oldWsSuffix = trailingWs(deletion.value);
|
|
4531
|
-
const newWsPrefix = leadingWs(insertion.value);
|
|
4532
|
-
const newWsSuffix = trailingWs(insertion.value);
|
|
4533
|
-
if (startKeep) {
|
|
4534
|
-
const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
4535
|
-
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
4536
|
-
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
4537
|
-
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
4538
|
-
}
|
|
4539
|
-
if (endKeep) {
|
|
4540
|
-
const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
4541
|
-
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
4542
|
-
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
4543
|
-
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
4544
|
-
}
|
|
4545
|
-
} else if (insertion) {
|
|
4546
|
-
if (startKeep) {
|
|
4547
|
-
const ws = leadingWs(insertion.value);
|
|
4548
|
-
insertion.value = insertion.value.substring(ws.length);
|
|
4549
|
-
}
|
|
4550
|
-
if (endKeep) {
|
|
4551
|
-
const ws = leadingWs(endKeep.value);
|
|
4552
|
-
endKeep.value = endKeep.value.substring(ws.length);
|
|
4553
|
-
}
|
|
4554
|
-
} else if (startKeep && endKeep) {
|
|
4555
|
-
const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
|
|
4556
|
-
const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
4557
|
-
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
4558
|
-
const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
4559
|
-
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
4560
|
-
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
4561
|
-
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
4562
|
-
} else if (endKeep) {
|
|
4563
|
-
const endKeepWsPrefix = leadingWs(endKeep.value);
|
|
4564
|
-
const deletionWsSuffix = trailingWs(deletion.value);
|
|
4565
|
-
const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
4566
|
-
deletion.value = removeSuffix(deletion.value, overlap);
|
|
4567
|
-
} else if (startKeep) {
|
|
4568
|
-
const startKeepWsSuffix = trailingWs(startKeep.value);
|
|
4569
|
-
const deletionWsPrefix = leadingWs(deletion.value);
|
|
4570
|
-
const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
4571
|
-
deletion.value = removePrefix(deletion.value, overlap);
|
|
4572
|
-
}
|
|
4573
|
-
}
|
|
4574
|
-
|
|
4575
|
-
class WordsWithSpaceDiff extends Diff {
|
|
4576
|
-
tokenize(value) {
|
|
4577
|
-
const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
|
|
4578
|
-
return value.match(regex) || [];
|
|
4579
|
-
}
|
|
4580
|
-
}
|
|
4581
|
-
var wordsWithSpaceDiff = new WordsWithSpaceDiff;
|
|
4582
|
-
|
|
4583
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/line.js
|
|
4584
|
-
class LineDiff extends Diff {
|
|
4585
|
-
constructor() {
|
|
4586
|
-
super(...arguments);
|
|
4587
|
-
this.tokenize = tokenize;
|
|
4588
|
-
}
|
|
4589
|
-
equals(left, right, options) {
|
|
4590
|
-
if (options.ignoreWhitespace) {
|
|
4591
|
-
if (!options.newlineIsToken || !left.includes(`
|
|
4592
|
-
`)) {
|
|
4593
|
-
left = left.trim();
|
|
4594
|
-
}
|
|
4595
|
-
if (!options.newlineIsToken || !right.includes(`
|
|
4596
|
-
`)) {
|
|
4597
|
-
right = right.trim();
|
|
4598
|
-
}
|
|
4599
|
-
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
4600
|
-
if (left.endsWith(`
|
|
4601
|
-
`)) {
|
|
4602
|
-
left = left.slice(0, -1);
|
|
4603
|
-
}
|
|
4604
|
-
if (right.endsWith(`
|
|
4605
|
-
`)) {
|
|
4606
|
-
right = right.slice(0, -1);
|
|
4607
|
-
}
|
|
4608
|
-
}
|
|
4609
|
-
return super.equals(left, right, options);
|
|
4610
|
-
}
|
|
4611
|
-
}
|
|
4612
|
-
var lineDiff = new LineDiff;
|
|
4613
|
-
function tokenize(value, options) {
|
|
4614
|
-
if (options.stripTrailingCr) {
|
|
4615
|
-
value = value.replace(/\r\n/g, `
|
|
4616
|
-
`);
|
|
4617
|
-
}
|
|
4618
|
-
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
4619
|
-
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
4620
|
-
linesAndNewlines.pop();
|
|
4621
|
-
}
|
|
4622
|
-
for (let i = 0;i < linesAndNewlines.length; i++) {
|
|
4623
|
-
const line = linesAndNewlines[i];
|
|
4624
|
-
if (i % 2 && !options.newlineIsToken) {
|
|
4625
|
-
retLines[retLines.length - 1] += line;
|
|
4626
|
-
} else {
|
|
4627
|
-
retLines.push(line);
|
|
4628
|
-
}
|
|
4629
|
-
}
|
|
4630
|
-
return retLines;
|
|
4631
|
-
}
|
|
4632
|
-
|
|
4633
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/sentence.js
|
|
4634
|
-
function isSentenceEndPunct(char) {
|
|
4635
|
-
return char == "." || char == "!" || char == "?";
|
|
4636
|
-
}
|
|
4637
|
-
|
|
4638
|
-
class SentenceDiff extends Diff {
|
|
4639
|
-
tokenize(value) {
|
|
4640
|
-
var _a;
|
|
4641
|
-
const result = [];
|
|
4642
|
-
let tokenStartI = 0;
|
|
4643
|
-
for (let i = 0;i < value.length; i++) {
|
|
4644
|
-
if (i == value.length - 1) {
|
|
4645
|
-
result.push(value.slice(tokenStartI));
|
|
4646
|
-
break;
|
|
4647
|
-
}
|
|
4648
|
-
if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
|
|
4649
|
-
result.push(value.slice(tokenStartI, i + 1));
|
|
4650
|
-
i = tokenStartI = i + 1;
|
|
4651
|
-
while ((_a = value[i + 1]) === null || _a === undefined ? undefined : _a.match(/\s/)) {
|
|
4652
|
-
i++;
|
|
4653
|
-
}
|
|
4654
|
-
result.push(value.slice(tokenStartI, i + 1));
|
|
4655
|
-
tokenStartI = i + 1;
|
|
4656
|
-
}
|
|
4657
|
-
}
|
|
4658
|
-
return result;
|
|
4659
|
-
}
|
|
4660
|
-
}
|
|
4661
|
-
var sentenceDiff = new SentenceDiff;
|
|
4662
|
-
|
|
4663
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/css.js
|
|
4664
|
-
class CssDiff extends Diff {
|
|
4665
|
-
tokenize(value) {
|
|
4666
|
-
return value.split(/([{}:;,]|\s+)/);
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
var cssDiff = new CssDiff;
|
|
4670
|
-
|
|
4671
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/json.js
|
|
4672
|
-
class JsonDiff extends Diff {
|
|
4673
|
-
constructor() {
|
|
4674
|
-
super(...arguments);
|
|
4675
|
-
this.tokenize = tokenize;
|
|
4676
|
-
}
|
|
4677
|
-
get useLongestToken() {
|
|
4678
|
-
return true;
|
|
4679
|
-
}
|
|
4680
|
-
castInput(value, options) {
|
|
4681
|
-
const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
|
|
4682
|
-
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
|
|
4683
|
-
}
|
|
4684
|
-
equals(left, right, options) {
|
|
4685
|
-
return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
4686
|
-
}
|
|
4687
|
-
}
|
|
4688
|
-
var jsonDiff = new JsonDiff;
|
|
4689
|
-
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
4690
|
-
stack = stack || [];
|
|
4691
|
-
replacementStack = replacementStack || [];
|
|
4692
|
-
if (replacer) {
|
|
4693
|
-
obj = replacer(key === undefined ? "" : key, obj);
|
|
4694
|
-
}
|
|
4695
|
-
let i;
|
|
4696
|
-
for (i = 0;i < stack.length; i += 1) {
|
|
4697
|
-
if (stack[i] === obj) {
|
|
4698
|
-
return replacementStack[i];
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
let canonicalizedObj;
|
|
4702
|
-
if (Object.prototype.toString.call(obj) === "[object Array]") {
|
|
4703
|
-
stack.push(obj);
|
|
4704
|
-
canonicalizedObj = new Array(obj.length);
|
|
4705
|
-
replacementStack.push(canonicalizedObj);
|
|
4706
|
-
for (i = 0;i < obj.length; i += 1) {
|
|
4707
|
-
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
4708
|
-
}
|
|
4709
|
-
stack.pop();
|
|
4710
|
-
replacementStack.pop();
|
|
4711
|
-
return canonicalizedObj;
|
|
4712
|
-
}
|
|
4713
|
-
if (obj && obj.toJSON) {
|
|
4714
|
-
obj = obj.toJSON();
|
|
4715
|
-
}
|
|
4716
|
-
if (typeof obj === "object" && obj !== null) {
|
|
4717
|
-
stack.push(obj);
|
|
4718
|
-
canonicalizedObj = {};
|
|
4719
|
-
replacementStack.push(canonicalizedObj);
|
|
4720
|
-
const sortedKeys = [];
|
|
4721
|
-
let key2;
|
|
4722
|
-
for (key2 in obj) {
|
|
4723
|
-
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
4724
|
-
sortedKeys.push(key2);
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
sortedKeys.sort();
|
|
4728
|
-
for (i = 0;i < sortedKeys.length; i += 1) {
|
|
4729
|
-
key2 = sortedKeys[i];
|
|
4730
|
-
canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
|
|
4731
|
-
}
|
|
4732
|
-
stack.pop();
|
|
4733
|
-
replacementStack.pop();
|
|
4734
|
-
} else {
|
|
4735
|
-
canonicalizedObj = obj;
|
|
4736
|
-
}
|
|
4737
|
-
return canonicalizedObj;
|
|
4738
|
-
}
|
|
4739
|
-
|
|
4740
|
-
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/diff/array.js
|
|
4741
|
-
class ArrayDiff extends Diff {
|
|
4742
|
-
tokenize(value) {
|
|
4743
|
-
return value.slice();
|
|
4744
|
-
}
|
|
4745
|
-
join(value) {
|
|
4746
|
-
return value;
|
|
4747
|
-
}
|
|
4748
|
-
removeEmpty(value) {
|
|
4749
|
-
return value;
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
|
-
var arrayDiff = new ArrayDiff;
|
|
4753
|
-
|
|
4754
4143
|
// ../../node_modules/.bun/diff@8.0.2/node_modules/diff/libesm/patch/parse.js
|
|
4755
4144
|
function parsePatch(uniDiff) {
|
|
4756
4145
|
const diffstr = uniDiff.split(/\n/), list = [];
|
|
@@ -4855,7 +4244,6 @@ function parsePatch(uniDiff) {
|
|
|
4855
4244
|
}
|
|
4856
4245
|
return list;
|
|
4857
4246
|
}
|
|
4858
|
-
|
|
4859
4247
|
// src/renderables/Text.ts
|
|
4860
4248
|
class TextRenderable extends TextBufferRenderable {
|
|
4861
4249
|
_text;
|
|
@@ -7171,6 +6559,7 @@ class TextTableRenderable extends Renderable {
|
|
|
7171
6559
|
_content;
|
|
7172
6560
|
_wrapMode;
|
|
7173
6561
|
_columnWidthMode;
|
|
6562
|
+
_columnFitter;
|
|
7174
6563
|
_cellPadding;
|
|
7175
6564
|
_showBorders;
|
|
7176
6565
|
_border;
|
|
@@ -7198,8 +6587,9 @@ class TextTableRenderable extends Renderable {
|
|
|
7198
6587
|
_cachedMeasureWidth = undefined;
|
|
7199
6588
|
_defaultOptions = {
|
|
7200
6589
|
content: [],
|
|
7201
|
-
wrapMode: "
|
|
7202
|
-
columnWidthMode: "
|
|
6590
|
+
wrapMode: "word",
|
|
6591
|
+
columnWidthMode: "full",
|
|
6592
|
+
columnFitter: "proportional",
|
|
7203
6593
|
cellPadding: 0,
|
|
7204
6594
|
showBorders: true,
|
|
7205
6595
|
border: true,
|
|
@@ -7216,10 +6606,11 @@ class TextTableRenderable extends Renderable {
|
|
|
7216
6606
|
attributes: 0
|
|
7217
6607
|
};
|
|
7218
6608
|
constructor(ctx, options = {}) {
|
|
7219
|
-
super(ctx, { ...options, buffered: true });
|
|
6609
|
+
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0, buffered: true });
|
|
7220
6610
|
this._content = options.content ?? this._defaultOptions.content;
|
|
7221
6611
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
7222
6612
|
this._columnWidthMode = options.columnWidthMode ?? this._defaultOptions.columnWidthMode;
|
|
6613
|
+
this._columnFitter = this.resolveColumnFitter(options.columnFitter);
|
|
7223
6614
|
this._cellPadding = this.resolveCellPadding(options.cellPadding);
|
|
7224
6615
|
this._showBorders = options.showBorders ?? this._defaultOptions.showBorders;
|
|
7225
6616
|
this._border = options.border ?? this._defaultOptions.border;
|
|
@@ -7268,6 +6659,16 @@ class TextTableRenderable extends Renderable {
|
|
|
7268
6659
|
this._columnWidthMode = value;
|
|
7269
6660
|
this.invalidateLayoutAndRaster();
|
|
7270
6661
|
}
|
|
6662
|
+
get columnFitter() {
|
|
6663
|
+
return this._columnFitter;
|
|
6664
|
+
}
|
|
6665
|
+
set columnFitter(value) {
|
|
6666
|
+
const next = this.resolveColumnFitter(value);
|
|
6667
|
+
if (this._columnFitter === next)
|
|
6668
|
+
return;
|
|
6669
|
+
this._columnFitter = next;
|
|
6670
|
+
this.invalidateLayoutAndRaster();
|
|
6671
|
+
}
|
|
7271
6672
|
get cellPadding() {
|
|
7272
6673
|
return this._cellPadding;
|
|
7273
6674
|
}
|
|
@@ -7421,7 +6822,7 @@ class TextTableRenderable extends Renderable {
|
|
|
7421
6822
|
super.destroySelf();
|
|
7422
6823
|
}
|
|
7423
6824
|
setupMeasureFunc() {
|
|
7424
|
-
const measureFunc = (width, widthMode,
|
|
6825
|
+
const measureFunc = (width, widthMode, _height, _heightMode) => {
|
|
7425
6826
|
const hasWidthConstraint = widthMode !== MeasureMode.Undefined && Number.isFinite(width);
|
|
7426
6827
|
const rawWidthConstraint = hasWidthConstraint ? Math.max(1, Math.floor(width)) : undefined;
|
|
7427
6828
|
const widthConstraint = this.resolveLayoutWidthConstraint(rawWidthConstraint);
|
|
@@ -7433,9 +6834,6 @@ class TextTableRenderable extends Renderable {
|
|
|
7433
6834
|
if (widthMode === MeasureMode.AtMost && rawWidthConstraint !== undefined && this._positionType !== "absolute") {
|
|
7434
6835
|
measuredWidth = Math.min(rawWidthConstraint, measuredWidth);
|
|
7435
6836
|
}
|
|
7436
|
-
if (heightMode === MeasureMode.AtMost && Number.isFinite(height) && this._positionType !== "absolute") {
|
|
7437
|
-
measuredHeight = Math.min(Math.max(1, Math.floor(height)), measuredHeight);
|
|
7438
|
-
}
|
|
7439
6837
|
return {
|
|
7440
6838
|
width: measuredWidth,
|
|
7441
6839
|
height: measuredHeight
|
|
@@ -7607,6 +7005,9 @@ class TextTableRenderable extends Renderable {
|
|
|
7607
7005
|
tableHeight: (rowOffsets[rowOffsets.length - 1] ?? 0) + 1
|
|
7608
7006
|
};
|
|
7609
7007
|
}
|
|
7008
|
+
isFullWidthMode() {
|
|
7009
|
+
return this._columnWidthMode === "full";
|
|
7010
|
+
}
|
|
7610
7011
|
computeColumnWidths(maxTableWidth, borderLayout) {
|
|
7611
7012
|
const horizontalPadding = this.getHorizontalCellPadding();
|
|
7612
7013
|
const intrinsicWidths = new Array(this._columnCount).fill(1 + horizontalPadding);
|
|
@@ -7629,7 +7030,7 @@ class TextTableRenderable extends Renderable {
|
|
|
7629
7030
|
return intrinsicWidths;
|
|
7630
7031
|
}
|
|
7631
7032
|
if (currentWidth < maxContentWidth) {
|
|
7632
|
-
if (this.
|
|
7033
|
+
if (this.isFullWidthMode()) {
|
|
7633
7034
|
return this.expandColumnWidths(intrinsicWidths, maxContentWidth);
|
|
7634
7035
|
}
|
|
7635
7036
|
return intrinsicWidths;
|
|
@@ -7659,6 +7060,12 @@ class TextTableRenderable extends Renderable {
|
|
|
7659
7060
|
return expanded;
|
|
7660
7061
|
}
|
|
7661
7062
|
fitColumnWidths(widths, targetContentWidth) {
|
|
7063
|
+
if (this._columnFitter === "balanced") {
|
|
7064
|
+
return this.fitColumnWidthsBalanced(widths, targetContentWidth);
|
|
7065
|
+
}
|
|
7066
|
+
return this.fitColumnWidthsProportional(widths, targetContentWidth);
|
|
7067
|
+
}
|
|
7068
|
+
fitColumnWidthsProportional(widths, targetContentWidth) {
|
|
7662
7069
|
const minWidth = 1 + this.getHorizontalCellPadding();
|
|
7663
7070
|
const hardMinWidths = new Array(widths.length).fill(minWidth);
|
|
7664
7071
|
const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
|
|
@@ -7709,6 +7116,80 @@ class TextTableRenderable extends Renderable {
|
|
|
7709
7116
|
}
|
|
7710
7117
|
return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - integerShrink[idx]));
|
|
7711
7118
|
}
|
|
7119
|
+
fitColumnWidthsBalanced(widths, targetContentWidth) {
|
|
7120
|
+
const minWidth = 1 + this.getHorizontalCellPadding();
|
|
7121
|
+
const hardMinWidths = new Array(widths.length).fill(minWidth);
|
|
7122
|
+
const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
|
|
7123
|
+
const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
|
|
7124
|
+
const columns = baseWidths.length;
|
|
7125
|
+
if (columns === 0 || totalBaseWidth <= targetContentWidth) {
|
|
7126
|
+
return baseWidths;
|
|
7127
|
+
}
|
|
7128
|
+
const evenShare = Math.max(minWidth, Math.floor(targetContentWidth / columns));
|
|
7129
|
+
const preferredMinWidths = baseWidths.map((width) => Math.min(width, evenShare));
|
|
7130
|
+
const preferredMinTotal = preferredMinWidths.reduce((sum, width) => sum + width, 0);
|
|
7131
|
+
const floorWidths = preferredMinTotal <= targetContentWidth ? preferredMinWidths : hardMinWidths;
|
|
7132
|
+
const floorTotal = floorWidths.reduce((sum, width) => sum + width, 0);
|
|
7133
|
+
const clampedTarget = Math.max(floorTotal, targetContentWidth);
|
|
7134
|
+
if (totalBaseWidth <= clampedTarget) {
|
|
7135
|
+
return baseWidths;
|
|
7136
|
+
}
|
|
7137
|
+
const shrinkable = baseWidths.map((width, idx) => width - floorWidths[idx]);
|
|
7138
|
+
const totalShrinkable = shrinkable.reduce((sum, value) => sum + value, 0);
|
|
7139
|
+
if (totalShrinkable <= 0) {
|
|
7140
|
+
return [...floorWidths];
|
|
7141
|
+
}
|
|
7142
|
+
const targetShrink = totalBaseWidth - clampedTarget;
|
|
7143
|
+
const shrink = this.allocateShrinkByWeight(shrinkable, targetShrink, "sqrt");
|
|
7144
|
+
return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - shrink[idx]));
|
|
7145
|
+
}
|
|
7146
|
+
allocateShrinkByWeight(shrinkable, targetShrink, mode) {
|
|
7147
|
+
const shrink = new Array(shrinkable.length).fill(0);
|
|
7148
|
+
if (targetShrink <= 0) {
|
|
7149
|
+
return shrink;
|
|
7150
|
+
}
|
|
7151
|
+
const weights = shrinkable.map((value) => {
|
|
7152
|
+
if (value <= 0) {
|
|
7153
|
+
return 0;
|
|
7154
|
+
}
|
|
7155
|
+
return mode === "sqrt" ? Math.sqrt(value) : value;
|
|
7156
|
+
});
|
|
7157
|
+
const totalWeight = weights.reduce((sum, value) => sum + value, 0);
|
|
7158
|
+
if (totalWeight <= 0) {
|
|
7159
|
+
return shrink;
|
|
7160
|
+
}
|
|
7161
|
+
const fractions = new Array(shrinkable.length).fill(0);
|
|
7162
|
+
let usedShrink = 0;
|
|
7163
|
+
for (let idx = 0;idx < shrinkable.length; idx++) {
|
|
7164
|
+
if (shrinkable[idx] <= 0 || weights[idx] <= 0)
|
|
7165
|
+
continue;
|
|
7166
|
+
const exact = weights[idx] / totalWeight * targetShrink;
|
|
7167
|
+
const whole = Math.min(shrinkable[idx], Math.floor(exact));
|
|
7168
|
+
shrink[idx] = whole;
|
|
7169
|
+
fractions[idx] = exact - whole;
|
|
7170
|
+
usedShrink += whole;
|
|
7171
|
+
}
|
|
7172
|
+
let remainingShrink = targetShrink - usedShrink;
|
|
7173
|
+
while (remainingShrink > 0) {
|
|
7174
|
+
let bestIdx = -1;
|
|
7175
|
+
let bestFraction = -1;
|
|
7176
|
+
for (let idx = 0;idx < shrinkable.length; idx++) {
|
|
7177
|
+
if (shrinkable[idx] - shrink[idx] <= 0)
|
|
7178
|
+
continue;
|
|
7179
|
+
if (bestIdx === -1 || fractions[idx] > bestFraction || fractions[idx] === bestFraction && shrinkable[idx] > shrinkable[bestIdx]) {
|
|
7180
|
+
bestIdx = idx;
|
|
7181
|
+
bestFraction = fractions[idx];
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
if (bestIdx === -1) {
|
|
7185
|
+
break;
|
|
7186
|
+
}
|
|
7187
|
+
shrink[bestIdx] += 1;
|
|
7188
|
+
fractions[bestIdx] = 0;
|
|
7189
|
+
remainingShrink -= 1;
|
|
7190
|
+
}
|
|
7191
|
+
return shrink;
|
|
7192
|
+
}
|
|
7712
7193
|
computeRowHeights(columnWidths) {
|
|
7713
7194
|
const horizontalPadding = this.getHorizontalCellPadding();
|
|
7714
7195
|
const verticalPadding = this.getVerticalCellPadding();
|
|
@@ -8032,7 +7513,7 @@ class TextTableRenderable extends Renderable {
|
|
|
8032
7513
|
if (width === undefined || !Number.isFinite(width) || width <= 0) {
|
|
8033
7514
|
return;
|
|
8034
7515
|
}
|
|
8035
|
-
if (this._wrapMode !== "none" || this.
|
|
7516
|
+
if (this._wrapMode !== "none" || this.isFullWidthMode()) {
|
|
8036
7517
|
return Math.max(1, Math.floor(width));
|
|
8037
7518
|
}
|
|
8038
7519
|
return;
|
|
@@ -8043,6 +7524,12 @@ class TextTableRenderable extends Renderable {
|
|
|
8043
7524
|
getVerticalCellPadding() {
|
|
8044
7525
|
return this._cellPadding * 2;
|
|
8045
7526
|
}
|
|
7527
|
+
resolveColumnFitter(value) {
|
|
7528
|
+
if (value === undefined) {
|
|
7529
|
+
return this._defaultOptions.columnFitter;
|
|
7530
|
+
}
|
|
7531
|
+
return value === "balanced" ? "balanced" : "proportional";
|
|
7532
|
+
}
|
|
8046
7533
|
resolveCellPadding(value) {
|
|
8047
7534
|
if (value === undefined || !Number.isFinite(value)) {
|
|
8048
7535
|
return this._defaultOptions.cellPadding;
|
|
@@ -9823,8 +9310,9 @@ class MarkdownRenderable extends Renderable {
|
|
|
9823
9310
|
resolveTableRenderableOptions() {
|
|
9824
9311
|
const borders = this._tableOptions?.borders ?? true;
|
|
9825
9312
|
return {
|
|
9826
|
-
columnWidthMode: this._tableOptions?.widthMode ?? "
|
|
9827
|
-
|
|
9313
|
+
columnWidthMode: this._tableOptions?.widthMode ?? "full",
|
|
9314
|
+
columnFitter: this._tableOptions?.columnFitter ?? "proportional",
|
|
9315
|
+
wrapMode: this._tableOptions?.wrapMode ?? "word",
|
|
9828
9316
|
cellPadding: this._tableOptions?.cellPadding ?? 0,
|
|
9829
9317
|
border: borders,
|
|
9830
9318
|
outerBorder: this._tableOptions?.outerBorder ?? borders,
|
|
@@ -9836,6 +9324,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9836
9324
|
}
|
|
9837
9325
|
applyTableRenderableOptions(tableRenderable, options) {
|
|
9838
9326
|
tableRenderable.columnWidthMode = options.columnWidthMode;
|
|
9327
|
+
tableRenderable.columnFitter = options.columnFitter;
|
|
9839
9328
|
tableRenderable.wrapMode = options.wrapMode;
|
|
9840
9329
|
tableRenderable.cellPadding = options.cellPadding;
|
|
9841
9330
|
tableRenderable.border = options.border;
|
|
@@ -9866,6 +9355,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
9866
9355
|
width: "100%",
|
|
9867
9356
|
marginBottom,
|
|
9868
9357
|
columnWidthMode: options.columnWidthMode,
|
|
9358
|
+
columnFitter: options.columnFitter,
|
|
9869
9359
|
wrapMode: options.wrapMode,
|
|
9870
9360
|
cellPadding: options.cellPadding,
|
|
9871
9361
|
border: options.border,
|
|
@@ -10727,6 +10217,34 @@ class ContentRenderable extends BoxRenderable {
|
|
|
10727
10217
|
return this.getChildrenSortedByPrimaryAxis().map((child) => child.num);
|
|
10728
10218
|
}
|
|
10729
10219
|
}
|
|
10220
|
+
var SCROLLBOX_PADDING_KEYS = [
|
|
10221
|
+
"padding",
|
|
10222
|
+
"paddingX",
|
|
10223
|
+
"paddingY",
|
|
10224
|
+
"paddingTop",
|
|
10225
|
+
"paddingRight",
|
|
10226
|
+
"paddingBottom",
|
|
10227
|
+
"paddingLeft"
|
|
10228
|
+
];
|
|
10229
|
+
function pickScrollBoxPadding(options) {
|
|
10230
|
+
if (!options)
|
|
10231
|
+
return {};
|
|
10232
|
+
const picked = {};
|
|
10233
|
+
for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
10234
|
+
const value = options[key];
|
|
10235
|
+
if (value !== undefined) {
|
|
10236
|
+
picked[key] = value;
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
10239
|
+
return picked;
|
|
10240
|
+
}
|
|
10241
|
+
function stripScrollBoxPadding(options) {
|
|
10242
|
+
const sanitized = { ...options };
|
|
10243
|
+
for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
10244
|
+
delete sanitized[key];
|
|
10245
|
+
}
|
|
10246
|
+
return sanitized;
|
|
10247
|
+
}
|
|
10730
10248
|
|
|
10731
10249
|
class ScrollBoxRenderable extends BoxRenderable {
|
|
10732
10250
|
static idCounter = 0;
|
|
@@ -10874,27 +10392,38 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10874
10392
|
this._isApplyingStickyScroll = wasApplyingStickyScroll;
|
|
10875
10393
|
}
|
|
10876
10394
|
}
|
|
10877
|
-
constructor(ctx, {
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10395
|
+
constructor(ctx, options) {
|
|
10396
|
+
const {
|
|
10397
|
+
wrapperOptions,
|
|
10398
|
+
viewportOptions,
|
|
10399
|
+
contentOptions,
|
|
10400
|
+
rootOptions,
|
|
10401
|
+
scrollbarOptions,
|
|
10402
|
+
verticalScrollbarOptions,
|
|
10403
|
+
horizontalScrollbarOptions,
|
|
10404
|
+
stickyScroll = false,
|
|
10405
|
+
stickyStart,
|
|
10406
|
+
scrollX = false,
|
|
10407
|
+
scrollY = true,
|
|
10408
|
+
scrollAcceleration,
|
|
10409
|
+
viewportCulling = true,
|
|
10410
|
+
...rootBoxOptions
|
|
10411
|
+
} = options;
|
|
10412
|
+
const forwardedContentPadding = {
|
|
10413
|
+
...pickScrollBoxPadding(rootBoxOptions),
|
|
10414
|
+
...pickScrollBoxPadding(rootOptions)
|
|
10415
|
+
};
|
|
10416
|
+
const sanitizedRootBoxOptions = stripScrollBoxPadding(rootBoxOptions);
|
|
10417
|
+
const sanitizedRootOptions = rootOptions ? stripScrollBoxPadding(rootOptions) : undefined;
|
|
10418
|
+
const mergedContentOptions = {
|
|
10419
|
+
...forwardedContentPadding,
|
|
10420
|
+
...contentOptions
|
|
10421
|
+
};
|
|
10893
10422
|
super(ctx, {
|
|
10894
10423
|
flexDirection: "row",
|
|
10895
10424
|
alignItems: "stretch",
|
|
10896
|
-
...
|
|
10897
|
-
...
|
|
10425
|
+
...sanitizedRootBoxOptions,
|
|
10426
|
+
...sanitizedRootOptions
|
|
10898
10427
|
});
|
|
10899
10428
|
this.internalId = ScrollBoxRenderable.idCounter++;
|
|
10900
10429
|
this._stickyScroll = stickyScroll;
|
|
@@ -10926,7 +10455,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
10926
10455
|
onSizeChange: () => {
|
|
10927
10456
|
this.recalculateBarProps();
|
|
10928
10457
|
},
|
|
10929
|
-
...
|
|
10458
|
+
...mergedContentOptions,
|
|
10930
10459
|
id: `scroll-box-content-${this.internalId}`
|
|
10931
10460
|
});
|
|
10932
10461
|
this.viewport.add(this.content);
|
|
@@ -11242,6 +10771,34 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
11242
10771
|
this.requestRender();
|
|
11243
10772
|
});
|
|
11244
10773
|
}
|
|
10774
|
+
set padding(value) {
|
|
10775
|
+
this.content.padding = value;
|
|
10776
|
+
this.requestRender();
|
|
10777
|
+
}
|
|
10778
|
+
set paddingX(value) {
|
|
10779
|
+
this.content.paddingX = value;
|
|
10780
|
+
this.requestRender();
|
|
10781
|
+
}
|
|
10782
|
+
set paddingY(value) {
|
|
10783
|
+
this.content.paddingY = value;
|
|
10784
|
+
this.requestRender();
|
|
10785
|
+
}
|
|
10786
|
+
set paddingTop(value) {
|
|
10787
|
+
this.content.paddingTop = value;
|
|
10788
|
+
this.requestRender();
|
|
10789
|
+
}
|
|
10790
|
+
set paddingRight(value) {
|
|
10791
|
+
this.content.paddingRight = value;
|
|
10792
|
+
this.requestRender();
|
|
10793
|
+
}
|
|
10794
|
+
set paddingBottom(value) {
|
|
10795
|
+
this.content.paddingBottom = value;
|
|
10796
|
+
this.requestRender();
|
|
10797
|
+
}
|
|
10798
|
+
set paddingLeft(value) {
|
|
10799
|
+
this.content.paddingLeft = value;
|
|
10800
|
+
this.requestRender();
|
|
10801
|
+
}
|
|
11245
10802
|
set rootOptions(options) {
|
|
11246
10803
|
Object.assign(this, options);
|
|
11247
10804
|
this.requestRender();
|
|
@@ -12206,5 +11763,5 @@ export {
|
|
|
12206
11763
|
ASCIIFont
|
|
12207
11764
|
};
|
|
12208
11765
|
|
|
12209
|
-
//# debugId=
|
|
11766
|
+
//# debugId=3C6B494E292F6AEE64756E2164756E21
|
|
12210
11767
|
//# sourceMappingURL=index.js.map
|