@opentui/core 0.8.1 → 0.8.3

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.bun.js CHANGED
@@ -120,7 +120,7 @@ import {
120
120
  Gutter2,
121
121
  MeasureMode2,
122
122
  exports_yoga
123
- } from "./chunk-bun-wdetc10w.js";
123
+ } from "./chunk-bun-12ttbayv.js";
124
124
  import {
125
125
  isValidBorderStyle2,
126
126
  parseBorderStyle2,
@@ -254,7 +254,7 @@ import {
254
254
  CliRenderEvents2,
255
255
  RendererControlState2,
256
256
  CliRenderer2
257
- } from "./chunk-bun-ved2tpxm.js";
257
+ } from "./chunk-bun-psdzwx7h.js";
258
258
  // src/syntax-style.ts
259
259
  function cloneStyle(style) {
260
260
  return {
@@ -4743,7 +4743,10 @@ class AudioRecorder extends EventEmitter {
4743
4743
  await this.writeFully(createWavHeader(this.sampleRate, this.channels, Number(this.dataBytesWritten)), 0, "finalize");
4744
4744
  if (this.terminationRequest != null)
4745
4745
  return;
4746
- await this.fileHandle.sync();
4746
+ await this.fileHandle.sync().catch((cause) => {
4747
+ if (cause.code !== "ERR_ACCESS_DENIED")
4748
+ throw cause;
4749
+ });
4747
4750
  if (this.terminationRequest != null)
4748
4751
  return;
4749
4752
  await this.fileHandle.close();
@@ -8163,6 +8166,11 @@ class EmbeddedTerminalRenderable extends Renderable2 {
8163
8166
  }
8164
8167
  };
8165
8168
  }
8169
+ getScroll() {
8170
+ if (!this.handle)
8171
+ return { offset: 0, total: 0, visible: 0 };
8172
+ return this.lib.contextEmbeddedTerminalScrollbar(this.handle.context, this.handle);
8173
+ }
8166
8174
  write(data) {
8167
8175
  if (!this.handle)
8168
8176
  return;
@@ -11795,7 +11803,9 @@ class TextTableRenderable extends Renderable2 {
11795
11803
 
11796
11804
  // src/renderables/markdown-parser.ts
11797
11805
  function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
11798
- if (!prevState || prevState.tokens.length === 0) {
11806
+ if (trailingUnstable === 0 && prevState?.content === newContent && prevState.stableTokenCount === prevState.tokens.length)
11807
+ return prevState;
11808
+ if (!prevState || prevState.tokens.length === 0 || trailingUnstable === 0) {
11799
11809
  try {
11800
11810
  const tokens = x.lex(newContent, { gfm: true });
11801
11811
  return {
@@ -11825,19 +11835,12 @@ function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
11825
11835
  }
11826
11836
  const stableTokens = prevState.tokens.slice(0, reuseCount);
11827
11837
  const remainingContent = newContent.slice(offset);
11828
- if (!remainingContent) {
11829
- return {
11830
- content: newContent,
11831
- tokens: stableTokens,
11832
- stableTokenCount: stableTokens.length
11833
- };
11834
- }
11835
11838
  try {
11836
11839
  const newTokens = x.lex(remainingContent, { gfm: true });
11837
11840
  return {
11838
11841
  content: newContent,
11839
11842
  tokens: [...stableTokens, ...newTokens],
11840
- stableTokenCount: trailingUnstable === 0 ? stableTokens.length + newTokens.length : stableTokens.length
11843
+ stableTokenCount: stableTokens.length
11841
11844
  };
11842
11845
  } catch {
11843
11846
  try {
@@ -12087,6 +12090,7 @@ class MarkdownRenderable extends Renderable2 {
12087
12090
  if (this._streaming !== value) {
12088
12091
  this.assertMutable();
12089
12092
  this._streaming = value;
12093
+ this._parseState = parseMarkdownIncremental(this._content, this._parseState, value ? 2 : 0);
12090
12094
  this.updateBlocks(true);
12091
12095
  }
12092
12096
  }
@@ -13335,8 +13339,9 @@ class MarkdownRenderable extends Renderable2 {
13335
13339
  this._stableBlockCount = 0;
13336
13340
  return;
13337
13341
  }
13338
- const trailingUnstable = this._streaming ? 2 : 0;
13339
- this._parseState = parseMarkdownIncremental(this._content, this._parseState, trailingUnstable);
13342
+ if (this._parseState?.content !== this._content) {
13343
+ this._parseState = parseMarkdownIncremental(this._content, this._parseState, this._streaming ? 2 : 0);
13344
+ }
13340
13345
  const tokens = this._parseState.tokens;
13341
13346
  if (tokens.length === 0 && this._content.length > 0) {
13342
13347
  this.clearBlockStates();
@@ -13366,7 +13371,7 @@ class MarkdownRenderable extends Renderable2 {
13366
13371
  const token = blockTokens[i];
13367
13372
  const nextToken = blockTokens[i + 1];
13368
13373
  const existing = this._blockStates[blockIndex];
13369
- if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
13374
+ if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type && (existing.canUpdateInPlace || !forceTableRefresh)) {
13370
13375
  existing.token = token;
13371
13376
  if (forceTableRefresh) {
13372
13377
  this.updateBlockRenderable(existing, token, blockIndex, nextToken, true);
@@ -13452,16 +13457,6 @@ class MarkdownRenderable extends Renderable2 {
13452
13457
  this._blockStates = [];
13453
13458
  this._stableBlockCount = 0;
13454
13459
  }
13455
- rerenderBlocks() {
13456
- if (this._internalBlockMode === "top-level") {
13457
- this.updateBlocks(true);
13458
- return;
13459
- }
13460
- for (let i = 0;i < this._blockStates.length; i++) {
13461
- const state = this._blockStates[i];
13462
- this.updateBlockRenderable(state, state.token, i, this._blockStates[i + 1]?.token, true);
13463
- }
13464
- }
13465
13460
  clearCache() {
13466
13461
  this._parseState = null;
13467
13462
  this.clearBlockStates();
@@ -13471,7 +13466,7 @@ class MarkdownRenderable extends Renderable2 {
13471
13466
  refreshStyles() {
13472
13467
  this._styleDirty = false;
13473
13468
  this._ctx.nativeScene.lifecyclePasses.refresh(this);
13474
- this.rerenderBlocks();
13469
+ this.updateBlocks(true);
13475
13470
  this.requestRender();
13476
13471
  }
13477
13472
  markStyleDirty() {
@@ -13483,7 +13478,7 @@ class MarkdownRenderable extends Renderable2 {
13483
13478
  return;
13484
13479
  this._styleDirty = false;
13485
13480
  this._ctx.nativeScene.lifecyclePasses.refresh(this);
13486
- this.rerenderBlocks();
13481
+ this.updateBlocks(true);
13487
13482
  }
13488
13483
  _needsLifecyclePass() {
13489
13484
  if (this.onLifecyclePass !== this.applyStyleChanges)
@@ -16317,5 +16312,5 @@ export {
16317
16312
  yellow2 as yellow
16318
16313
  };
16319
16314
 
16320
- //# debugId=3FC176E86CAEA33964756E2164756E21
16315
+ //# debugId=59547B18FAA5886764756E2164756E21
16321
16316
  //# sourceMappingURL=index.bun.js.map