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