typebulb 0.51.0 → 0.51.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/dist/render.js CHANGED
@@ -723,19 +723,17 @@ const something = require('module-name') // NOT SUPPORTED!
723
723
 
724
724
  // tb.infer() \u2014 the local inference layer (TB-Inference.md). The UI and network live in the
725
725
  // lazy-imported modal module (/__infer-ui.js \u2014 zero bytes here until the first call); the shim
726
- // stays the state machine and globals writer. The promise settles once: a modal retry after a
726
+ // stays the concurrency guard and globals writer. The promise settles once: a modal retry after a
727
727
  // rejected promise still updates runtime state on success, for tb.insight() readers.
728
- let inferState = 'idle';
729
- let dataOverrides = null;
728
+ let inferRunning = false;
730
729
  const infer = (opts = {}) => {
731
730
  if (isFramed) return Promise.reject(inlineErr('tb.infer()'));
732
- if (inferState === 'running') return Promise.reject(new Error('Inference already in progress'));
733
- inferState = 'running';
734
- // Data priority (matching the .com sandbox): explicit arg > setData overrides > undefined \u2014
735
- // the modal then seeds from the SOURCE chunks (/__infer-info), the local Data tab, exactly as
736
- // .com's IDE modal reseeds from the Data tab rather than post-run runtime state.
731
+ if (inferRunning) return Promise.reject(new Error('Inference already in progress'));
732
+ inferRunning = true;
733
+ // Data to preview: the explicit arg, else undefined \u2014 the modal then seeds from the SOURCE
734
+ // chunks (/__infer-info), the local Data tab, exactly as .com's IDE modal reseeds from the
735
+ // Data tab rather than post-run runtime state.
737
736
  let data = opts.data;
738
- if (data === undefined && dataOverrides) data = Object.values(dataOverrides);
739
737
  if (data !== undefined && !Array.isArray(data)) data = [data];
740
738
  return new Promise((resolve, reject) => {
741
739
  let settled = false;
@@ -751,19 +749,19 @@ const something = require('module-name') // NOT SUPPORTED!
751
749
  window.__TB_INSIGHT__ = final.insightJson;
752
750
  if (final.data && final.data.length) window.__TB_DATA__ = final.data;
753
751
  if (final.hash) history.replaceState(null, '', location.pathname + location.search + final.hash);
754
- inferState = 'complete';
752
+ inferRunning = false;
755
753
  settle(resolve, final.insight);
756
754
  },
757
755
  onError: (err) => {
758
- inferState = 'error';
756
+ inferRunning = false;
759
757
  const e = new Error(err.message); e.code = err.code; e.retryable = !!err.retryable;
760
758
  settle(reject, e);
761
759
  },
762
760
  onCancel: () => {
763
- if (!settled) { inferState = 'idle'; settle(resolve, undefined); }
761
+ if (!settled) { inferRunning = false; settle(resolve, undefined); }
764
762
  }
765
763
  });
766
- }).catch((e) => { inferState = 'error'; settle(reject, e); });
764
+ }).catch((e) => { inferRunning = false; settle(reject, e); });
767
765
  });
768
766
  };
769
767
 
@@ -812,9 +810,6 @@ const something = require('module-name') // NOT SUPPORTED!
812
810
 
813
811
  // Inference (TB-Inference.md) \u2014 modal-hosted one-shot LLM call over the bulb's own blocks
814
812
  infer,
815
- inferenceState: () => inferState,
816
- setData: (index, content) => { if (!dataOverrides) dataOverrides = {}; dataOverrides[index] = content; },
817
- resetInferenceState: () => { inferState = 'idle'; dataOverrides = null; },
818
813
 
819
814
  // AI - tb.ai() proxies to the provider via the local server; tb.ai.stream() streams AiChunks.
820
815
  ai,