@zync/zync-screnplay-player 0.1.251 → 0.1.253

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 (32) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/bundle.js.LICENSE.txt +24 -0
  3. package/dist/screenplay/RemotionRenderer/RemotionRenderer.js +51 -42
  4. package/dist/screenplay/RemotionRenderer/assets/wordObjects/LICENSE +21 -0
  5. package/dist/screenplay/RemotionRenderer/assets/wordObjects/emojiCatalog.json +1 -0
  6. package/dist/screenplay/RemotionRenderer/assets/wordObjects/images.js +24 -0
  7. package/dist/screenplay/RemotionRenderer/assets/wordObjects/manifest.json +67 -0
  8. package/dist/screenplay/RemotionRenderer/components/effects/CaptionWordObjectOverlay.js +275 -0
  9. package/dist/screenplay/RemotionRenderer/components/effects/Sentence.js +10 -3
  10. package/dist/screenplay/RemotionRenderer/components/layouts/Keyword.js +7 -9
  11. package/dist/screenplay/RemotionRenderer/components/layouts/KeywordStudioBackdrop.js +5 -7
  12. package/dist/screenplay/RemotionRenderer/components/layouts/SimpleFrameSentence.js +3 -1
  13. package/dist/screenplay/RemotionRenderer/components/utils/FaceCenteredVideo.js +9 -0
  14. package/dist/screenplay/RemotionRenderer/helpers/captionWordObjectGeometry.js +143 -0
  15. package/dist/screenplay/RemotionRenderer/helpers/captionWordObjects.js +143 -0
  16. package/dist/screenplay/RemotionRenderer/helpers/emojiCatalog.js +17 -0
  17. package/dist/screenplay/RemotionRenderer/helpers/headingColors.js +12 -0
  18. package/dist/screenplay/RemotionRenderer/helpers/loadWordObjectArtwork.js +56 -0
  19. package/dist/screenplay/RemotionRenderer/helpers/normalizeDisabledTranscripts.js +3 -629
  20. package/dist/screenplay/RemotionRenderer/main/lib/layouts/LayoutFactory.js +0 -15
  21. package/dist/screenplay/RemotionRenderer/main/lib/layouts/SimpleFrameLayout.js +8 -3
  22. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionPunctuated.js +29 -6
  23. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBoom.js +42 -47
  24. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBubble.js +30 -7
  25. package/dist/screenplay/RemotionRenderer/theme/themes/default/Sentence/AnimatedSentence.js +1 -0
  26. package/dist/screenplay/RemotionRenderer/theme/themes/default/Sentence.js +8 -4
  27. package/dist/screenplay/RemotionRenderer/theme/themes/fullcover/TextFullCover.js +10 -5
  28. package/dist/screenplay/RemotionRenderer/theme/themes/glassmorphism/Sentence.js +14 -4
  29. package/dist/screenplay/RemotionRenderer/tracks/LayoutVideoTrack.js +1 -1
  30. package/dist/screenplay/RemotionRenderer/tracks/Soundtrack.js +20 -3
  31. package/dist/timing.cjs +1050 -0
  32. package/package.json +8 -4
@@ -0,0 +1,67 @@
1
+ {
2
+ "upstream": "https://github.com/microsoft/fluentui-emoji",
3
+ "commit": "1ffb34c752ecf5d402f04cfb4b392c77f57c54bc",
4
+ "license": "MIT",
5
+ "assets": {
6
+ "plane": {
7
+ "sourcePath": "assets/Airplane/3D/airplane_3d.png",
8
+ "sha256": "dda8d8e9ccaca71973f4ee75fcab085dcffbb89f3987a9d2cc5401f186268fa1",
9
+ "bytes": 39468
10
+ },
11
+ "clock": {
12
+ "sourcePath": "assets/Alarm clock/3D/alarm_clock_3d.png",
13
+ "sha256": "1aa6929e1baa440db535fd321868dc76ddd888bf3e4f4333d37800ff2ec41c74",
14
+ "bytes": 42751
15
+ },
16
+ "light_bulb": {
17
+ "sourcePath": "assets/Light bulb/3D/light_bulb_3d.png",
18
+ "sha256": "df7b09aa18301507e6fb8c279df66d9afa465b6fed3e63d2efa84dacebdbbf79",
19
+ "bytes": 22450
20
+ },
21
+ "money": {
22
+ "sourcePath": "assets/Money bag/3D/money_bag_3d.png",
23
+ "sha256": "cec19b9cf0beac5bbd27a07dcbe1e68c54b04112b4641165705ccb920f230292",
24
+ "bytes": 34132
25
+ },
26
+ "rocket": {
27
+ "sourcePath": "assets/Rocket/3D/rocket_3d.png",
28
+ "sha256": "4636925a1dfc76a45dc83c08b983699d39143a0978f794a4e2dfb6cbffdcd7ab",
29
+ "bytes": 36274
30
+ },
31
+ "target": {
32
+ "sourcePath": "assets/Bullseye/3D/bullseye_3d.png",
33
+ "sha256": "2b2a2d9eec76c5649b8207b050f9135ce666c9d94694e5577aade50c53768437",
34
+ "bytes": 42883
35
+ },
36
+ "phone": {
37
+ "sourcePath": "assets/Mobile phone/3D/mobile_phone_3d.png",
38
+ "sha256": "c72cf9f888cb74cb8852679184e0dac945ed0340839c98a86c653f51e1e3504d",
39
+ "bytes": 26886
40
+ },
41
+ "computer": {
42
+ "sourcePath": "assets/Laptop/3D/laptop_3d.png",
43
+ "sha256": "3b8a267f6c3d2721af925782bdbc11c4e1bc9ae806c5c875557b100393665aab",
44
+ "bytes": 29028
45
+ },
46
+ "book": {
47
+ "sourcePath": "assets/Books/3D/books_3d.png",
48
+ "sha256": "36f75eaa1e1a849fc950f43962b447c206d96244858468240a6a81beaa97f7be",
49
+ "bytes": 26332
50
+ },
51
+ "key": {
52
+ "sourcePath": "assets/Key/3D/key_3d.png",
53
+ "sha256": "ae59ce2b8dcfaa1afcdfe91bde7cc88cf06a8493686a6676706d1c891bb349eb",
54
+ "bytes": 22458
55
+ },
56
+ "globe": {
57
+ "sourcePath": "assets/Globe showing europe-africa/3D/globe_showing_europe-africa_3d.png",
58
+ "sha256": "a69baec3cc48ed5206d171f5f494e3ab06665277ec4a3acc7e6bf3962ee460ad",
59
+ "bytes": 42555
60
+ },
61
+ "chart": {
62
+ "sourcePath": "assets/Chart increasing/3D/chart_increasing_3d.png",
63
+ "sha256": "dd5e6b29aa4067c5a4d9e152119497832d70e094b380998e5f5b0c51abbb3a64",
64
+ "bytes": 42157
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,275 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ 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; } }
8
+ 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; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ import React from "react";
12
+ import { AbsoluteFill, Img, Sequence, continueRender, delayRender, useCurrentFrame, useCurrentScale, useVideoConfig } from "remotion";
13
+ import { getWordObjectArtwork } from "../../helpers/emojiCatalog.js";
14
+ import { loadWordObjectArtwork } from "../../helpers/loadWordObjectArtwork.js";
15
+ import { isEnabledWordObject } from "../../helpers/captionWordObjects.js";
16
+ import { getWordObjectMotion, placeCaptionWordObject, projectFaceRects } from "../../helpers/captionWordObjectGeometry.js";
17
+ import { cleanFacemetadata } from "../../helpers/cleanFacemetadata.js";
18
+ import { calculateFaceCenteredTranslation } from "../utils/FaceCenteredVideo";
19
+ var WordObject = function WordObject(_ref) {
20
+ var _props$output;
21
+ var event = _ref.event,
22
+ renderSource = _ref.renderSource,
23
+ geometry = _ref.geometry,
24
+ fontFamily = _ref.fontFamily,
25
+ color = _ref.color;
26
+ var frame = useCurrentFrame();
27
+ var _useVideoConfig = useVideoConfig(),
28
+ width = _useVideoConfig.width,
29
+ height = _useVideoConfig.height,
30
+ fps = _useVideoConfig.fps,
31
+ props = _useVideoConfig.props;
32
+ var playerScale = useCurrentScale();
33
+ var lineRef = React.useRef(null);
34
+ var rootRef = React.useRef(null);
35
+ var measurementRootRef = React.useRef(null);
36
+ var _React$useState = React.useState(null),
37
+ _React$useState2 = _slicedToArray(_React$useState, 2),
38
+ measurement = _React$useState2[0],
39
+ setMeasurement = _React$useState2[1];
40
+ var _React$useState3 = React.useState(null),
41
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
42
+ artwork = _React$useState4[0],
43
+ setArtwork = _React$useState4[1];
44
+ var _React$useState5 = React.useState(false),
45
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
46
+ imageFailed = _React$useState6[0],
47
+ setImageFailed = _React$useState6[1];
48
+ var source = event.punctuation.__wordObjectImageUrl || getWordObjectArtwork(event.punctuation.wordObject.assetId);
49
+ React.useEffect(function () {
50
+ var handle = delayRender("Load caption emoji");
51
+ var cancelled = false;
52
+ setArtwork(null);
53
+ setImageFailed(false);
54
+ loadWordObjectArtwork(source).then(function (result) {
55
+ if (!cancelled) setArtwork(result);
56
+ // Allow React to commit the loaded image before releasing this frame.
57
+ requestAnimationFrame(function () {
58
+ return continueRender(handle);
59
+ });
60
+ });
61
+ return function () {
62
+ cancelled = true;
63
+ continueRender(handle);
64
+ };
65
+ }, [source]);
66
+ var orientation = (props === null || props === void 0 ? void 0 : (_props$output = props.output) === null || _props$output === void 0 ? void 0 : _props$output.orientation) || (width === height ? "square" : "portrait");
67
+ React.useEffect(function () {
68
+ var _document$fonts;
69
+ var handle = delayRender("Measure caption word object source");
70
+ var cancelled = false;
71
+ var measure = function measure() {
72
+ var _faceMetadata$metadat, _faceMetadata$metadat2, _faceMetadata$metadat3, _faceMetadata$metadat4;
73
+ if (cancelled) return;
74
+ var line = lineRef.current;
75
+ var word = line === null || line === void 0 ? void 0 : line.querySelector("[data-word-index=\"".concat(event.punctuation.index, "\"]"));
76
+ var root = rootRef.current;
77
+ if (!line || !word || !root) {
78
+ setMeasurement({
79
+ placement: null
80
+ });
81
+ continueRender(handle);
82
+ return;
83
+ }
84
+ var rootRect = root.getBoundingClientRect();
85
+ var convert = function convert(rect) {
86
+ return {
87
+ left: (rect.left - rootRect.left) / playerScale,
88
+ top: (rect.top - rootRect.top) / playerScale,
89
+ right: (rect.right - rootRect.left) / playerScale,
90
+ bottom: (rect.bottom - rootRect.top) / playerScale
91
+ };
92
+ };
93
+ var anchor = convert(word.getBoundingClientRect());
94
+ var faceMetadata = cleanFacemetadata(geometry === null || geometry === void 0 ? void 0 : geometry.faceMetadata);
95
+ var videoProperties = faceMetadata === null || faceMetadata === void 0 ? void 0 : (_faceMetadata$metadat = faceMetadata.metadata) === null || _faceMetadata$metadat === void 0 ? void 0 : _faceMetadata$metadat.videoProperties;
96
+ var rawBoxes = ((faceMetadata === null || faceMetadata === void 0 ? void 0 : (_faceMetadata$metadat2 = faceMetadata.metadata) === null || _faceMetadata$metadat2 === void 0 ? void 0 : _faceMetadata$metadat2.frames) || []).map(function (f) {
97
+ var _f$face_data;
98
+ return (_f$face_data = f.face_data) === null || _f$face_data === void 0 ? void 0 : _f$face_data.face_bbox;
99
+ }).filter(Boolean);
100
+ var averageBox = faceMetadata === null || faceMetadata === void 0 ? void 0 : (_faceMetadata$metadat3 = faceMetadata.metadata) === null || _faceMetadata$metadat3 === void 0 ? void 0 : (_faceMetadata$metadat4 = _faceMetadata$metadat3.averageFaceData) === null || _faceMetadata$metadat4 === void 0 ? void 0 : _faceMetadata$metadat4.face_bbox;
101
+ if (averageBox) rawBoxes.push(averageBox);
102
+ var translation = faceMetadata ? calculateFaceCenteredTranslation({
103
+ faceMetadata: faceMetadata,
104
+ containerWidth: width,
105
+ containerHeight: height,
106
+ currentFrame: 0,
107
+ useAveragePosition: true,
108
+ centerHorizontally: false,
109
+ orientation: orientation
110
+ }) : null;
111
+ var sameSize = (videoProperties === null || videoProperties === void 0 ? void 0 : videoProperties.width) === width && (videoProperties === null || videoProperties === void 0 ? void 0 : videoProperties.height) === height;
112
+ var projection = sameSize ? {
113
+ scale: 1,
114
+ translateX: 0,
115
+ translateY: 0,
116
+ originX: 0,
117
+ originY: 0
118
+ } : translation === null || translation === void 0 ? void 0 : translation.projection;
119
+ var faceRects = projectFaceRects({
120
+ boxes: rawBoxes,
121
+ hasFaceMetadata: (geometry === null || geometry === void 0 ? void 0 : geometry.faceMetadata) != null,
122
+ projection: projection,
123
+ width: width,
124
+ height: height,
125
+ videoZoom: geometry === null || geometry === void 0 ? void 0 : geometry.videoZoom,
126
+ framePadding: geometry === null || geometry === void 0 ? void 0 : geometry.framePadding
127
+ });
128
+ var wordRects = _toConsumableArray(measurementRootRef.current.querySelectorAll("[data-word-index]")).map(function (node) {
129
+ return convert(node.getBoundingClientRect());
130
+ });
131
+ // Measure the active-word envelope of every phrase in this segment so an
132
+ // object that outlives its source phrase also clears subsequent captions.
133
+ var captionTop = Math.min.apply(Math, _toConsumableArray(wordRects.map(function (r) {
134
+ return r.top;
135
+ })));
136
+ var placement = placeCaptionWordObject({
137
+ width: width,
138
+ height: height,
139
+ anchor: anchor,
140
+ captionTop: captionTop,
141
+ faceRects: faceRects
142
+ });
143
+ setMeasurement({
144
+ placement: placement,
145
+ anchor: anchor,
146
+ sourceStyle: window.getComputedStyle(word)
147
+ });
148
+ continueRender(handle);
149
+ };
150
+ Promise.resolve((_document$fonts = document.fonts) === null || _document$fonts === void 0 ? void 0 : _document$fonts.ready).then(measure)["catch"](function () {
151
+ if (!cancelled) setMeasurement({
152
+ placement: null
153
+ });
154
+ continueRender(handle);
155
+ });
156
+ return function () {
157
+ cancelled = true;
158
+ continueRender(handle);
159
+ };
160
+ }, [event, geometry, width, height, orientation, playerScale]);
161
+ var placement = measurement === null || measurement === void 0 ? void 0 : measurement.placement;
162
+ var motion = getWordObjectMotion({
163
+ frame: frame,
164
+ fps: fps,
165
+ durationInFrames: event.durationInFrames,
166
+ assetId: event.punctuation.wordObject.assetId
167
+ });
168
+ var scale = width / 1080;
169
+ var wordX = placement ? placement.startX + (placement.x - placement.startX) * motion.rise : 0;
170
+ var wordY = placement ? placement.startY + (placement.y - placement.startY) * motion.rise : 0;
171
+ return /*#__PURE__*/React.createElement(AbsoluteFill, {
172
+ ref: rootRef,
173
+ style: {
174
+ pointerEvents: "none"
175
+ }
176
+ }, /*#__PURE__*/React.createElement(AbsoluteFill, {
177
+ ref: measurementRootRef,
178
+ style: {
179
+ visibility: "hidden"
180
+ },
181
+ "aria-hidden": "true"
182
+ }, renderSource(event.transcript, event.punctuation.index, event.punctuation.start, lineRef), event.sourceTranscripts.filter(function (transcript) {
183
+ return transcript !== event.transcript;
184
+ }).map(function (transcript, index) {
185
+ var _transcript$punctuati, _transcript$punctuati2, _transcript$punctuati3;
186
+ return /*#__PURE__*/React.createElement(React.Fragment, {
187
+ key: index
188
+ }, renderSource(transcript, 0, (_transcript$punctuati = (_transcript$punctuati2 = transcript.punctuations) === null || _transcript$punctuati2 === void 0 ? void 0 : (_transcript$punctuati3 = _transcript$punctuati2[0]) === null || _transcript$punctuati3 === void 0 ? void 0 : _transcript$punctuati3.start) !== null && _transcript$punctuati !== void 0 ? _transcript$punctuati : transcript.from, {
189
+ current: null
190
+ }));
191
+ })), placement && artwork && !imageFailed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
192
+ "data-word-object-copy": true,
193
+ style: {
194
+ position: "absolute",
195
+ left: wordX,
196
+ top: wordY,
197
+ transform: "translate(-50%, -50%) ".concat(measurement.sourceStyle.transform === "none" ? "" : measurement.sourceStyle.transform),
198
+ opacity: motion.wordOpacity,
199
+ fontFamily: fontFamily,
200
+ fontSize: measurement.sourceStyle.fontSize,
201
+ fontWeight: measurement.sourceStyle.fontWeight,
202
+ lineHeight: measurement.sourceStyle.lineHeight,
203
+ padding: measurement.sourceStyle.padding,
204
+ backgroundColor: measurement.sourceStyle.backgroundColor,
205
+ borderRadius: measurement.sourceStyle.borderRadius,
206
+ textTransform: "uppercase",
207
+ whiteSpace: "nowrap",
208
+ color: color || measurement.sourceStyle.color,
209
+ textShadow: measurement.sourceStyle.textShadow
210
+ }
211
+ }, event.word), /*#__PURE__*/React.createElement(Img, {
212
+ "data-word-object": event.punctuation.wordObject.assetId,
213
+ src: artwork,
214
+ maxRetries: 0,
215
+ onError: function onError() {
216
+ return setImageFailed(true);
217
+ },
218
+ style: {
219
+ position: "absolute",
220
+ left: placement.x,
221
+ top: placement.y + motion.hover * scale,
222
+ width: placement.size,
223
+ height: placement.size,
224
+ objectFit: "contain",
225
+ opacity: motion.opacity,
226
+ transform: "translate(-50%, -50%) rotate(".concat(motion.rotation, "deg) scale(").concat(motion.scale, ")"),
227
+ filter: motion.glow ? "drop-shadow(0 0 ".concat(12 * scale, "px rgba(255,220,90,").concat(motion.glow, "))") : "drop-shadow(0 ".concat(3 * scale, "px ").concat(4 * scale, "px rgba(0,0,0,0.35))")
228
+ }
229
+ })) : null);
230
+ };
231
+ export var CaptionWordObjectOverlay = function CaptionWordObjectOverlay(_ref2) {
232
+ var transcripts = _ref2.transcripts,
233
+ renderSource = _ref2.renderSource,
234
+ geometry = _ref2.geometry,
235
+ fontFamily = _ref2.fontFamily,
236
+ color = _ref2.color;
237
+ var _useVideoConfig2 = useVideoConfig(),
238
+ width = _useVideoConfig2.width,
239
+ height = _useVideoConfig2.height,
240
+ fps = _useVideoConfig2.fps;
241
+ var events = React.useMemo(function () {
242
+ return transcripts.flatMap(function (transcript) {
243
+ return (transcript.punctuations || []).filter(function (p) {
244
+ return isEnabledWordObject(p.wordObject) && !p.__wordObjectSuppressed && !p.__wordObjectOnsetClipped && !p.__wordObjectImageUnavailable && Number.isInteger(p.__wordObjectDurationInFrames) && p.__wordObjectDurationInFrames > 0 && Number.isFinite(p.start);
245
+ }).map(function (punctuation) {
246
+ return {
247
+ transcript: transcript,
248
+ punctuation: punctuation,
249
+ word: transcript.text.split(" ")[punctuation.index],
250
+ durationInFrames: punctuation.__wordObjectDurationInFrames,
251
+ sourceTranscripts: transcripts
252
+ };
253
+ });
254
+ });
255
+ }, [transcripts, fps]);
256
+ if (width > height) return null;
257
+ return /*#__PURE__*/React.createElement(AbsoluteFill, {
258
+ style: {
259
+ zIndex: 20,
260
+ pointerEvents: "none"
261
+ }
262
+ }, events.map(function (event, index) {
263
+ return /*#__PURE__*/React.createElement(Sequence, {
264
+ key: index,
265
+ from: event.punctuation.start,
266
+ durationInFrames: event.durationInFrames
267
+ }, /*#__PURE__*/React.createElement(WordObject, {
268
+ event: event,
269
+ renderSource: renderSource,
270
+ geometry: geometry,
271
+ fontFamily: fontFamily,
272
+ color: color
273
+ }));
274
+ }));
275
+ };
@@ -1,12 +1,16 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1
2
  import React from "react";
2
3
  import { useThemedComponents } from "../../theme/hooks/useThemedComponents.js";
3
4
  import { useVideoConfig } from "remotion";
4
5
  import { useOrientationBased } from "../../hooks/useOrientationBased.js";
5
6
  import { distributeTextToFit } from "../../theme/themes/default/Sentence/SentenceSimple.helpers.js";
6
7
  import { KeyPointOverlayDepth } from "../layouts/KeyPointOverlayDepth";
8
+ import { getHeadingColors } from "../../helpers/headingColors.js";
7
9
  export var Sentence = function Sentence(_ref) {
8
10
  var sentence = _ref.sentence,
9
- theme = _ref.theme;
11
+ theme = _ref.theme,
12
+ headingTextColor = _ref.headingTextColor,
13
+ headingBackgroundColor = _ref.headingBackgroundColor;
10
14
  var Sentence = useThemedComponents("Sentence", theme);
11
15
  var _useVideoConfig = useVideoConfig(),
12
16
  width = _useVideoConfig.width,
@@ -40,11 +44,14 @@ export var Sentence = function Sentence(_ref) {
40
44
  var _distributeTextToFit = distributeTextToFit(sentence, maxWidth - sentencePadding * 2, maxHeight - sentencePadding * 2, maxFontSize),
41
45
  lines = _distributeTextToFit.lines,
42
46
  fontSize = _distributeTextToFit.fontSize;
43
- return /*#__PURE__*/React.createElement(Sentence, {
47
+ return /*#__PURE__*/React.createElement(Sentence, _extends({
44
48
  sentence: sentence,
45
49
  lines: lines,
46
50
  fontSize: fontSize,
47
51
  maxHeight: maxHeight,
48
52
  maxWidth: maxWidth
49
- });
53
+ }, getHeadingColors({
54
+ headingTextColor: headingTextColor,
55
+ headingBackgroundColor: headingBackgroundColor
56
+ })));
50
57
  };
@@ -3,7 +3,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
3
3
  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; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
5
5
  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); }
6
- import { AbsoluteFill, Audio, Easing, Img, interpolate, OffthreadVideo, staticFile, useCurrentFrame, useVideoConfig } from "remotion";
6
+ import { AbsoluteFill, Audio, Easing, Img, interpolate, OffthreadVideo, useCurrentFrame, useVideoConfig } from "remotion";
7
7
  import { FONT_FAMILIES } from "../../fontRegistry.js";
8
8
  import React from "react";
9
9
  import { useOrientationBased } from "../../hooks/useOrientationBased.js";
@@ -50,11 +50,9 @@ var Logo = function Logo(_ref) {
50
50
  var Word = function Word(_ref2) {
51
51
  var word = _ref2.word,
52
52
  index = _ref2.index;
53
- var _React$useMemo = React.useMemo(function () {
54
- return distributeTextToFit(word, 300, 120, 50);
55
- }, [word]),
56
- fontSize = _React$useMemo.fontSize,
57
- lines = _React$useMemo.lines;
53
+ var _distributeTextToFit = distributeTextToFit(word, 300, 120, 50),
54
+ fontSize = _distributeTextToFit.fontSize,
55
+ lines = _distributeTextToFit.lines;
58
56
  var frame = useCurrentFrame();
59
57
  var timings = [0, 90];
60
58
  var options = {};
@@ -357,7 +355,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
357
355
  height: "100%",
358
356
  mixBlendMode: "screen"
359
357
  },
360
- src: staticFile("plexus1-1080.mp4"),
358
+ src: "https://storage.googleapis.com/zync-media/assets/static/plexus1.mov",
361
359
  startFrom: 120
362
360
  }), /*#__PURE__*/React.createElement(RotatingWordsContainer, {
363
361
  words: words
@@ -438,7 +436,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
438
436
  height: "100%",
439
437
  mixBlendMode: "screen"
440
438
  },
441
- src: staticFile("plexus1-1080.mp4"),
439
+ src: "https://storage.googleapis.com/zync-media/assets/static/plexus1.mov",
442
440
  startFrom: 120
443
441
  }), /*#__PURE__*/React.createElement(RotatingWordsContainer, {
444
442
  words: words
@@ -498,7 +496,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
498
496
  height: "100%",
499
497
  mixBlendMode: "screen"
500
498
  },
501
- src: staticFile("plexus1-1080.mp4"),
499
+ src: "https://storage.googleapis.com/zync-media/assets/static/plexus1.mov",
502
500
  startFrom: 120
503
501
  }), /*#__PURE__*/React.createElement(RotatingWordsContainer, {
504
502
  words: words
@@ -5,7 +5,7 @@ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Sym
5
5
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
6
  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; }
7
7
  import React from "react";
8
- import { AbsoluteFill, Audio, OffthreadVideo, staticFile, useCurrentFrame, useVideoConfig, spring, interpolate, Easing } from "remotion";
8
+ import { AbsoluteFill, Audio, OffthreadVideo, useCurrentFrame, useVideoConfig, spring, interpolate, Easing } from "remotion";
9
9
  import { FONT_FAMILIES } from "../../fontRegistry.js";
10
10
  import { useOrientationBased } from "../../hooks/useOrientationBased.js";
11
11
  import { CHROME_PADDING } from "../../config.js";
@@ -67,11 +67,9 @@ var Word = function Word(_ref2) {
67
67
  maxWidth = _ref3.maxWidth,
68
68
  maxHeight = _ref3.maxHeight,
69
69
  maxFontSize = _ref3.maxFontSize;
70
- var _React$useMemo = React.useMemo(function () {
71
- return distributeTextToFit(word, maxWidth !== null && maxWidth !== void 0 ? maxWidth : 350, maxHeight !== null && maxHeight !== void 0 ? maxHeight : 120, maxFontSize !== null && maxFontSize !== void 0 ? maxFontSize : 54);
72
- }, [word, maxWidth, maxHeight, maxFontSize]),
73
- lines = _React$useMemo.lines,
74
- fontSize = _React$useMemo.fontSize;
70
+ var _distributeTextToFit = distributeTextToFit(word, maxWidth !== null && maxWidth !== void 0 ? maxWidth : 350, maxHeight !== null && maxHeight !== void 0 ? maxHeight : 120, maxFontSize !== null && maxFontSize !== void 0 ? maxFontSize : 54),
71
+ lines = _distributeTextToFit.lines,
72
+ fontSize = _distributeTextToFit.fontSize;
75
73
  var frame = useCurrentFrame();
76
74
  var _useVideoConfig = useVideoConfig(),
77
75
  fps = _useVideoConfig.fps;
@@ -546,7 +544,7 @@ var BackdropFrame = function BackdropFrame(_ref5) {
546
544
  mixBlendMode: "screen",
547
545
  opacity: 0.35 // softer integration
548
546
  },
549
- src: staticFile("plexus1-1080.mp4"),
547
+ src: "https://storage.googleapis.com/zync-media/assets/static/plexus1.mov",
550
548
  startFrom: 120,
551
549
  muted: true
552
550
  }), /*#__PURE__*/React.createElement(RotatingWordsContainer, {
@@ -12,6 +12,8 @@ export var SimpleFrameSentence = function SimpleFrameSentence(props) {
12
12
  }
13
13
  return /*#__PURE__*/React.createElement(SimpleFrame, props, /*#__PURE__*/React.createElement(Sentence, {
14
14
  theme: props.theme,
15
- sentence: props.sentenceText
15
+ sentence: props.sentenceText,
16
+ headingTextColor: props.headingTextColor,
17
+ headingBackgroundColor: props.headingBackgroundColor
16
18
  }), props.children);
17
19
  };
@@ -194,6 +194,14 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
194
194
  return {
195
195
  transform: transform,
196
196
  transformOrigin: transformOrigin,
197
+ // Exact numeric projection for overlays sharing this video's coordinate system.
198
+ projection: {
199
+ scale: scale,
200
+ translateX: (finalTranslateX + horizontalOffset) * scale,
201
+ translateY: finalTranslateY * scale,
202
+ originX: faceX,
203
+ originY: anchorToBottom ? sourceHeight : faceY
204
+ },
197
205
  debugInfo: {
198
206
  frameIndex: useAveragePosition ? "AVERAGE" : frameIndex,
199
207
  relativeFaceX: relativeFaceX.toFixed(3),
@@ -569,4 +577,5 @@ export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
569
577
  }
570
578
  }, "Error: ", debugInfo.error)));
571
579
  };
580
+ export { calculateFaceCenteredTranslation };
572
581
  export default FaceCenteredVideo;
@@ -0,0 +1,143 @@
1
+ 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; } } }; }
2
+ 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; } }
3
+ 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; }
4
+ var intersects = function intersects(a, b) {
5
+ return a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
6
+ };
7
+ export var projectFaceRects = function projectFaceRects(_ref) {
8
+ var boxes = _ref.boxes,
9
+ projection = _ref.projection,
10
+ width = _ref.width,
11
+ height = _ref.height,
12
+ _ref$hasFaceMetadata = _ref.hasFaceMetadata,
13
+ hasFaceMetadata = _ref$hasFaceMetadata === void 0 ? false : _ref$hasFaceMetadata,
14
+ _ref$videoZoom = _ref.videoZoom,
15
+ videoZoom = _ref$videoZoom === void 0 ? 1 : _ref$videoZoom,
16
+ _ref$framePadding = _ref.framePadding,
17
+ framePadding = _ref$framePadding === void 0 ? 0 : _ref$framePadding;
18
+ // Missing face metadata must not hide otherwise valid caption objects.
19
+ if (!(boxes !== null && boxes !== void 0 && boxes.length) && !hasFaceMetadata) return [];
20
+ if (!projection || !(boxes !== null && boxes !== void 0 && boxes.length) || ![projection.scale, projection.translateX, projection.translateY, projection.originX, projection.originY, videoZoom, framePadding].every(Number.isFinite) || projection.scale <= 0) return [{
21
+ left: 0,
22
+ top: 0,
23
+ right: width,
24
+ bottom: height * 2 / 3
25
+ }];
26
+ var scale = projection.scale,
27
+ translateX = projection.translateX,
28
+ translateY = projection.translateY,
29
+ originX = projection.originX,
30
+ originY = projection.originY;
31
+ var rects = [];
32
+ var _iterator = _createForOfIteratorHelper(boxes),
33
+ _step;
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ var box = _step.value;
37
+ if (!Array.isArray(box) || box.length < 4 || !box.every(Number.isFinite) || box[2] <= 0 || box[3] <= 0) continue;
38
+ // Union across the video's full zoom ramp; metadata coordinates use the same
39
+ // transform origin and translation as FaceCenteredVideo.
40
+ for (var _i = 0, _arr = [1, Math.max(1, videoZoom)]; _i < _arr.length; _i++) {
41
+ var zoom = _arr[_i];
42
+ var x = originX + (box[0] - originX) * scale + translateX;
43
+ var y = originY + (box[1] - originY) * scale + translateY;
44
+ var padding = 24 * width / 1080 + framePadding;
45
+ rects.push({
46
+ left: width / 2 + (x - width / 2) * zoom - padding,
47
+ top: height / 2 + (y - height / 2) * zoom - padding,
48
+ right: width / 2 + (x + box[2] * scale - width / 2) * zoom + padding,
49
+ bottom: height / 2 + (y + box[3] * scale - height / 2) * zoom + padding
50
+ });
51
+ }
52
+ }
53
+ } catch (err) {
54
+ _iterator.e(err);
55
+ } finally {
56
+ _iterator.f();
57
+ }
58
+ return rects.length ? rects : [{
59
+ left: 0,
60
+ top: 0,
61
+ right: width,
62
+ bottom: height * 2 / 3
63
+ }];
64
+ };
65
+ export var placeCaptionWordObject = function placeCaptionWordObject(_ref2) {
66
+ var width = _ref2.width,
67
+ height = _ref2.height,
68
+ anchor = _ref2.anchor,
69
+ captionTop = _ref2.captionTop,
70
+ faceRects = _ref2.faceRects;
71
+ var scale = width / 1080;
72
+ var gap = 24 * scale;
73
+ var leftLimit = width * 0.06;
74
+ var rightLimit = width * 0.85;
75
+ var startX = (anchor.left + anchor.right) / 2;
76
+ var startY = (anchor.top + anchor.bottom) / 2;
77
+ if (![width, height, captionTop, startX, startY].every(Number.isFinite)) return null;
78
+ var protectedRects = faceRects || [];
79
+ var _loop = function _loop() {
80
+ // Includes rotation, entry overshoot, hover and shadow.
81
+ var halfEnvelope = size * 0.62 + 12 * scale;
82
+ var x = Math.max(leftLimit + halfEnvelope, Math.min(rightLimit - halfEnvelope, startX));
83
+ var y = captionTop - gap - halfEnvelope;
84
+ var envelope = {
85
+ left: x - halfEnvelope,
86
+ top: y - halfEnvelope,
87
+ right: x + halfEnvelope,
88
+ bottom: y + halfEnvelope
89
+ };
90
+ var wordFlight = {
91
+ left: Math.min(anchor.left, x - size / 2),
92
+ right: Math.max(anchor.right, x + size / 2),
93
+ top: Math.min(anchor.top, y - size / 2),
94
+ bottom: Math.max(anchor.bottom, y + size / 2)
95
+ };
96
+ if (envelope.top < 0 || envelope.bottom > height || envelope.left < leftLimit || envelope.right > rightLimit || protectedRects.some(function (face) {
97
+ return intersects(envelope, face) || intersects(wordFlight, face);
98
+ })) return 0; // continue
99
+ return {
100
+ v: {
101
+ x: x,
102
+ y: y,
103
+ size: size,
104
+ startX: startX,
105
+ startY: startY,
106
+ envelope: envelope
107
+ }
108
+ };
109
+ },
110
+ _ret;
111
+ for (var size = 128 * scale; size >= 80 * scale - 0.01; size -= 8 * scale) {
112
+ _ret = _loop();
113
+ if (_ret === 0) continue;
114
+ if (_ret) return _ret.v;
115
+ }
116
+ return null;
117
+ };
118
+ export var getWordObjectMotion = function getWordObjectMotion(_ref3) {
119
+ var frame = _ref3.frame,
120
+ fps = _ref3.fps,
121
+ durationInFrames = _ref3.durationInFrames,
122
+ assetId = _ref3.assetId;
123
+ var motionAsset = {
124
+ "fluent3d_v1:2708-fe0f": "plane",
125
+ "fluent3d_v1:23f0": "clock",
126
+ "fluent3d_v1:1f4a1": "light_bulb"
127
+ }[assetId] || assetId;
128
+ var seconds = frame / fps;
129
+ var rise = Math.max(0, Math.min(1, seconds / 0.35));
130
+ var easedRise = 1 - Math.pow(1 - rise, 3);
131
+ var exit = Math.max(0, Math.min(1, (durationInFrames - frame) / (0.3 * fps)));
132
+ var opacity = Math.min(1, Math.max(0, (seconds - 0.05) / 0.3)) * exit;
133
+ var hoverStrength = Math.max(0, Math.min(1, (seconds - 0.35) / 0.15));
134
+ return {
135
+ rise: easedRise,
136
+ wordOpacity: 1 - rise,
137
+ opacity: opacity,
138
+ scale: (0.55 + 0.45 * rise + Math.sin(Math.PI * rise) * 0.12) * (0.8 + 0.2 * exit),
139
+ hover: Math.sin(seconds * 3) * 6 * hoverStrength,
140
+ rotation: Math.sin(seconds * 2.5) * (motionAsset === "plane" ? 6 : motionAsset === "clock" ? 5 : 3) * hoverStrength,
141
+ glow: motionAsset === "light_bulb" ? (0.5 + Math.sin(seconds * 4) * 0.2) * opacity : 0
142
+ };
143
+ };