@opentui/core 0.0.0-20251202-71dcabc4 → 0.0.0-20251205-41c885f6

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/index.js CHANGED
@@ -35,7 +35,6 @@ import {
35
35
  TextAttributes,
36
36
  TextBuffer,
37
37
  TreeSitterClient,
38
- __toESM,
39
38
  addDefaultParsers,
40
39
  bg,
41
40
  bgBlack,
@@ -120,7 +119,6 @@ import {
120
119
  red,
121
120
  registerEnvVar,
122
121
  renderFontToFrameBuffer,
123
- require_dist,
124
122
  resolveRenderLib,
125
123
  reverse,
126
124
  rgbToHex,
@@ -135,7 +133,7 @@ import {
135
133
  white,
136
134
  wrapWithDelegates,
137
135
  yellow
138
- } from "./index-r6acnfwr.js";
136
+ } from "./index-x5bb5xvn.js";
139
137
  // src/text-buffer-view.ts
140
138
  class TextBufferView {
141
139
  lib;
@@ -2199,7 +2197,7 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2199
2197
  }
2200
2198
  }
2201
2199
  // src/renderables/Box.ts
2202
- var import_bun_yoga = __toESM(require_dist(), 1);
2200
+ import { Edge, Gutter } from "bun-yoga";
2203
2201
  function isGapType(value) {
2204
2202
  if (value === undefined) {
2205
2203
  return true;
@@ -2378,45 +2376,45 @@ class BoxRenderable extends Renderable {
2378
2376
  }
2379
2377
  applyYogaBorders() {
2380
2378
  const node = this.yogaNode;
2381
- node.setBorder(import_bun_yoga.Edge.Left, this.borderSides.left ? 1 : 0);
2382
- node.setBorder(import_bun_yoga.Edge.Right, this.borderSides.right ? 1 : 0);
2383
- node.setBorder(import_bun_yoga.Edge.Top, this.borderSides.top ? 1 : 0);
2384
- node.setBorder(import_bun_yoga.Edge.Bottom, this.borderSides.bottom ? 1 : 0);
2379
+ node.setBorder(Edge.Left, this.borderSides.left ? 1 : 0);
2380
+ node.setBorder(Edge.Right, this.borderSides.right ? 1 : 0);
2381
+ node.setBorder(Edge.Top, this.borderSides.top ? 1 : 0);
2382
+ node.setBorder(Edge.Bottom, this.borderSides.bottom ? 1 : 0);
2385
2383
  this.requestRender();
2386
2384
  }
2387
2385
  applyYogaGap(options) {
2388
2386
  const node = this.yogaNode;
2389
2387
  if (isGapType(options.gap)) {
2390
- node.setGap(import_bun_yoga.Gutter.All, options.gap);
2388
+ node.setGap(Gutter.All, options.gap);
2391
2389
  }
2392
2390
  if (isGapType(options.rowGap)) {
2393
- node.setGap(import_bun_yoga.Gutter.Row, options.rowGap);
2391
+ node.setGap(Gutter.Row, options.rowGap);
2394
2392
  }
2395
2393
  if (isGapType(options.columnGap)) {
2396
- node.setGap(import_bun_yoga.Gutter.Column, options.columnGap);
2394
+ node.setGap(Gutter.Column, options.columnGap);
2397
2395
  }
2398
2396
  }
2399
2397
  set gap(gap) {
2400
2398
  if (isGapType(gap)) {
2401
- this.yogaNode.setGap(import_bun_yoga.Gutter.All, gap);
2399
+ this.yogaNode.setGap(Gutter.All, gap);
2402
2400
  this.requestRender();
2403
2401
  }
2404
2402
  }
2405
2403
  set rowGap(rowGap) {
2406
2404
  if (isGapType(rowGap)) {
2407
- this.yogaNode.setGap(import_bun_yoga.Gutter.Row, rowGap);
2405
+ this.yogaNode.setGap(Gutter.Row, rowGap);
2408
2406
  this.requestRender();
2409
2407
  }
2410
2408
  }
2411
2409
  set columnGap(columnGap) {
2412
2410
  if (isGapType(columnGap)) {
2413
- this.yogaNode.setGap(import_bun_yoga.Gutter.Column, columnGap);
2411
+ this.yogaNode.setGap(Gutter.Column, columnGap);
2414
2412
  this.requestRender();
2415
2413
  }
2416
2414
  }
2417
2415
  }
2418
2416
  // src/renderables/TextBufferRenderable.ts
2419
- var import_bun_yoga2 = __toESM(require_dist(), 1);
2417
+ import { MeasureMode } from "bun-yoga";
2420
2418
  class TextBufferRenderable extends Renderable {
2421
2419
  selectable = true;
2422
2420
  _defaultFg;
@@ -2689,7 +2687,7 @@ class TextBufferRenderable extends Renderable {
2689
2687
  setupMeasureFunc() {
2690
2688
  const measureFunc = (width, widthMode, height, heightMode) => {
2691
2689
  let effectiveWidth;
2692
- if (widthMode === import_bun_yoga2.MeasureMode.Undefined || isNaN(width)) {
2690
+ if (widthMode === MeasureMode.Undefined || isNaN(width)) {
2693
2691
  effectiveWidth = 0;
2694
2692
  } else {
2695
2693
  effectiveWidth = width;
@@ -2698,7 +2696,7 @@ class TextBufferRenderable extends Renderable {
2698
2696
  const measureResult = this.textBufferView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
2699
2697
  const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
2700
2698
  const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
2701
- if (widthMode === import_bun_yoga2.MeasureMode.AtMost && this._positionType !== "absolute") {
2699
+ if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
2702
2700
  return {
2703
2701
  width: Math.min(effectiveWidth, measuredWidth),
2704
2702
  height: Math.min(effectiveHeight, measuredHeight)
@@ -3756,720 +3754,8 @@ class LineNumberRenderable extends Renderable {
3756
3754
  }
3757
3755
  }
3758
3756
 
3759
- // ../../node_modules/diff/libesm/diff/base.js
3760
- class Diff {
3761
- diff(oldStr, newStr, options = {}) {
3762
- let callback;
3763
- if (typeof options === "function") {
3764
- callback = options;
3765
- options = {};
3766
- } else if ("callback" in options) {
3767
- callback = options.callback;
3768
- }
3769
- const oldString = this.castInput(oldStr, options);
3770
- const newString = this.castInput(newStr, options);
3771
- const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
3772
- const newTokens = this.removeEmpty(this.tokenize(newString, options));
3773
- return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
3774
- }
3775
- diffWithOptionsObj(oldTokens, newTokens, options, callback) {
3776
- var _a;
3777
- const done = (value) => {
3778
- value = this.postProcess(value, options);
3779
- if (callback) {
3780
- setTimeout(function() {
3781
- callback(value);
3782
- }, 0);
3783
- return;
3784
- } else {
3785
- return value;
3786
- }
3787
- };
3788
- const newLen = newTokens.length, oldLen = oldTokens.length;
3789
- let editLength = 1;
3790
- let maxEditLength = newLen + oldLen;
3791
- if (options.maxEditLength != null) {
3792
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
3793
- }
3794
- const maxExecutionTime = (_a = options.timeout) !== null && _a !== undefined ? _a : Infinity;
3795
- const abortAfterTimestamp = Date.now() + maxExecutionTime;
3796
- const bestPath = [{ oldPos: -1, lastComponent: undefined }];
3797
- let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
3798
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
3799
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
3800
- }
3801
- let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
3802
- const execEditLength = () => {
3803
- for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
3804
- let basePath;
3805
- const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
3806
- if (removePath) {
3807
- bestPath[diagonalPath - 1] = undefined;
3808
- }
3809
- let canAdd = false;
3810
- if (addPath) {
3811
- const addPathNewPos = addPath.oldPos - diagonalPath;
3812
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
3813
- }
3814
- const canRemove = removePath && removePath.oldPos + 1 < oldLen;
3815
- if (!canAdd && !canRemove) {
3816
- bestPath[diagonalPath] = undefined;
3817
- continue;
3818
- }
3819
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
3820
- basePath = this.addToPath(addPath, true, false, 0, options);
3821
- } else {
3822
- basePath = this.addToPath(removePath, false, true, 1, options);
3823
- }
3824
- newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
3825
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
3826
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
3827
- } else {
3828
- bestPath[diagonalPath] = basePath;
3829
- if (basePath.oldPos + 1 >= oldLen) {
3830
- maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
3831
- }
3832
- if (newPos + 1 >= newLen) {
3833
- minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
3834
- }
3835
- }
3836
- }
3837
- editLength++;
3838
- };
3839
- if (callback) {
3840
- (function exec() {
3841
- setTimeout(function() {
3842
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
3843
- return callback(undefined);
3844
- }
3845
- if (!execEditLength()) {
3846
- exec();
3847
- }
3848
- }, 0);
3849
- })();
3850
- } else {
3851
- while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
3852
- const ret = execEditLength();
3853
- if (ret) {
3854
- return ret;
3855
- }
3856
- }
3857
- }
3858
- }
3859
- addToPath(path, added, removed, oldPosInc, options) {
3860
- const last = path.lastComponent;
3861
- if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
3862
- return {
3863
- oldPos: path.oldPos + oldPosInc,
3864
- lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
3865
- };
3866
- } else {
3867
- return {
3868
- oldPos: path.oldPos + oldPosInc,
3869
- lastComponent: { count: 1, added, removed, previousComponent: last }
3870
- };
3871
- }
3872
- }
3873
- extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
3874
- const newLen = newTokens.length, oldLen = oldTokens.length;
3875
- let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
3876
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
3877
- newPos++;
3878
- oldPos++;
3879
- commonCount++;
3880
- if (options.oneChangePerToken) {
3881
- basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
3882
- }
3883
- }
3884
- if (commonCount && !options.oneChangePerToken) {
3885
- basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
3886
- }
3887
- basePath.oldPos = oldPos;
3888
- return newPos;
3889
- }
3890
- equals(left, right, options) {
3891
- if (options.comparator) {
3892
- return options.comparator(left, right);
3893
- } else {
3894
- return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
3895
- }
3896
- }
3897
- removeEmpty(array) {
3898
- const ret = [];
3899
- for (let i = 0;i < array.length; i++) {
3900
- if (array[i]) {
3901
- ret.push(array[i]);
3902
- }
3903
- }
3904
- return ret;
3905
- }
3906
- castInput(value, options) {
3907
- return value;
3908
- }
3909
- tokenize(value, options) {
3910
- return Array.from(value);
3911
- }
3912
- join(chars) {
3913
- return chars.join("");
3914
- }
3915
- postProcess(changeObjects, options) {
3916
- return changeObjects;
3917
- }
3918
- get useLongestToken() {
3919
- return false;
3920
- }
3921
- buildValues(lastComponent, newTokens, oldTokens) {
3922
- const components = [];
3923
- let nextComponent;
3924
- while (lastComponent) {
3925
- components.push(lastComponent);
3926
- nextComponent = lastComponent.previousComponent;
3927
- delete lastComponent.previousComponent;
3928
- lastComponent = nextComponent;
3929
- }
3930
- components.reverse();
3931
- const componentLen = components.length;
3932
- let componentPos = 0, newPos = 0, oldPos = 0;
3933
- for (;componentPos < componentLen; componentPos++) {
3934
- const component = components[componentPos];
3935
- if (!component.removed) {
3936
- if (!component.added && this.useLongestToken) {
3937
- let value = newTokens.slice(newPos, newPos + component.count);
3938
- value = value.map(function(value2, i) {
3939
- const oldValue = oldTokens[oldPos + i];
3940
- return oldValue.length > value2.length ? oldValue : value2;
3941
- });
3942
- component.value = this.join(value);
3943
- } else {
3944
- component.value = this.join(newTokens.slice(newPos, newPos + component.count));
3945
- }
3946
- newPos += component.count;
3947
- if (!component.added) {
3948
- oldPos += component.count;
3949
- }
3950
- } else {
3951
- component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
3952
- oldPos += component.count;
3953
- }
3954
- }
3955
- return components;
3956
- }
3957
- }
3958
-
3959
- // ../../node_modules/diff/libesm/diff/character.js
3960
- class CharacterDiff extends Diff {
3961
- }
3962
- var characterDiff = new CharacterDiff;
3963
-
3964
- // ../../node_modules/diff/libesm/util/string.js
3965
- function longestCommonPrefix(str1, str2) {
3966
- let i;
3967
- for (i = 0;i < str1.length && i < str2.length; i++) {
3968
- if (str1[i] != str2[i]) {
3969
- return str1.slice(0, i);
3970
- }
3971
- }
3972
- return str1.slice(0, i);
3973
- }
3974
- function longestCommonSuffix(str1, str2) {
3975
- let i;
3976
- if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
3977
- return "";
3978
- }
3979
- for (i = 0;i < str1.length && i < str2.length; i++) {
3980
- if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
3981
- return str1.slice(-i);
3982
- }
3983
- }
3984
- return str1.slice(-i);
3985
- }
3986
- function replacePrefix(string, oldPrefix, newPrefix) {
3987
- if (string.slice(0, oldPrefix.length) != oldPrefix) {
3988
- throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
3989
- }
3990
- return newPrefix + string.slice(oldPrefix.length);
3991
- }
3992
- function replaceSuffix(string, oldSuffix, newSuffix) {
3993
- if (!oldSuffix) {
3994
- return string + newSuffix;
3995
- }
3996
- if (string.slice(-oldSuffix.length) != oldSuffix) {
3997
- throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
3998
- }
3999
- return string.slice(0, -oldSuffix.length) + newSuffix;
4000
- }
4001
- function removePrefix(string, oldPrefix) {
4002
- return replacePrefix(string, oldPrefix, "");
4003
- }
4004
- function removeSuffix(string, oldSuffix) {
4005
- return replaceSuffix(string, oldSuffix, "");
4006
- }
4007
- function maximumOverlap(string1, string2) {
4008
- return string2.slice(0, overlapCount(string1, string2));
4009
- }
4010
- function overlapCount(a, b) {
4011
- let startA = 0;
4012
- if (a.length > b.length) {
4013
- startA = a.length - b.length;
4014
- }
4015
- let endB = b.length;
4016
- if (a.length < b.length) {
4017
- endB = a.length;
4018
- }
4019
- const map = Array(endB);
4020
- let k = 0;
4021
- map[0] = 0;
4022
- for (let j = 1;j < endB; j++) {
4023
- if (b[j] == b[k]) {
4024
- map[j] = map[k];
4025
- } else {
4026
- map[j] = k;
4027
- }
4028
- while (k > 0 && b[j] != b[k]) {
4029
- k = map[k];
4030
- }
4031
- if (b[j] == b[k]) {
4032
- k++;
4033
- }
4034
- }
4035
- k = 0;
4036
- for (let i = startA;i < a.length; i++) {
4037
- while (k > 0 && a[i] != b[k]) {
4038
- k = map[k];
4039
- }
4040
- if (a[i] == b[k]) {
4041
- k++;
4042
- }
4043
- }
4044
- return k;
4045
- }
4046
- function trailingWs(string) {
4047
- let i;
4048
- for (i = string.length - 1;i >= 0; i--) {
4049
- if (!string[i].match(/\s/)) {
4050
- break;
4051
- }
4052
- }
4053
- return string.substring(i + 1);
4054
- }
4055
- function leadingWs(string) {
4056
- const match = string.match(/^\s*/);
4057
- return match ? match[0] : "";
4058
- }
4059
-
4060
- // ../../node_modules/diff/libesm/diff/word.js
4061
- 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}";
4062
- var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
4063
-
4064
- class WordDiff extends Diff {
4065
- equals(left, right, options) {
4066
- if (options.ignoreCase) {
4067
- left = left.toLowerCase();
4068
- right = right.toLowerCase();
4069
- }
4070
- return left.trim() === right.trim();
4071
- }
4072
- tokenize(value, options = {}) {
4073
- let parts;
4074
- if (options.intlSegmenter) {
4075
- const segmenter = options.intlSegmenter;
4076
- if (segmenter.resolvedOptions().granularity != "word") {
4077
- throw new Error('The segmenter passed must have a granularity of "word"');
4078
- }
4079
- parts = Array.from(segmenter.segment(value), (segment) => segment.segment);
4080
- } else {
4081
- parts = value.match(tokenizeIncludingWhitespace) || [];
4082
- }
4083
- const tokens = [];
4084
- let prevPart = null;
4085
- parts.forEach((part) => {
4086
- if (/\s/.test(part)) {
4087
- if (prevPart == null) {
4088
- tokens.push(part);
4089
- } else {
4090
- tokens.push(tokens.pop() + part);
4091
- }
4092
- } else if (prevPart != null && /\s/.test(prevPart)) {
4093
- if (tokens[tokens.length - 1] == prevPart) {
4094
- tokens.push(tokens.pop() + part);
4095
- } else {
4096
- tokens.push(prevPart + part);
4097
- }
4098
- } else {
4099
- tokens.push(part);
4100
- }
4101
- prevPart = part;
4102
- });
4103
- return tokens;
4104
- }
4105
- join(tokens) {
4106
- return tokens.map((token, i) => {
4107
- if (i == 0) {
4108
- return token;
4109
- } else {
4110
- return token.replace(/^\s+/, "");
4111
- }
4112
- }).join("");
4113
- }
4114
- postProcess(changes, options) {
4115
- if (!changes || options.oneChangePerToken) {
4116
- return changes;
4117
- }
4118
- let lastKeep = null;
4119
- let insertion = null;
4120
- let deletion = null;
4121
- changes.forEach((change) => {
4122
- if (change.added) {
4123
- insertion = change;
4124
- } else if (change.removed) {
4125
- deletion = change;
4126
- } else {
4127
- if (insertion || deletion) {
4128
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
4129
- }
4130
- lastKeep = change;
4131
- insertion = null;
4132
- deletion = null;
4133
- }
4134
- });
4135
- if (insertion || deletion) {
4136
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
4137
- }
4138
- return changes;
4139
- }
4140
- }
4141
- var wordDiff = new WordDiff;
4142
- function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
4143
- if (deletion && insertion) {
4144
- const oldWsPrefix = leadingWs(deletion.value);
4145
- const oldWsSuffix = trailingWs(deletion.value);
4146
- const newWsPrefix = leadingWs(insertion.value);
4147
- const newWsSuffix = trailingWs(insertion.value);
4148
- if (startKeep) {
4149
- const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
4150
- startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
4151
- deletion.value = removePrefix(deletion.value, commonWsPrefix);
4152
- insertion.value = removePrefix(insertion.value, commonWsPrefix);
4153
- }
4154
- if (endKeep) {
4155
- const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
4156
- endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
4157
- deletion.value = removeSuffix(deletion.value, commonWsSuffix);
4158
- insertion.value = removeSuffix(insertion.value, commonWsSuffix);
4159
- }
4160
- } else if (insertion) {
4161
- if (startKeep) {
4162
- const ws = leadingWs(insertion.value);
4163
- insertion.value = insertion.value.substring(ws.length);
4164
- }
4165
- if (endKeep) {
4166
- const ws = leadingWs(endKeep.value);
4167
- endKeep.value = endKeep.value.substring(ws.length);
4168
- }
4169
- } else if (startKeep && endKeep) {
4170
- const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
4171
- const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
4172
- deletion.value = removePrefix(deletion.value, newWsStart);
4173
- const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
4174
- deletion.value = removeSuffix(deletion.value, newWsEnd);
4175
- endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
4176
- startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
4177
- } else if (endKeep) {
4178
- const endKeepWsPrefix = leadingWs(endKeep.value);
4179
- const deletionWsSuffix = trailingWs(deletion.value);
4180
- const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
4181
- deletion.value = removeSuffix(deletion.value, overlap);
4182
- } else if (startKeep) {
4183
- const startKeepWsSuffix = trailingWs(startKeep.value);
4184
- const deletionWsPrefix = leadingWs(deletion.value);
4185
- const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
4186
- deletion.value = removePrefix(deletion.value, overlap);
4187
- }
4188
- }
4189
-
4190
- class WordsWithSpaceDiff extends Diff {
4191
- tokenize(value) {
4192
- const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
4193
- return value.match(regex) || [];
4194
- }
4195
- }
4196
- var wordsWithSpaceDiff = new WordsWithSpaceDiff;
4197
-
4198
- // ../../node_modules/diff/libesm/diff/line.js
4199
- class LineDiff extends Diff {
4200
- constructor() {
4201
- super(...arguments);
4202
- this.tokenize = tokenize;
4203
- }
4204
- equals(left, right, options) {
4205
- if (options.ignoreWhitespace) {
4206
- if (!options.newlineIsToken || !left.includes(`
4207
- `)) {
4208
- left = left.trim();
4209
- }
4210
- if (!options.newlineIsToken || !right.includes(`
4211
- `)) {
4212
- right = right.trim();
4213
- }
4214
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
4215
- if (left.endsWith(`
4216
- `)) {
4217
- left = left.slice(0, -1);
4218
- }
4219
- if (right.endsWith(`
4220
- `)) {
4221
- right = right.slice(0, -1);
4222
- }
4223
- }
4224
- return super.equals(left, right, options);
4225
- }
4226
- }
4227
- var lineDiff = new LineDiff;
4228
- function tokenize(value, options) {
4229
- if (options.stripTrailingCr) {
4230
- value = value.replace(/\r\n/g, `
4231
- `);
4232
- }
4233
- const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
4234
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
4235
- linesAndNewlines.pop();
4236
- }
4237
- for (let i = 0;i < linesAndNewlines.length; i++) {
4238
- const line = linesAndNewlines[i];
4239
- if (i % 2 && !options.newlineIsToken) {
4240
- retLines[retLines.length - 1] += line;
4241
- } else {
4242
- retLines.push(line);
4243
- }
4244
- }
4245
- return retLines;
4246
- }
4247
-
4248
- // ../../node_modules/diff/libesm/diff/sentence.js
4249
- function isSentenceEndPunct(char) {
4250
- return char == "." || char == "!" || char == "?";
4251
- }
4252
-
4253
- class SentenceDiff extends Diff {
4254
- tokenize(value) {
4255
- var _a;
4256
- const result = [];
4257
- let tokenStartI = 0;
4258
- for (let i = 0;i < value.length; i++) {
4259
- if (i == value.length - 1) {
4260
- result.push(value.slice(tokenStartI));
4261
- break;
4262
- }
4263
- if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
4264
- result.push(value.slice(tokenStartI, i + 1));
4265
- i = tokenStartI = i + 1;
4266
- while ((_a = value[i + 1]) === null || _a === undefined ? undefined : _a.match(/\s/)) {
4267
- i++;
4268
- }
4269
- result.push(value.slice(tokenStartI, i + 1));
4270
- tokenStartI = i + 1;
4271
- }
4272
- }
4273
- return result;
4274
- }
4275
- }
4276
- var sentenceDiff = new SentenceDiff;
4277
-
4278
- // ../../node_modules/diff/libesm/diff/css.js
4279
- class CssDiff extends Diff {
4280
- tokenize(value) {
4281
- return value.split(/([{}:;,]|\s+)/);
4282
- }
4283
- }
4284
- var cssDiff = new CssDiff;
4285
-
4286
- // ../../node_modules/diff/libesm/diff/json.js
4287
- class JsonDiff extends Diff {
4288
- constructor() {
4289
- super(...arguments);
4290
- this.tokenize = tokenize;
4291
- }
4292
- get useLongestToken() {
4293
- return true;
4294
- }
4295
- castInput(value, options) {
4296
- const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
4297
- return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
4298
- }
4299
- equals(left, right, options) {
4300
- return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
4301
- }
4302
- }
4303
- var jsonDiff = new JsonDiff;
4304
- function canonicalize(obj, stack, replacementStack, replacer, key) {
4305
- stack = stack || [];
4306
- replacementStack = replacementStack || [];
4307
- if (replacer) {
4308
- obj = replacer(key === undefined ? "" : key, obj);
4309
- }
4310
- let i;
4311
- for (i = 0;i < stack.length; i += 1) {
4312
- if (stack[i] === obj) {
4313
- return replacementStack[i];
4314
- }
4315
- }
4316
- let canonicalizedObj;
4317
- if (Object.prototype.toString.call(obj) === "[object Array]") {
4318
- stack.push(obj);
4319
- canonicalizedObj = new Array(obj.length);
4320
- replacementStack.push(canonicalizedObj);
4321
- for (i = 0;i < obj.length; i += 1) {
4322
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
4323
- }
4324
- stack.pop();
4325
- replacementStack.pop();
4326
- return canonicalizedObj;
4327
- }
4328
- if (obj && obj.toJSON) {
4329
- obj = obj.toJSON();
4330
- }
4331
- if (typeof obj === "object" && obj !== null) {
4332
- stack.push(obj);
4333
- canonicalizedObj = {};
4334
- replacementStack.push(canonicalizedObj);
4335
- const sortedKeys = [];
4336
- let key2;
4337
- for (key2 in obj) {
4338
- if (Object.prototype.hasOwnProperty.call(obj, key2)) {
4339
- sortedKeys.push(key2);
4340
- }
4341
- }
4342
- sortedKeys.sort();
4343
- for (i = 0;i < sortedKeys.length; i += 1) {
4344
- key2 = sortedKeys[i];
4345
- canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
4346
- }
4347
- stack.pop();
4348
- replacementStack.pop();
4349
- } else {
4350
- canonicalizedObj = obj;
4351
- }
4352
- return canonicalizedObj;
4353
- }
4354
-
4355
- // ../../node_modules/diff/libesm/diff/array.js
4356
- class ArrayDiff extends Diff {
4357
- tokenize(value) {
4358
- return value.slice();
4359
- }
4360
- join(value) {
4361
- return value;
4362
- }
4363
- removeEmpty(value) {
4364
- return value;
4365
- }
4366
- }
4367
- var arrayDiff = new ArrayDiff;
4368
-
4369
- // ../../node_modules/diff/libesm/patch/parse.js
4370
- function parsePatch(uniDiff) {
4371
- const diffstr = uniDiff.split(/\n/), list = [];
4372
- let i = 0;
4373
- function parseIndex() {
4374
- const index = {};
4375
- list.push(index);
4376
- while (i < diffstr.length) {
4377
- const line = diffstr[i];
4378
- if (/^(---|\+\+\+|@@)\s/.test(line)) {
4379
- break;
4380
- }
4381
- const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
4382
- if (header) {
4383
- index.index = header[1];
4384
- }
4385
- i++;
4386
- }
4387
- parseFileHeader(index);
4388
- parseFileHeader(index);
4389
- index.hunks = [];
4390
- while (i < diffstr.length) {
4391
- const line = diffstr[i];
4392
- if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
4393
- break;
4394
- } else if (/^@@/.test(line)) {
4395
- index.hunks.push(parseHunk());
4396
- } else if (line) {
4397
- throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
4398
- } else {
4399
- i++;
4400
- }
4401
- }
4402
- }
4403
- function parseFileHeader(index) {
4404
- const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
4405
- if (fileHeader) {
4406
- const data = fileHeader[2].split("\t", 2), header = (data[1] || "").trim();
4407
- let fileName = data[0].replace(/\\\\/g, "\\");
4408
- if (/^".*"$/.test(fileName)) {
4409
- fileName = fileName.substr(1, fileName.length - 2);
4410
- }
4411
- if (fileHeader[1] === "---") {
4412
- index.oldFileName = fileName;
4413
- index.oldHeader = header;
4414
- } else {
4415
- index.newFileName = fileName;
4416
- index.newHeader = header;
4417
- }
4418
- i++;
4419
- }
4420
- }
4421
- function parseHunk() {
4422
- var _a;
4423
- const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
4424
- const hunk = {
4425
- oldStart: +chunkHeader[1],
4426
- oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
4427
- newStart: +chunkHeader[3],
4428
- newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
4429
- lines: []
4430
- };
4431
- if (hunk.oldLines === 0) {
4432
- hunk.oldStart += 1;
4433
- }
4434
- if (hunk.newLines === 0) {
4435
- hunk.newStart += 1;
4436
- }
4437
- let addCount = 0, removeCount = 0;
4438
- for (;i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a = diffstr[i]) === null || _a === undefined ? undefined : _a.startsWith("\\"))); i++) {
4439
- const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
4440
- if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
4441
- hunk.lines.push(diffstr[i]);
4442
- if (operation === "+") {
4443
- addCount++;
4444
- } else if (operation === "-") {
4445
- removeCount++;
4446
- } else if (operation === " ") {
4447
- addCount++;
4448
- removeCount++;
4449
- }
4450
- } else {
4451
- throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
4452
- }
4453
- }
4454
- if (!addCount && hunk.newLines === 1) {
4455
- hunk.newLines = 0;
4456
- }
4457
- if (!removeCount && hunk.oldLines === 1) {
4458
- hunk.oldLines = 0;
4459
- }
4460
- if (addCount !== hunk.newLines) {
4461
- throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
4462
- }
4463
- if (removeCount !== hunk.oldLines) {
4464
- throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
4465
- }
4466
- return hunk;
4467
- }
4468
- while (i < diffstr.length) {
4469
- parseIndex();
4470
- }
4471
- return list;
4472
- }
3757
+ // src/renderables/Diff.ts
3758
+ import { parsePatch } from "diff";
4473
3759
 
4474
3760
  // src/renderables/Text.ts
4475
3761
  class TextRenderable extends TextBufferRenderable {
@@ -7499,7 +6785,7 @@ class TabSelectRenderable extends Renderable {
7499
6785
  }
7500
6786
  }
7501
6787
  // src/renderables/EditBufferRenderable.ts
7502
- var import_bun_yoga3 = __toESM(require_dist(), 1);
6788
+ import { MeasureMode as MeasureMode2 } from "bun-yoga";
7503
6789
 
7504
6790
  class EditBufferRenderable extends Renderable {
7505
6791
  _focusable = true;
@@ -7800,7 +7086,7 @@ class EditBufferRenderable extends Renderable {
7800
7086
  setupMeasureFunc() {
7801
7087
  const measureFunc = (width, widthMode, height, heightMode) => {
7802
7088
  let effectiveWidth;
7803
- if (widthMode === import_bun_yoga3.MeasureMode.Undefined || isNaN(width)) {
7089
+ if (widthMode === MeasureMode2.Undefined || isNaN(width)) {
7804
7090
  effectiveWidth = 0;
7805
7091
  } else {
7806
7092
  effectiveWidth = width;
@@ -7809,7 +7095,7 @@ class EditBufferRenderable extends Renderable {
7809
7095
  const measureResult = this.editorView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
7810
7096
  const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
7811
7097
  const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
7812
- if (widthMode === import_bun_yoga3.MeasureMode.AtMost && this._positionType !== "absolute") {
7098
+ if (widthMode === MeasureMode2.AtMost && this._positionType !== "absolute") {
7813
7099
  return {
7814
7100
  width: Math.min(effectiveWidth, measuredWidth),
7815
7101
  height: Math.min(effectiveHeight, measuredHeight)
@@ -8472,7 +7758,7 @@ class TextareaRenderable extends EditBufferRenderable {
8472
7758
  }
8473
7759
  }
8474
7760
  // src/index.ts
8475
- var Yoga = __toESM(require_dist(), 1);
7761
+ import * as Yoga from "bun-yoga";
8476
7762
  export {
8477
7763
  yellow,
8478
7764
  wrapWithDelegates,
@@ -8660,5 +7946,5 @@ export {
8660
7946
  ASCIIFont
8661
7947
  };
8662
7948
 
8663
- //# debugId=FC7E508FCF3C484F64756E2164756E21
7949
+ //# debugId=8B540B053341534264756E2164756E21
8664
7950
  //# sourceMappingURL=index.js.map