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