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