@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
@@ -0,0 +1,112 @@
1
+ import timing from "../../../timing.cjs";
2
+ import { toFrames } from "../main/lib/Sequence.js";
3
+ export var WORD_OBJECT_ASSET_IDS = Object.freeze(["plane", "clock", "light_bulb", "money", "rocket", "target", "phone", "computer", "book", "key", "globe", "chart"]);
4
+ export var WORD_OBJECT_CAPTION_TYPES = Object.freeze(["caption_word_boom", "caption_punctuated", "caption_word_bubble"]);
5
+ export var isEnabledWordObject = function isEnabledWordObject(object) {
6
+ return !!object && object.disabled !== true && (object.disabled === undefined || object.disabled === false) && WORD_OBJECT_ASSET_IDS.includes(object.assetId) && object.preset === "emerge_v1" && Number.isFinite(object.duration) && object.duration >= 1.5 && object.duration <= 2.6;
7
+ };
8
+
9
+ // Operates on the renderer's private normalized screenplay, never on saved input.
10
+ export var prepareCaptionWordObjects = function prepareCaptionWordObjects(screenplay, fps) {
11
+ var _screenplay$tracks, _screenplay$tracks$fi;
12
+ var stats = {
13
+ selected: 0,
14
+ disabled: 0,
15
+ suppressed: 0
16
+ };
17
+ // Standalone captions have no speaker layout/segment boundary to validate.
18
+ // Preserve their captions and metadata, but never accept saved private approval.
19
+ (screenplay.tracks || []).filter(function (track) {
20
+ return track.type === "caption";
21
+ }).forEach(function (track) {
22
+ (track.segments || []).forEach(function (caption) {
23
+ var _caption$data;
24
+ (((_caption$data = caption.data) === null || _caption$data === void 0 ? void 0 : _caption$data.transcript_text) || []).forEach(function (transcript) {
25
+ (transcript.punctuations || []).forEach(function (p) {
26
+ delete p.__wordObjectDurationInFrames;
27
+ if (!p.wordObject) return;
28
+ var disabled = p.wordObject.disabled === true;
29
+ p.__wordObjectSuppressed = disabled ? "disabled" : "ineligible";
30
+ stats[disabled ? "disabled" : "suppressed"]++;
31
+ });
32
+ });
33
+ });
34
+ });
35
+ var segments = ((_screenplay$tracks = screenplay.tracks) === null || _screenplay$tracks === void 0 ? void 0 : (_screenplay$tracks$fi = _screenplay$tracks.find(function (track) {
36
+ return track.type === "segment";
37
+ })) === null || _screenplay$tracks$fi === void 0 ? void 0 : _screenplay$tracks$fi.segments) || [];
38
+ var candidates = [];
39
+ var _timing$getScreenplay = timing.getScreenplayTiming(screenplay, {
40
+ prepared: true
41
+ }),
42
+ sequences = _timing$getScreenplay.sequences;
43
+ segments.forEach(function (segment, segmentIndex) {
44
+ var _layout$data, _layout$data2;
45
+ var cursor = sequences[segmentIndex].startFrame;
46
+ var layout = segment.layout,
47
+ _segment$effects = segment.effects,
48
+ effects = _segment$effects === void 0 ? [] : _segment$effects;
49
+ if (layout !== null && layout !== void 0 && layout.removed) return;
50
+ var _ref = (layout === null || layout === void 0 ? void 0 : layout.data) || {},
51
+ _ref$duration = _ref.duration,
52
+ duration = _ref$duration === void 0 ? 0 : _ref$duration,
53
+ _ref$trimLeft = _ref.trimLeft,
54
+ trimLeft = _ref$trimLeft === void 0 ? 0 : _ref$trimLeft,
55
+ _ref$trimRight = _ref.trimRight,
56
+ trimRight = _ref$trimRight === void 0 ? 0 : _ref$trimRight;
57
+ var durationInFrames = toFrames(fps * (duration - trimLeft - trimRight));
58
+ var supportedLayout = ["simple_frame", "simple_frame_zoom_cut"].includes(layout === null || layout === void 0 ? void 0 : layout.type) && !(layout !== null && layout !== void 0 && (_layout$data = layout.data) !== null && _layout$data !== void 0 && _layout$data.sentenceText) && !(layout !== null && layout !== void 0 && (_layout$data2 = layout.data) !== null && _layout$data2 !== void 0 && _layout$data2.brollUrl);
59
+ effects.filter(function (effect) {
60
+ var _effect$type;
61
+ return (_effect$type = effect.type) === null || _effect$type === void 0 ? void 0 : _effect$type.includes("caption");
62
+ }).forEach(function (effect) {
63
+ var _effect$data;
64
+ (((_effect$data = effect.data) === null || _effect$data === void 0 ? void 0 : _effect$data.transcript_text) || []).forEach(function (transcript) {
65
+ var words = typeof transcript.text === "string" ? transcript.text.split(" ") : [];
66
+ (transcript.punctuations || []).forEach(function (p) {
67
+ var _effect$data2, _screenplay$output;
68
+ if (!p.wordObject) return;
69
+ delete p.__wordObjectSuppressed;
70
+ delete p.__wordObjectDurationInFrames;
71
+ var localStart = toFrames(fps * (p.start - trimLeft));
72
+ var effectFrom = Number.isFinite(Number((_effect$data2 = effect.data) === null || _effect$data2 === void 0 ? void 0 : _effect$data2.offset)) ? fps * (Number(effect.data.offset) + trimLeft) : 0;
73
+ var at = localStart + effectFrom;
74
+ var available = durationInFrames - at;
75
+ if (p.wordObject.disabled === true) {
76
+ p.__wordObjectSuppressed = "disabled";
77
+ stats.disabled++;
78
+ return;
79
+ }
80
+ if (!supportedLayout || !["portrait", "square"].includes((_screenplay$output = screenplay.output) === null || _screenplay$output === void 0 ? void 0 : _screenplay$output.orientation) || !WORD_OBJECT_CAPTION_TYPES.includes(effect.type) || transcript.disabled === true || p.__wordObjectOnsetClipped || !Number.isFinite(p.start) || !Number.isFinite(p.end) || p.end <= p.start || p.start < trimLeft || !Number.isInteger(p.index) || !words[p.index] || !isEnabledWordObject(p.wordObject) || !Number.isFinite(at) || at < 0 || available < Math.ceil(1.5 * fps)) {
81
+ p.__wordObjectSuppressed = "ineligible";
82
+ stats.suppressed++;
83
+ return;
84
+ }
85
+ candidates.push({
86
+ p: p,
87
+ at: cursor + at,
88
+ durationInFrames: Math.min(Math.round(p.wordObject.duration * fps), available)
89
+ });
90
+ });
91
+ });
92
+ });
93
+ });
94
+ candidates.sort(function (a, b) {
95
+ return a.at - b.at;
96
+ });
97
+ var lastStart = -Infinity;
98
+ candidates.forEach(function (_ref2) {
99
+ var p = _ref2.p,
100
+ at = _ref2.at,
101
+ durationInFrames = _ref2.durationInFrames;
102
+ if (at - lastStart < 15 * fps) {
103
+ p.__wordObjectSuppressed = "cooldown";
104
+ stats.suppressed++;
105
+ return;
106
+ }
107
+ p.__wordObjectDurationInFrames = durationInFrames;
108
+ stats.selected++;
109
+ lastStart = at;
110
+ });
111
+ return stats;
112
+ };
@@ -0,0 +1,12 @@
1
+ // Screenplay overrides are optional. Invalid values never become arbitrary CSS.
2
+ export var getHeadingColors = function getHeadingColors() {
3
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
+ var result = {};
5
+ for (var _i = 0, _arr = ["headingTextColor", "headingBackgroundColor"]; _i < _arr.length; _i++) {
6
+ var key = _arr[_i];
7
+ if (typeof props[key] === "string" && /^#[a-f\d]{3}([a-f\d]{3})?$/i.test(props[key])) {
8
+ result[key] = props[key];
9
+ }
10
+ }
11
+ return result;
12
+ };