@livo-tv/blocks 1.22.0 → 1.24.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 +33 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1201,6 +1201,7 @@ function LanguageSwitcher({
|
|
|
1201
1201
|
const sizes = sizeClasses2[size];
|
|
1202
1202
|
const shapeClass = shapeClasses2[shape];
|
|
1203
1203
|
const reduceMotion = useReducedMotion();
|
|
1204
|
+
const layoutId = `${useId()}-activeLanguage`;
|
|
1204
1205
|
const defaultLabels2 = {
|
|
1205
1206
|
language: labels.language ?? "Language"
|
|
1206
1207
|
};
|
|
@@ -1276,7 +1277,7 @@ function LanguageSwitcher({
|
|
|
1276
1277
|
motion.div,
|
|
1277
1278
|
{
|
|
1278
1279
|
className: cn("absolute inset-0 bg-secondary", shapeClass),
|
|
1279
|
-
layoutId
|
|
1280
|
+
layoutId,
|
|
1280
1281
|
initial: { opacity: 0 },
|
|
1281
1282
|
animate: { opacity: 1 },
|
|
1282
1283
|
exit: { opacity: 0 },
|
|
@@ -4005,6 +4006,9 @@ function remainderAfterOverlap(previous, next) {
|
|
|
4005
4006
|
}
|
|
4006
4007
|
return null;
|
|
4007
4008
|
}
|
|
4009
|
+
function liveCaptionRow(text, receivedAt, speaker) {
|
|
4010
|
+
return speaker == null ? { text, receivedAt } : { text, receivedAt, speaker };
|
|
4011
|
+
}
|
|
4008
4012
|
function coalesceLiveCaptionCues(cues) {
|
|
4009
4013
|
const out = [];
|
|
4010
4014
|
for (const cue of cues) {
|
|
@@ -4012,26 +4016,31 @@ function coalesceLiveCaptionCues(cues) {
|
|
|
4012
4016
|
if (!text) continue;
|
|
4013
4017
|
const last = out[out.length - 1];
|
|
4014
4018
|
if (!last) {
|
|
4015
|
-
out.push(
|
|
4019
|
+
out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
|
|
4020
|
+
continue;
|
|
4021
|
+
}
|
|
4022
|
+
if (last.speaker !== cue.speaker && (last.speaker != null || cue.speaker != null)) {
|
|
4023
|
+
out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
|
|
4016
4024
|
continue;
|
|
4017
4025
|
}
|
|
4018
4026
|
const lastNorm = normalizeLiveCaptionText(last.text);
|
|
4019
4027
|
const nextNorm = normalizeLiveCaptionText(text);
|
|
4020
4028
|
if (lastNorm === nextNorm) continue;
|
|
4021
4029
|
if (nextNorm.startsWith(lastNorm) || lastNorm.startsWith(nextNorm)) {
|
|
4022
|
-
out[out.length - 1] =
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4030
|
+
out[out.length - 1] = liveCaptionRow(
|
|
4031
|
+
nextNorm.length >= lastNorm.length ? text : last.text,
|
|
4032
|
+
cue.receivedAt,
|
|
4033
|
+
cue.speaker ?? last.speaker
|
|
4034
|
+
);
|
|
4026
4035
|
continue;
|
|
4027
4036
|
}
|
|
4028
4037
|
const remainder = remainderAfterOverlap(last.text, text);
|
|
4029
4038
|
if (remainder !== null) {
|
|
4030
4039
|
if (!remainder) continue;
|
|
4031
|
-
out.push(
|
|
4040
|
+
out.push(liveCaptionRow(remainder, cue.receivedAt, cue.speaker));
|
|
4032
4041
|
continue;
|
|
4033
4042
|
}
|
|
4034
|
-
out.push(
|
|
4043
|
+
out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
|
|
4035
4044
|
}
|
|
4036
4045
|
return out;
|
|
4037
4046
|
}
|
|
@@ -4086,7 +4095,14 @@ async function loadLiveCaptions(url) {
|
|
|
4086
4095
|
if (typeof record.receivedAt !== "number" || !Number.isFinite(record.receivedAt)) {
|
|
4087
4096
|
continue;
|
|
4088
4097
|
}
|
|
4089
|
-
|
|
4098
|
+
const parsed = {
|
|
4099
|
+
text: record.text.trim(),
|
|
4100
|
+
receivedAt: record.receivedAt
|
|
4101
|
+
};
|
|
4102
|
+
if (typeof record.speaker === "number" && Number.isFinite(record.speaker)) {
|
|
4103
|
+
parsed.speaker = record.speaker;
|
|
4104
|
+
}
|
|
4105
|
+
cues.push(parsed);
|
|
4090
4106
|
}
|
|
4091
4107
|
return { ok: true, cues };
|
|
4092
4108
|
} catch {
|
|
@@ -4159,6 +4175,10 @@ function LiveCaptionStack({
|
|
|
4159
4175
|
}, [lastReceivedAt, prefersReduced, cues.length]);
|
|
4160
4176
|
if (cues.length === 0) return null;
|
|
4161
4177
|
const windowed = variant === "window";
|
|
4178
|
+
const distinctSpeakers = new Set(
|
|
4179
|
+
cues.map((cue) => cue.speaker).filter((speaker) => speaker != null)
|
|
4180
|
+
);
|
|
4181
|
+
const showTurns = distinctSpeakers.size >= 2;
|
|
4162
4182
|
return /* @__PURE__ */ jsx(
|
|
4163
4183
|
"div",
|
|
4164
4184
|
{
|
|
@@ -4204,13 +4224,16 @@ function LiveCaptionStack({
|
|
|
4204
4224
|
const fromEnd = cues.length - 1 - index;
|
|
4205
4225
|
const opacity = fromEnd === 0 ? 1 : fromEnd === 1 ? 0.75 : 0.45;
|
|
4206
4226
|
const newest = fromEnd === 0;
|
|
4227
|
+
const previous = cues[index - 1];
|
|
4228
|
+
const turnStart = showTurns && (index === 0 || previous?.speaker !== cue.speaker);
|
|
4207
4229
|
return /* @__PURE__ */ jsxs(
|
|
4208
4230
|
"span",
|
|
4209
4231
|
{
|
|
4210
4232
|
style: { opacity },
|
|
4211
4233
|
"aria-live": newest ? "polite" : void 0,
|
|
4212
4234
|
children: [
|
|
4213
|
-
index > 0 ? " " : "",
|
|
4235
|
+
turnStart && index > 0 ? /* @__PURE__ */ jsx("br", {}) : index > 0 ? " " : "",
|
|
4236
|
+
turnStart ? "\u2013 " : "",
|
|
4214
4237
|
cue.text
|
|
4215
4238
|
]
|
|
4216
4239
|
},
|