@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.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.global.js +11 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -862,7 +862,13 @@ var MebiusCaptions = class extends TypedEmitter {
|
|
|
862
862
|
this.es = null;
|
|
863
863
|
this.timer = null;
|
|
864
864
|
this.pending = /* @__PURE__ */ new Map();
|
|
865
|
-
|
|
865
|
+
/**
|
|
866
|
+
* segmentId -> the rev already handed to listeners. Not a Set: with interim
|
|
867
|
+
* revisions on, a segment stays pending while it is being corrected, and a
|
|
868
|
+
* plain "have I shown this id" check re-emits the same unchanged text on
|
|
869
|
+
* every 100ms tick. Comparing revs emits exactly once per actual revision.
|
|
870
|
+
*/
|
|
871
|
+
this.shown = /* @__PURE__ */ new Map();
|
|
866
872
|
}
|
|
867
873
|
/** Open the SSE connection and begin emitting segments for `streamId`. */
|
|
868
874
|
start(streamId) {
|
|
@@ -911,8 +917,9 @@ var MebiusCaptions = class extends TypedEmitter {
|
|
|
911
917
|
this.emit("cleared", { segmentId: id });
|
|
912
918
|
continue;
|
|
913
919
|
}
|
|
914
|
-
|
|
915
|
-
this.shown.
|
|
920
|
+
const rev = frame.rev ?? 0;
|
|
921
|
+
if (this.shown.get(id) === rev) continue;
|
|
922
|
+
this.shown.set(id, rev);
|
|
916
923
|
this.emit("segment", toSegment(id, frame, this.opts.lang));
|
|
917
924
|
}
|
|
918
925
|
}
|
|
@@ -925,6 +932,7 @@ function toSegment(segmentId, frame, lang) {
|
|
|
925
932
|
epochMs: frame.epochMs ?? 0,
|
|
926
933
|
durationMs: frame.durationMs ?? 0,
|
|
927
934
|
text: frame.text ?? "",
|
|
935
|
+
srcLang: frame.srcLang,
|
|
928
936
|
translation: frame.translations?.[lang],
|
|
929
937
|
machineGenerated: true
|
|
930
938
|
};
|