@zync/zync-screnplay-player 0.1.251 → 0.1.252

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.
Files changed (28) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/screenplay/RemotionRenderer/RemotionRenderer.js +43 -42
  3. package/dist/screenplay/RemotionRenderer/assets/wordObjects/LICENSE +21 -0
  4. package/dist/screenplay/RemotionRenderer/assets/wordObjects/images.js +24 -0
  5. package/dist/screenplay/RemotionRenderer/assets/wordObjects/manifest.json +67 -0
  6. package/dist/screenplay/RemotionRenderer/components/effects/CaptionWordObjectOverlay.js +243 -0
  7. package/dist/screenplay/RemotionRenderer/components/effects/Sentence.js +10 -3
  8. package/dist/screenplay/RemotionRenderer/components/layouts/Keyword.js +7 -9
  9. package/dist/screenplay/RemotionRenderer/components/layouts/KeywordStudioBackdrop.js +5 -7
  10. package/dist/screenplay/RemotionRenderer/components/layouts/SimpleFrameSentence.js +3 -1
  11. package/dist/screenplay/RemotionRenderer/components/utils/FaceCenteredVideo.js +9 -0
  12. package/dist/screenplay/RemotionRenderer/helpers/captionWordObjectGeometry.js +139 -0
  13. package/dist/screenplay/RemotionRenderer/helpers/captionWordObjects.js +112 -0
  14. package/dist/screenplay/RemotionRenderer/helpers/headingColors.js +12 -0
  15. package/dist/screenplay/RemotionRenderer/helpers/normalizeDisabledTranscripts.js +3 -629
  16. package/dist/screenplay/RemotionRenderer/main/lib/layouts/LayoutFactory.js +0 -15
  17. package/dist/screenplay/RemotionRenderer/main/lib/layouts/SimpleFrameLayout.js +8 -3
  18. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionPunctuated.js +29 -6
  19. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBoom.js +42 -47
  20. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBubble.js +30 -7
  21. package/dist/screenplay/RemotionRenderer/theme/themes/default/Sentence/AnimatedSentence.js +1 -0
  22. package/dist/screenplay/RemotionRenderer/theme/themes/default/Sentence.js +8 -4
  23. package/dist/screenplay/RemotionRenderer/theme/themes/fullcover/TextFullCover.js +10 -5
  24. package/dist/screenplay/RemotionRenderer/theme/themes/glassmorphism/Sentence.js +14 -4
  25. package/dist/screenplay/RemotionRenderer/tracks/LayoutVideoTrack.js +1 -1
  26. package/dist/screenplay/RemotionRenderer/tracks/Soundtrack.js +20 -3
  27. package/dist/timing.cjs +1050 -0
  28. package/package.json +8 -4
@@ -1,629 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
3
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- var EPSILON = 1e-6;
11
- var DEFAULT_FPS = 30;
12
- var MIN_CHUNK_DURATION_SECONDS = 0.26;
13
- var cloneValue = function cloneValue(value) {
14
- if (value === undefined) {
15
- return undefined;
16
- }
17
- return JSON.parse(JSON.stringify(value));
18
- };
19
- var toFiniteNumber = function toFiniteNumber(value) {
20
- var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
21
- var parsed = Number(value);
22
- if (!Number.isFinite(parsed)) {
23
- return fallback;
24
- }
25
- return parsed;
26
- };
27
- var isDisabled = function isDisabled(value) {
28
- return value === true || value === "true" || value === 1 || value === "1";
29
- };
30
- var buildInterval = function buildInterval(start, end) {
31
- if (!Number.isFinite(start) || !Number.isFinite(end)) {
32
- return null;
33
- }
34
- if (end <= start + EPSILON) {
35
- return null;
36
- }
37
- return {
38
- start: start,
39
- end: end
40
- };
41
- };
42
- var isMeaningfulDuration = function isMeaningfulDuration(duration) {
43
- return Number.isFinite(duration) && duration > Math.max(EPSILON, MIN_CHUNK_DURATION_SECONDS - EPSILON);
44
- };
45
- var mergeIntervals = function mergeIntervals() {
46
- var intervals = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
47
- if (!Array.isArray(intervals) || intervals.length === 0) {
48
- return [];
49
- }
50
- var normalized = intervals.map(function (interval) {
51
- return buildInterval(interval === null || interval === void 0 ? void 0 : interval.start, interval === null || interval === void 0 ? void 0 : interval.end);
52
- }).filter(Boolean).sort(function (a, b) {
53
- return a.start - b.start;
54
- });
55
- if (normalized.length === 0) {
56
- return [];
57
- }
58
- return normalized.reduce(function (merged, current) {
59
- var previous = merged[merged.length - 1];
60
- if (!previous) {
61
- merged.push(_objectSpread({}, current));
62
- return merged;
63
- }
64
- if (current.start <= previous.end + EPSILON) {
65
- previous.end = Math.max(previous.end, current.end);
66
- return merged;
67
- }
68
- merged.push(_objectSpread({}, current));
69
- return merged;
70
- }, []);
71
- };
72
- var subtractIntervals = function subtractIntervals(range) {
73
- var cuts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
74
- var start = toFiniteNumber(range === null || range === void 0 ? void 0 : range.start, null);
75
- var end = toFiniteNumber(range === null || range === void 0 ? void 0 : range.end, null);
76
- if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start + EPSILON) {
77
- return [];
78
- }
79
- if (!Array.isArray(cuts) || cuts.length === 0) {
80
- return [{
81
- start: start,
82
- end: end
83
- }];
84
- }
85
- var mergedCuts = mergeIntervals(cuts);
86
- var kept = [];
87
- var cursor = start;
88
- var _iterator = _createForOfIteratorHelper(mergedCuts),
89
- _step;
90
- try {
91
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
- var cut = _step.value;
93
- if (cut.end <= cursor + EPSILON) {
94
- continue;
95
- }
96
- if (cut.start >= end - EPSILON) {
97
- break;
98
- }
99
- if (cut.start > cursor + EPSILON) {
100
- kept.push({
101
- start: cursor,
102
- end: Math.min(cut.start, end)
103
- });
104
- }
105
- cursor = Math.max(cursor, cut.end);
106
- if (cursor >= end - EPSILON) {
107
- break;
108
- }
109
- }
110
- } catch (err) {
111
- _iterator.e(err);
112
- } finally {
113
- _iterator.f();
114
- }
115
- if (cursor < end - EPSILON) {
116
- kept.push({
117
- start: cursor,
118
- end: end
119
- });
120
- }
121
- return kept.filter(function (interval) {
122
- return interval.end > interval.start + EPSILON;
123
- });
124
- };
125
- var clipIntervalToRange = function clipIntervalToRange(interval, rangeStart, rangeEnd) {
126
- var start = Math.max(interval.start, rangeStart);
127
- var end = Math.min(interval.end, rangeEnd);
128
- return buildInterval(start, end);
129
- };
130
- var mapTimeAfterCuts = function mapTimeAfterCuts(time) {
131
- var cuts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
132
- var normalizedTime = toFiniteNumber(time, null);
133
- if (!Number.isFinite(normalizedTime)) {
134
- return 0;
135
- }
136
- if (!Array.isArray(cuts) || cuts.length === 0) {
137
- return normalizedTime;
138
- }
139
- var removedDuration = 0;
140
- var _iterator2 = _createForOfIteratorHelper(cuts),
141
- _step2;
142
- try {
143
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
144
- var cut = _step2.value;
145
- if (cut.start >= normalizedTime) {
146
- break;
147
- }
148
- removedDuration += Math.max(0, Math.min(normalizedTime, cut.end) - cut.start);
149
- }
150
- } catch (err) {
151
- _iterator2.e(err);
152
- } finally {
153
- _iterator2.f();
154
- }
155
- return Math.max(0, normalizedTime - removedDuration);
156
- };
157
- var isCaptionEffect = function isCaptionEffect(effect) {
158
- return typeof (effect === null || effect === void 0 ? void 0 : effect.type) === "string" && effect.type.includes("caption");
159
- };
160
- var getSegmentTiming = function getSegmentTiming(segment) {
161
- var _segment$layout, _segment$layout$data, _segment$layout2, _segment$layout2$data, _segment$layout3, _segment$layout3$data;
162
- var duration = Math.max(0, toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$layout = segment.layout) === null || _segment$layout === void 0 ? void 0 : (_segment$layout$data = _segment$layout.data) === null || _segment$layout$data === void 0 ? void 0 : _segment$layout$data.duration, 0));
163
- var trimLeft = Math.max(0, toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$layout2 = segment.layout) === null || _segment$layout2 === void 0 ? void 0 : (_segment$layout2$data = _segment$layout2.data) === null || _segment$layout2$data === void 0 ? void 0 : _segment$layout2$data.trimLeft, 0));
164
- var trimRight = Math.max(0, toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$layout3 = segment.layout) === null || _segment$layout3 === void 0 ? void 0 : (_segment$layout3$data = _segment$layout3.data) === null || _segment$layout3$data === void 0 ? void 0 : _segment$layout3$data.trimRight, 0));
165
- var playableStart = trimLeft;
166
- var playableEnd = Math.max(playableStart, duration - trimRight);
167
- var playableDuration = Math.max(0, playableEnd - playableStart);
168
- return {
169
- duration: duration,
170
- trimLeft: trimLeft,
171
- trimRight: trimRight,
172
- playableStart: playableStart,
173
- playableEnd: playableEnd,
174
- playableDuration: playableDuration
175
- };
176
- };
177
- var collectDisabledTranscriptIntervals = function collectDisabledTranscriptIntervals() {
178
- var transcripts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
179
- if (!Array.isArray(transcripts)) {
180
- return [];
181
- }
182
- var intervals = [];
183
- transcripts.forEach(function (transcript) {
184
- if (!isDisabled(transcript === null || transcript === void 0 ? void 0 : transcript.disabled)) {
185
- return;
186
- }
187
- var offset = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.offset, null);
188
- var duration = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.duration, null);
189
- if (!Number.isFinite(offset) || !Number.isFinite(duration) || duration <= EPSILON) {
190
- return;
191
- }
192
- intervals.push({
193
- start: offset,
194
- end: offset + duration
195
- });
196
- });
197
- return mergeIntervals(intervals);
198
- };
199
- var collectSegmentDisabledIntervals = function collectSegmentDisabledIntervals(segment, timing) {
200
- var effects = Array.isArray(segment === null || segment === void 0 ? void 0 : segment.effects) ? segment.effects : [];
201
- var cuts = [];
202
- effects.forEach(function (effect) {
203
- var _effect$data;
204
- if (!isCaptionEffect(effect)) {
205
- return;
206
- }
207
- var intervals = collectDisabledTranscriptIntervals((effect === null || effect === void 0 ? void 0 : (_effect$data = effect.data) === null || _effect$data === void 0 ? void 0 : _effect$data.transcript_text) || []);
208
- intervals.forEach(function (interval) {
209
- var clipped = clipIntervalToRange(interval, timing.playableStart, timing.playableEnd);
210
- if (clipped) {
211
- cuts.push(clipped);
212
- }
213
- });
214
- });
215
- return mergeIntervals(cuts);
216
- };
217
- var collectGlobalDisabledIntervals = function collectGlobalDisabledIntervals(screenplay) {
218
- var _screenplay$tracks, _screenplay$tracks2;
219
- var allIntervals = [];
220
- var segmentTrack = screenplay === null || screenplay === void 0 ? void 0 : (_screenplay$tracks = screenplay.tracks) === null || _screenplay$tracks === void 0 ? void 0 : _screenplay$tracks.find(function (track) {
221
- return track.type === "segment";
222
- });
223
- var captionTrack = screenplay === null || screenplay === void 0 ? void 0 : (_screenplay$tracks2 = screenplay.tracks) === null || _screenplay$tracks2 === void 0 ? void 0 : _screenplay$tracks2.find(function (track) {
224
- return track.type === "caption";
225
- });
226
- var segmentTimelineCursor = 0;
227
- if (Array.isArray(segmentTrack === null || segmentTrack === void 0 ? void 0 : segmentTrack.segments)) {
228
- segmentTrack.segments.forEach(function (segment) {
229
- var timing = getSegmentTiming(segment);
230
- var localCuts = collectSegmentDisabledIntervals(segment, timing);
231
- localCuts.forEach(function (cut) {
232
- var start = segmentTimelineCursor + (cut.start - timing.trimLeft);
233
- var end = segmentTimelineCursor + (cut.end - timing.trimLeft);
234
- var absolute = buildInterval(start, end);
235
- if (absolute) {
236
- allIntervals.push(absolute);
237
- }
238
- });
239
- segmentTimelineCursor += timing.playableDuration;
240
- });
241
- }
242
- if (Array.isArray(captionTrack === null || captionTrack === void 0 ? void 0 : captionTrack.segments)) {
243
- captionTrack.segments.forEach(function (segment) {
244
- var _segment$data, _segment$data2;
245
- var segmentOffset = toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$data = segment.data) === null || _segment$data === void 0 ? void 0 : _segment$data.offset, 0);
246
- var intervals = collectDisabledTranscriptIntervals((segment === null || segment === void 0 ? void 0 : (_segment$data2 = segment.data) === null || _segment$data2 === void 0 ? void 0 : _segment$data2.transcript_text) || []);
247
- intervals.forEach(function (interval) {
248
- var absolute = buildInterval(segmentOffset + interval.start, segmentOffset + interval.end);
249
- if (absolute) {
250
- allIntervals.push(absolute);
251
- }
252
- });
253
- });
254
- }
255
- return mergeIntervals(allIntervals);
256
- };
257
- var normalizeTextAndPunctuations = function normalizeTextAndPunctuations(text) {
258
- var punctuations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
259
- if (!Array.isArray(punctuations) || punctuations.length === 0) {
260
- return {
261
- text: text,
262
- punctuations: []
263
- };
264
- }
265
- if (typeof text !== "string") {
266
- return {
267
- text: text,
268
- punctuations: punctuations
269
- };
270
- }
271
- var words = text.split(" ");
272
- if (words.length === 0) {
273
- return {
274
- text: text,
275
- punctuations: punctuations
276
- };
277
- }
278
- var wordIndexOrder = [];
279
- var seen = new Set();
280
- punctuations.forEach(function (punctuation) {
281
- var index = toFiniteNumber(punctuation === null || punctuation === void 0 ? void 0 : punctuation.index, null);
282
- if (!Number.isInteger(index)) {
283
- return;
284
- }
285
- if (index < 0 || index >= words.length) {
286
- return;
287
- }
288
- if (!seen.has(index)) {
289
- seen.add(index);
290
- wordIndexOrder.push(index);
291
- }
292
- });
293
- if (wordIndexOrder.length === 0) {
294
- return {
295
- text: text,
296
- punctuations: []
297
- };
298
- }
299
- var filteredWords = wordIndexOrder.map(function (wordIndex) {
300
- return words[wordIndex];
301
- }).filter(function (word) {
302
- return word !== undefined;
303
- });
304
- if (filteredWords.length === 0) {
305
- return {
306
- text: text,
307
- punctuations: []
308
- };
309
- }
310
- var indexMap = new Map(wordIndexOrder.map(function (wordIndex, mappedIndex) {
311
- return [wordIndex, mappedIndex];
312
- }));
313
- var normalizedPunctuations = punctuations.filter(function (punctuation) {
314
- return indexMap.has(toFiniteNumber(punctuation === null || punctuation === void 0 ? void 0 : punctuation.index, null));
315
- }).map(function (punctuation) {
316
- return _objectSpread(_objectSpread({}, punctuation), {}, {
317
- index: indexMap.get(toFiniteNumber(punctuation === null || punctuation === void 0 ? void 0 : punctuation.index, null))
318
- });
319
- });
320
- return {
321
- text: filteredWords.join(" "),
322
- punctuations: normalizedPunctuations
323
- };
324
- };
325
- var clipTranscriptToRange = function clipTranscriptToRange(_ref) {
326
- var transcript = _ref.transcript,
327
- rangeStart = _ref.rangeStart,
328
- rangeEnd = _ref.rangeEnd,
329
- offsetMode = _ref.offsetMode,
330
- _ref$offsetBase = _ref.offsetBase,
331
- offsetBase = _ref$offsetBase === void 0 ? 0 : _ref$offsetBase,
332
- _ref$stripDisabled = _ref.stripDisabled,
333
- stripDisabled = _ref$stripDisabled === void 0 ? false : _ref$stripDisabled;
334
- if (!transcript) {
335
- return null;
336
- }
337
- if (stripDisabled && isDisabled(transcript === null || transcript === void 0 ? void 0 : transcript.disabled)) {
338
- return null;
339
- }
340
- var transcriptStart = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.offset, null);
341
- var transcriptDuration = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.duration, null);
342
- if (!Number.isFinite(transcriptStart) || !Number.isFinite(transcriptDuration) || transcriptDuration <= EPSILON) {
343
- return null;
344
- }
345
- var transcriptEnd = transcriptStart + transcriptDuration;
346
- var overlapStart = Math.max(transcriptStart, rangeStart);
347
- var overlapEnd = Math.min(transcriptEnd, rangeEnd);
348
- if (overlapEnd <= overlapStart + EPSILON) {
349
- return null;
350
- }
351
- var clonedTranscript = cloneValue(transcript);
352
- var mapOffset = function mapOffset(value) {
353
- return offsetMode === "relative" ? value - offsetBase : value;
354
- };
355
- clonedTranscript.offset = mapOffset(overlapStart);
356
- clonedTranscript.duration = overlapEnd - overlapStart;
357
- var punctuations = Array.isArray(transcript === null || transcript === void 0 ? void 0 : transcript.punctuations) ? transcript.punctuations : [];
358
- var clippedPunctuations = punctuations.map(function (punctuation) {
359
- var punctuationStart = toFiniteNumber(punctuation === null || punctuation === void 0 ? void 0 : punctuation.start, null);
360
- var punctuationEnd = toFiniteNumber(punctuation === null || punctuation === void 0 ? void 0 : punctuation.end, null);
361
- if (!Number.isFinite(punctuationStart) || !Number.isFinite(punctuationEnd) || punctuationEnd <= punctuationStart + EPSILON) {
362
- return null;
363
- }
364
- var clippedStart = Math.max(punctuationStart, overlapStart);
365
- var clippedEnd = Math.min(punctuationEnd, overlapEnd);
366
- if (clippedEnd <= clippedStart + EPSILON) {
367
- return null;
368
- }
369
- return _objectSpread(_objectSpread({}, punctuation), {}, {
370
- start: mapOffset(clippedStart),
371
- end: mapOffset(clippedEnd)
372
- });
373
- }).filter(Boolean);
374
- var wasClipped = overlapStart > transcriptStart + EPSILON || overlapEnd < transcriptEnd - EPSILON;
375
- if (wasClipped && clippedPunctuations.length > 0) {
376
- var _normalizeTextAndPunc = normalizeTextAndPunctuations(transcript === null || transcript === void 0 ? void 0 : transcript.text, clippedPunctuations),
377
- text = _normalizeTextAndPunc.text,
378
- normalizedPunctuations = _normalizeTextAndPunc.punctuations;
379
- clonedTranscript.text = text;
380
- clonedTranscript.punctuations = normalizedPunctuations;
381
- } else {
382
- clonedTranscript.text = transcript === null || transcript === void 0 ? void 0 : transcript.text;
383
- clonedTranscript.punctuations = clippedPunctuations;
384
- }
385
- return clonedTranscript;
386
- };
387
- var normalizeTranscriptsForRange = function normalizeTranscriptsForRange(_ref2) {
388
- var transcripts = _ref2.transcripts,
389
- rangeStart = _ref2.rangeStart,
390
- rangeEnd = _ref2.rangeEnd,
391
- offsetMode = _ref2.offsetMode,
392
- offsetBase = _ref2.offsetBase,
393
- stripDisabled = _ref2.stripDisabled;
394
- if (!Array.isArray(transcripts)) {
395
- return [];
396
- }
397
- return transcripts.map(function (transcript) {
398
- return clipTranscriptToRange({
399
- transcript: transcript,
400
- rangeStart: rangeStart,
401
- rangeEnd: rangeEnd,
402
- offsetMode: offsetMode,
403
- offsetBase: offsetBase,
404
- stripDisabled: stripDisabled
405
- });
406
- }).filter(Boolean);
407
- };
408
- var normalizeSegmentTrack = function normalizeSegmentTrack(segmentTrack, globalCuts) {
409
- if (!segmentTrack || !Array.isArray(segmentTrack === null || segmentTrack === void 0 ? void 0 : segmentTrack.segments)) {
410
- return segmentTrack;
411
- }
412
- var normalizedSegments = [];
413
- var timelineCursor = 0;
414
- segmentTrack.segments.forEach(function (segment, segmentIndex) {
415
- var _segment$layout4;
416
- var timing = getSegmentTiming(segment);
417
- var duration = timing.duration,
418
- playableStart = timing.playableStart,
419
- playableEnd = timing.playableEnd,
420
- playableDuration = timing.playableDuration,
421
- trimLeft = timing.trimLeft;
422
- var isRemoved = (segment === null || segment === void 0 ? void 0 : (_segment$layout4 = segment.layout) === null || _segment$layout4 === void 0 ? void 0 : _segment$layout4.removed) === true;
423
- if (isRemoved || playableDuration <= EPSILON) {
424
- var untouched = cloneValue(segment);
425
- untouched.__transitionAfter = true;
426
- untouched.__originSegmentIndex = segmentIndex;
427
- normalizedSegments.push(untouched);
428
- timelineCursor += playableDuration;
429
- return;
430
- }
431
- var localCuts = [];
432
- var segmentAbsoluteStart = timelineCursor;
433
- var segmentAbsoluteEnd = segmentAbsoluteStart + playableDuration;
434
- globalCuts.forEach(function (globalCut) {
435
- if (globalCut.end <= segmentAbsoluteStart + EPSILON) {
436
- return;
437
- }
438
- if (globalCut.start >= segmentAbsoluteEnd - EPSILON) {
439
- return;
440
- }
441
- var overlapStart = Math.max(globalCut.start, segmentAbsoluteStart);
442
- var overlapEnd = Math.min(globalCut.end, segmentAbsoluteEnd);
443
- if (overlapEnd <= overlapStart + EPSILON) {
444
- return;
445
- }
446
- var localStart = trimLeft + (overlapStart - segmentAbsoluteStart);
447
- var localEnd = trimLeft + (overlapEnd - segmentAbsoluteStart);
448
- var localInterval = buildInterval(localStart, localEnd);
449
- if (localInterval) {
450
- localCuts.push(localInterval);
451
- }
452
- });
453
- var mergedLocalCuts = mergeIntervals(localCuts);
454
- var keptRanges = subtractIntervals({
455
- start: playableStart,
456
- end: playableEnd
457
- }, mergedLocalCuts);
458
- if (keptRanges.length === 0) {
459
- timelineCursor += playableDuration;
460
- return;
461
- }
462
- keptRanges.forEach(function (keptRange, chunkIndex) {
463
- var chunkDuration = keptRange.end - keptRange.start;
464
- if (!isMeaningfulDuration(chunkDuration)) {
465
- return;
466
- }
467
- var clonedChunk = cloneValue(segment);
468
- clonedChunk.layout.data.trimLeft = keptRange.start;
469
- clonedChunk.layout.data.trimRight = Math.max(0, duration - keptRange.end);
470
- clonedChunk.__transitionAfter = chunkIndex === keptRanges.length - 1;
471
- clonedChunk.__originSegmentIndex = segmentIndex;
472
- if (Array.isArray(clonedChunk.effects)) {
473
- clonedChunk.effects = clonedChunk.effects.map(function (effect) {
474
- var _effect$data2;
475
- if (!isCaptionEffect(effect)) {
476
- return effect;
477
- }
478
- var normalizedEffect = cloneValue(effect);
479
- normalizedEffect.data = normalizedEffect.data || {};
480
- normalizedEffect.data.transcript_text = normalizeTranscriptsForRange({
481
- transcripts: (effect === null || effect === void 0 ? void 0 : (_effect$data2 = effect.data) === null || _effect$data2 === void 0 ? void 0 : _effect$data2.transcript_text) || [],
482
- rangeStart: keptRange.start,
483
- rangeEnd: keptRange.end,
484
- offsetMode: "absolute",
485
- offsetBase: keptRange.start,
486
- stripDisabled: true
487
- });
488
- return normalizedEffect;
489
- });
490
- }
491
- normalizedSegments.push(clonedChunk);
492
- });
493
- timelineCursor += playableDuration;
494
- });
495
- return _objectSpread(_objectSpread({}, segmentTrack), {}, {
496
- segments: normalizedSegments
497
- });
498
- };
499
- var resolveSegmentDuration = function resolveSegmentDuration(segment, trackType) {
500
- var _segment$data3, _segment$data4;
501
- var explicitDuration = toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$data3 = segment.data) === null || _segment$data3 === void 0 ? void 0 : _segment$data3.duration, null);
502
- if (Number.isFinite(explicitDuration) && explicitDuration > EPSILON) {
503
- return explicitDuration;
504
- }
505
- if (trackType !== "caption") {
506
- return null;
507
- }
508
- var transcripts = Array.isArray(segment === null || segment === void 0 ? void 0 : (_segment$data4 = segment.data) === null || _segment$data4 === void 0 ? void 0 : _segment$data4.transcript_text) ? segment.data.transcript_text : [];
509
- var maxEnd = transcripts.reduce(function (currentMax, transcript) {
510
- var offset = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.offset, null);
511
- var duration = toFiniteNumber(transcript === null || transcript === void 0 ? void 0 : transcript.duration, null);
512
- if (!Number.isFinite(offset) || !Number.isFinite(duration) || duration <= EPSILON) {
513
- return currentMax;
514
- }
515
- return Math.max(currentMax, offset + duration);
516
- }, 0);
517
- return maxEnd > EPSILON ? maxEnd : null;
518
- };
519
- var shiftSourceMediaStart = function shiftSourceMediaStart(segment, deltaInSeconds) {
520
- var _segment$data5, _segment$data5$source, _segment$data6, _segment$data6$source;
521
- if (!(segment !== null && segment !== void 0 && segment.data) || !Number.isFinite(deltaInSeconds) || deltaInSeconds === 0) {
522
- return;
523
- }
524
- var sourceVideoStart = toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$data5 = segment.data) === null || _segment$data5 === void 0 ? void 0 : (_segment$data5$source = _segment$data5.sourceVideo) === null || _segment$data5$source === void 0 ? void 0 : _segment$data5$source.start, null);
525
- if (Number.isFinite(sourceVideoStart)) {
526
- segment.data.sourceVideo.start = Math.max(0, sourceVideoStart + deltaInSeconds);
527
- }
528
- var sourceAudioStart = toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$data6 = segment.data) === null || _segment$data6 === void 0 ? void 0 : (_segment$data6$source = _segment$data6.sourceAudio) === null || _segment$data6$source === void 0 ? void 0 : _segment$data6$source.start, null);
529
- if (Number.isFinite(sourceAudioStart)) {
530
- segment.data.sourceAudio.start = Math.max(0, sourceAudioStart + deltaInSeconds);
531
- }
532
- };
533
- var normalizeTimedTrack = function normalizeTimedTrack(track, globalCuts, trackType) {
534
- if (!track || !Array.isArray(track === null || track === void 0 ? void 0 : track.segments)) {
535
- return track;
536
- }
537
- var normalizedSegments = [];
538
- track.segments.forEach(function (segment) {
539
- var _segment$data7;
540
- var segmentStart = toFiniteNumber(segment === null || segment === void 0 ? void 0 : (_segment$data7 = segment.data) === null || _segment$data7 === void 0 ? void 0 : _segment$data7.offset, 0);
541
- var segmentDuration = resolveSegmentDuration(segment, trackType);
542
- if (!Number.isFinite(segmentDuration) || segmentDuration <= EPSILON) {
543
- var shiftedSegment = cloneValue(segment);
544
- shiftedSegment.data = shiftedSegment.data || {};
545
- shiftedSegment.data.offset = mapTimeAfterCuts(segmentStart, globalCuts);
546
- if (trackType === "caption") {
547
- var _segment$data8;
548
- shiftedSegment.data.transcript_text = normalizeTranscriptsForRange({
549
- transcripts: (segment === null || segment === void 0 ? void 0 : (_segment$data8 = segment.data) === null || _segment$data8 === void 0 ? void 0 : _segment$data8.transcript_text) || [],
550
- rangeStart: 0,
551
- rangeEnd: Number.POSITIVE_INFINITY,
552
- offsetMode: "relative",
553
- offsetBase: 0,
554
- stripDisabled: true
555
- });
556
- if (shiftedSegment.data.transcript_text.length === 0) {
557
- return;
558
- }
559
- }
560
- normalizedSegments.push(shiftedSegment);
561
- return;
562
- }
563
- var segmentEnd = segmentStart + segmentDuration;
564
- var keptRanges = subtractIntervals({
565
- start: segmentStart,
566
- end: segmentEnd
567
- }, globalCuts);
568
- keptRanges.forEach(function (keptRange) {
569
- var chunkDuration = keptRange.end - keptRange.start;
570
- if (!isMeaningfulDuration(chunkDuration)) {
571
- return;
572
- }
573
- var clonedChunk = cloneValue(segment);
574
- clonedChunk.data = clonedChunk.data || {};
575
- clonedChunk.data.offset = mapTimeAfterCuts(keptRange.start, globalCuts);
576
- clonedChunk.data.duration = chunkDuration;
577
- var sourceTimeDelta = keptRange.start - segmentStart;
578
- shiftSourceMediaStart(clonedChunk, sourceTimeDelta);
579
- if (trackType === "caption") {
580
- var _segment$data9;
581
- var localStart = keptRange.start - segmentStart;
582
- var localEnd = keptRange.end - segmentStart;
583
- clonedChunk.data.transcript_text = normalizeTranscriptsForRange({
584
- transcripts: (segment === null || segment === void 0 ? void 0 : (_segment$data9 = segment.data) === null || _segment$data9 === void 0 ? void 0 : _segment$data9.transcript_text) || [],
585
- rangeStart: localStart,
586
- rangeEnd: localEnd,
587
- offsetMode: "relative",
588
- offsetBase: localStart,
589
- stripDisabled: true
590
- });
591
- if (clonedChunk.data.transcript_text.length === 0) {
592
- return;
593
- }
594
- }
595
- normalizedSegments.push(clonedChunk);
596
- });
597
- });
598
- return _objectSpread(_objectSpread({}, track), {}, {
599
- segments: normalizedSegments
600
- });
601
- };
602
- export var normalizeDisabledTranscripts = function normalizeDisabledTranscripts(screenplayInput) {
603
- var screenplay = cloneValue(screenplayInput) || {};
604
- if (!Array.isArray(screenplay === null || screenplay === void 0 ? void 0 : screenplay.tracks)) {
605
- return screenplay;
606
- }
607
- var globalDisabledIntervals = collectGlobalDisabledIntervals(screenplay);
608
- if (globalDisabledIntervals.length === 0) {
609
- return screenplay;
610
- }
611
- screenplay.tracks = screenplay.tracks.map(function (track) {
612
- if (!track || !Array.isArray(track === null || track === void 0 ? void 0 : track.segments)) {
613
- return track;
614
- }
615
- switch (track.type) {
616
- case "segment":
617
- return normalizeSegmentTrack(track, globalDisabledIntervals);
618
- case "effect":
619
- return normalizeTimedTrack(track, globalDisabledIntervals, "effect");
620
- case "audio":
621
- return normalizeTimedTrack(track, globalDisabledIntervals, "audio");
622
- case "caption":
623
- return normalizeTimedTrack(track, globalDisabledIntervals, "caption");
624
- default:
625
- return track;
626
- }
627
- });
628
- return screenplay;
629
- };
1
+ import timing from "../../../timing.cjs";
2
+ var normalizeDisabledTranscripts = timing.normalizeDisabledTranscripts;
3
+ export { normalizeDisabledTranscripts };
@@ -1,7 +1,4 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
2
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
6
3
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
4
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -31,19 +28,7 @@ export var LayoutFactory = /*#__PURE__*/function () {
31
28
  return _createClass(LayoutFactory, null, [{
32
29
  key: "createObject",
33
30
  value: function createObject(props) {
34
- var _props$data;
35
31
  var layout;
36
- var sourceVideo = (_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.sourceVideo;
37
- var proxyVideoUrl = sourceVideo === null || sourceVideo === void 0 ? void 0 : sourceVideo.proxyVideoUrl;
38
- if (typeof proxyVideoUrl === "string" && proxyVideoUrl.trim() && proxyVideoUrl !== sourceVideo.videoUrl) {
39
- props = _objectSpread(_objectSpread({}, props), {}, {
40
- data: _objectSpread(_objectSpread({}, props.data), {}, {
41
- sourceVideo: _objectSpread(_objectSpread({}, sourceVideo), {}, {
42
- videoUrl: proxyVideoUrl
43
- })
44
- })
45
- });
46
- }
47
32
  switch (props.type) {
48
33
  case "text_with_video":
49
34
  {