@opentui/core 0.8.1 → 0.8.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/index.node.js CHANGED
@@ -253,7 +253,7 @@ import {
253
253
  CliRenderEvents2,
254
254
  RendererControlState2,
255
255
  CliRenderer2
256
- } from "./chunk-node-tpjmjvn7.js";
256
+ } from "./chunk-node-s9be55eh.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();
@@ -11794,7 +11797,9 @@ class TextTableRenderable extends Renderable2 {
11794
11797
 
11795
11798
  // src/renderables/markdown-parser.ts
11796
11799
  function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
11797
- if (!prevState || prevState.tokens.length === 0) {
11800
+ if (trailingUnstable === 0 && prevState?.content === newContent && prevState.stableTokenCount === prevState.tokens.length)
11801
+ return prevState;
11802
+ if (!prevState || prevState.tokens.length === 0 || trailingUnstable === 0) {
11798
11803
  try {
11799
11804
  const tokens = x.lex(newContent, { gfm: true });
11800
11805
  return {
@@ -11824,19 +11829,12 @@ function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
11824
11829
  }
11825
11830
  const stableTokens = prevState.tokens.slice(0, reuseCount);
11826
11831
  const remainingContent = newContent.slice(offset);
11827
- if (!remainingContent) {
11828
- return {
11829
- content: newContent,
11830
- tokens: stableTokens,
11831
- stableTokenCount: stableTokens.length
11832
- };
11833
- }
11834
11832
  try {
11835
11833
  const newTokens = x.lex(remainingContent, { gfm: true });
11836
11834
  return {
11837
11835
  content: newContent,
11838
11836
  tokens: [...stableTokens, ...newTokens],
11839
- stableTokenCount: trailingUnstable === 0 ? stableTokens.length + newTokens.length : stableTokens.length
11837
+ stableTokenCount: stableTokens.length
11840
11838
  };
11841
11839
  } catch {
11842
11840
  try {
@@ -12086,6 +12084,7 @@ class MarkdownRenderable extends Renderable2 {
12086
12084
  if (this._streaming !== value) {
12087
12085
  this.assertMutable();
12088
12086
  this._streaming = value;
12087
+ this._parseState = parseMarkdownIncremental(this._content, this._parseState, value ? 2 : 0);
12089
12088
  this.updateBlocks(true);
12090
12089
  }
12091
12090
  }
@@ -13334,8 +13333,9 @@ class MarkdownRenderable extends Renderable2 {
13334
13333
  this._stableBlockCount = 0;
13335
13334
  return;
13336
13335
  }
13337
- const trailingUnstable = this._streaming ? 2 : 0;
13338
- this._parseState = parseMarkdownIncremental(this._content, this._parseState, trailingUnstable);
13336
+ if (this._parseState?.content !== this._content) {
13337
+ this._parseState = parseMarkdownIncremental(this._content, this._parseState, this._streaming ? 2 : 0);
13338
+ }
13339
13339
  const tokens = this._parseState.tokens;
13340
13340
  if (tokens.length === 0 && this._content.length > 0) {
13341
13341
  this.clearBlockStates();
@@ -13365,7 +13365,7 @@ class MarkdownRenderable extends Renderable2 {
13365
13365
  const token = blockTokens[i];
13366
13366
  const nextToken = blockTokens[i + 1];
13367
13367
  const existing = this._blockStates[blockIndex];
13368
- if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
13368
+ if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type && (existing.canUpdateInPlace || !forceTableRefresh)) {
13369
13369
  existing.token = token;
13370
13370
  if (forceTableRefresh) {
13371
13371
  this.updateBlockRenderable(existing, token, blockIndex, nextToken, true);
@@ -13451,16 +13451,6 @@ class MarkdownRenderable extends Renderable2 {
13451
13451
  this._blockStates = [];
13452
13452
  this._stableBlockCount = 0;
13453
13453
  }
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
13454
  clearCache() {
13465
13455
  this._parseState = null;
13466
13456
  this.clearBlockStates();
@@ -13470,7 +13460,7 @@ class MarkdownRenderable extends Renderable2 {
13470
13460
  refreshStyles() {
13471
13461
  this._styleDirty = false;
13472
13462
  this._ctx.nativeScene.lifecyclePasses.refresh(this);
13473
- this.rerenderBlocks();
13463
+ this.updateBlocks(true);
13474
13464
  this.requestRender();
13475
13465
  }
13476
13466
  markStyleDirty() {
@@ -13482,7 +13472,7 @@ class MarkdownRenderable extends Renderable2 {
13482
13472
  return;
13483
13473
  this._styleDirty = false;
13484
13474
  this._ctx.nativeScene.lifecyclePasses.refresh(this);
13485
- this.rerenderBlocks();
13475
+ this.updateBlocks(true);
13486
13476
  }
13487
13477
  _needsLifecyclePass() {
13488
13478
  if (this.onLifecyclePass !== this.applyStyleChanges)
@@ -16316,5 +16306,5 @@ export {
16316
16306
  yellow2 as yellow
16317
16307
  };
16318
16308
 
16319
- //# debugId=3176549723C7AF9764756E2164756E21
16309
+ //# debugId=CD1EAF87C395884164756E2164756E21
16320
16310
  //# sourceMappingURL=index.node.js.map