@mebius-io/web 0.5.4 → 0.6.0

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/index.js CHANGED
@@ -820,7 +820,13 @@ var MebiusCaptions = class extends TypedEmitter {
820
820
  this.es = null;
821
821
  this.timer = null;
822
822
  this.pending = /* @__PURE__ */ new Map();
823
- this.shown = /* @__PURE__ */ new Set();
823
+ /**
824
+ * segmentId -> the rev already handed to listeners. Not a Set: with interim
825
+ * revisions on, a segment stays pending while it is being corrected, and a
826
+ * plain "have I shown this id" check re-emits the same unchanged text on
827
+ * every 100ms tick. Comparing revs emits exactly once per actual revision.
828
+ */
829
+ this.shown = /* @__PURE__ */ new Map();
824
830
  }
825
831
  /** Open the SSE connection and begin emitting segments for `streamId`. */
826
832
  start(streamId) {
@@ -869,8 +875,9 @@ var MebiusCaptions = class extends TypedEmitter {
869
875
  this.emit("cleared", { segmentId: id });
870
876
  continue;
871
877
  }
872
- if (this.shown.has(id) && frame.state === "final") continue;
873
- this.shown.add(id);
878
+ const rev = frame.rev ?? 0;
879
+ if (this.shown.get(id) === rev) continue;
880
+ this.shown.set(id, rev);
874
881
  this.emit("segment", toSegment(id, frame, this.opts.lang));
875
882
  }
876
883
  }
@@ -883,6 +890,7 @@ function toSegment(segmentId, frame, lang) {
883
890
  epochMs: frame.epochMs ?? 0,
884
891
  durationMs: frame.durationMs ?? 0,
885
892
  text: frame.text ?? "",
893
+ srcLang: frame.srcLang,
886
894
  translation: frame.translations?.[lang],
887
895
  machineGenerated: true
888
896
  };