@zync/zync-screnplay-player 0.1.237 → 0.1.238

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.
@@ -0,0 +1,249 @@
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 _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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
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
+ import React from "react";
8
+ import { AbsoluteFill, Audio, Easing, interpolate, OffthreadVideo, useCurrentFrame, useVideoConfig } from "remotion";
9
+ import { loadFont } from "@remotion/google-fonts/Poppins";
10
+ var _loadFont = loadFont("normal", {
11
+ subsets: ["latin"],
12
+ weights: ["900"]
13
+ }),
14
+ fontFamily = _loadFont.fontFamily;
15
+ var TEXT_COLOR = "#0a3567";
16
+ var BACKGROUND_COLORS = ["#fff200", "#22f3d0", "#ff8a00", "#ff78a8", "#b9ff4a", "#f7f7f2"];
17
+ var HORIZONTAL_SAFE_AREA = 0.86;
18
+ var VERTICAL_SAFE_AREA = 0.5;
19
+ var BACKGROUND_WIPE_FRAMES = 7;
20
+ var WORD_STEP_FRAMES = 18;
21
+ var splitWords = function splitWords() {
22
+ var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
23
+ return String(text).trim().split(/\s+/).filter(Boolean);
24
+ };
25
+ var estimateWordWidth = function estimateWordWidth(word, fontSize) {
26
+ var wideCharacters = (word.match(/[mw@#%&]/gi) || []).length;
27
+ var narrowCharacters = (word.match(/[ijl1!.,'\u2019]/gi) || []).length;
28
+ var normalCharacters = Math.max(0, word.length - wideCharacters - narrowCharacters);
29
+ return fontSize * (wideCharacters * 0.9 + normalCharacters * 0.68 + narrowCharacters * 0.32);
30
+ };
31
+ var estimateWrappedTextSize = function estimateWrappedTextSize(_ref) {
32
+ var text = _ref.text,
33
+ fontSize = _ref.fontSize,
34
+ maxWidth = _ref.maxWidth;
35
+ var words = splitWords(text);
36
+ var spaceWidth = fontSize * 0.32;
37
+ var lines = words.reduce(function (acc, word) {
38
+ var wordWidth = estimateWordWidth(word, fontSize);
39
+ var currentLine = acc[acc.length - 1];
40
+ var nextWidth = currentLine.width === 0 ? wordWidth : currentLine.width + spaceWidth + wordWidth;
41
+ if (currentLine.width > 0 && nextWidth > maxWidth) {
42
+ acc.push({
43
+ width: wordWidth
44
+ });
45
+ return acc;
46
+ }
47
+ currentLine.width = nextWidth;
48
+ return acc;
49
+ }, [{
50
+ width: 0
51
+ }]);
52
+ return {
53
+ height: lines.length * fontSize * 0.95,
54
+ width: Math.max.apply(Math, _toConsumableArray(lines.map(function (line) {
55
+ return line.width;
56
+ })))
57
+ };
58
+ };
59
+ var getFontSizeForFullText = function getFontSizeForFullText(_ref2) {
60
+ var text = _ref2.text,
61
+ baseFontSize = _ref2.baseFontSize,
62
+ width = _ref2.width,
63
+ height = _ref2.height;
64
+ var maxWidth = width * HORIZONTAL_SAFE_AREA;
65
+ var maxHeight = height * VERTICAL_SAFE_AREA;
66
+ var min = 12;
67
+ var max = baseFontSize;
68
+ for (var i = 0; i < 12; i++) {
69
+ var candidate = (min + max) / 2;
70
+ var size = estimateWrappedTextSize({
71
+ text: text,
72
+ fontSize: candidate,
73
+ maxWidth: maxWidth
74
+ });
75
+ if (size.width <= maxWidth && size.height <= maxHeight) {
76
+ min = candidate;
77
+ } else {
78
+ max = candidate;
79
+ }
80
+ }
81
+ return Math.floor(min);
82
+ };
83
+ var getBackgroundColor = function getBackgroundColor(index) {
84
+ return BACKGROUND_COLORS[index % BACKGROUND_COLORS.length];
85
+ };
86
+ var PositionedWords = function PositionedWords(_ref3) {
87
+ var fontSize = _ref3.fontSize,
88
+ frame = _ref3.frame,
89
+ staticUntilIndex = _ref3.staticUntilIndex,
90
+ visibleUntilIndex = _ref3.visibleUntilIndex,
91
+ width = _ref3.width,
92
+ words = _ref3.words;
93
+ return /*#__PURE__*/React.createElement(AbsoluteFill, {
94
+ style: {
95
+ alignItems: "center",
96
+ display: "flex",
97
+ justifyContent: "center"
98
+ }
99
+ }, /*#__PURE__*/React.createElement("div", {
100
+ style: {
101
+ columnGap: fontSize * 0.32,
102
+ display: "flex",
103
+ flexWrap: "wrap",
104
+ justifyContent: "center",
105
+ lineHeight: 0.95,
106
+ maxWidth: "".concat(HORIZONTAL_SAFE_AREA * 100, "%"),
107
+ rowGap: fontSize * 0.06
108
+ }
109
+ }, words.map(function (word, index) {
110
+ if (index > visibleUntilIndex) {
111
+ return /*#__PURE__*/React.createElement("span", {
112
+ key: "".concat(word, "-").concat(index),
113
+ style: {
114
+ fontFamily: fontFamily,
115
+ fontSize: fontSize,
116
+ fontWeight: 900,
117
+ visibility: "hidden",
118
+ whiteSpace: "nowrap"
119
+ }
120
+ }, word);
121
+ }
122
+ var shouldAnimate = index > staticUntilIndex;
123
+ var wordFrame = frame - index * WORD_STEP_FRAMES;
124
+ var progress = shouldAnimate ? interpolate(wordFrame, [0, BACKGROUND_WIPE_FRAMES + 5], [0, 1], {
125
+ easing: Easing.out(Easing.cubic),
126
+ extrapolateLeft: "clamp",
127
+ extrapolateRight: "clamp"
128
+ }) : 1;
129
+ var startTranslateX = width;
130
+ var translateX = shouldAnimate ? interpolate(progress, [0, 1], [startTranslateX, 0], {
131
+ extrapolateLeft: "clamp",
132
+ extrapolateRight: "clamp"
133
+ }) : 0;
134
+ var opacity = shouldAnimate ? interpolate(progress, [0, 0.2, 1], [0, 1, 1], {
135
+ extrapolateLeft: "clamp",
136
+ extrapolateRight: "clamp"
137
+ }) : 1;
138
+ return /*#__PURE__*/React.createElement("span", {
139
+ key: "".concat(word, "-").concat(index),
140
+ style: {
141
+ color: TEXT_COLOR,
142
+ fontFamily: fontFamily,
143
+ fontSize: fontSize,
144
+ fontWeight: 900,
145
+ lineHeight: 0.95,
146
+ opacity: opacity,
147
+ transform: "translateX(".concat(translateX, "px)"),
148
+ whiteSpace: "nowrap",
149
+ willChange: "opacity, transform"
150
+ }
151
+ }, word);
152
+ })));
153
+ };
154
+ export var TextFullCover = function TextFullCover(_ref4) {
155
+ var text = _ref4.text,
156
+ children = _ref4.children,
157
+ muted = _ref4.muted,
158
+ _ref4$startVideoFrom = _ref4.startVideoFrom,
159
+ startVideoFrom = _ref4$startVideoFrom === void 0 ? 0 : _ref4$startVideoFrom,
160
+ videoUrl = _ref4.videoUrl,
161
+ _ref4$videoZoom = _ref4.videoZoom,
162
+ videoZoom = _ref4$videoZoom === void 0 ? 1 : _ref4$videoZoom,
163
+ _ref4$disableTransiti = _ref4.disableTransitionSounds,
164
+ disableTransitionSounds = _ref4$disableTransiti === void 0 ? false : _ref4$disableTransiti;
165
+ var frame = useCurrentFrame();
166
+ var _useVideoConfig = useVideoConfig(),
167
+ width = _useVideoConfig.width,
168
+ height = _useVideoConfig.height;
169
+ var words = splitWords(text);
170
+ var fallbackWords = words.length ? words : [""];
171
+ var uppercaseWords = fallbackWords.map(function (word) {
172
+ return word.toLocaleUpperCase();
173
+ });
174
+ var lastStepIndex = fallbackWords.length - 1;
175
+ var stepIndex = Math.min(lastStepIndex, Math.floor(frame / WORD_STEP_FRAMES));
176
+ var previousStepIndex = Math.max(0, stepIndex - 1);
177
+ var frameInWord = frame - stepIndex * WORD_STEP_FRAMES;
178
+ var currentBackgroundColor = getBackgroundColor(stepIndex);
179
+ var previousBackgroundColor = getBackgroundColor(Math.max(0, stepIndex - 1));
180
+ var shouldWipe = stepIndex > 0 && frameInWord < BACKGROUND_WIPE_FRAMES;
181
+ var wipeProgress = shouldWipe ? interpolate(frameInWord, [0, BACKGROUND_WIPE_FRAMES], [0, 1], {
182
+ easing: Easing.out(Easing.cubic),
183
+ extrapolateLeft: "clamp",
184
+ extrapolateRight: "clamp"
185
+ }) : 1;
186
+ var currentClipPath = "inset(0 0 0 ".concat((1 - wipeProgress) * 100, "%)");
187
+ var baseFontSize = Math.floor(Math.min(width * 0.2, height * 0.32));
188
+ var fontSize = getFontSizeForFullText({
189
+ text: uppercaseWords.join(" "),
190
+ baseFontSize: baseFontSize,
191
+ width: width,
192
+ height: height
193
+ });
194
+ return /*#__PURE__*/React.createElement(AbsoluteFill, {
195
+ style: {
196
+ alignItems: "center",
197
+ backgroundColor: shouldWipe ? previousBackgroundColor : currentBackgroundColor,
198
+ display: "flex",
199
+ justifyContent: "center",
200
+ overflow: "hidden"
201
+ }
202
+ }, videoUrl ? /*#__PURE__*/React.createElement(AbsoluteFill, {
203
+ style: {
204
+ zIndex: 0
205
+ }
206
+ }, /*#__PURE__*/React.createElement(OffthreadVideo, {
207
+ src: videoUrl,
208
+ startFrom: startVideoFrom,
209
+ muted: muted,
210
+ style: {
211
+ height: "100%",
212
+ objectFit: "cover",
213
+ opacity: 0,
214
+ transform: "scale(".concat(videoZoom, ")"),
215
+ width: "100%"
216
+ }
217
+ })) : null, shouldWipe ? /*#__PURE__*/React.createElement(PositionedWords, {
218
+ fontSize: fontSize,
219
+ frame: frame,
220
+ staticUntilIndex: previousStepIndex,
221
+ visibleUntilIndex: previousStepIndex,
222
+ width: width,
223
+ words: uppercaseWords
224
+ }) : null, /*#__PURE__*/React.createElement(AbsoluteFill, {
225
+ style: {
226
+ alignItems: "center",
227
+ backgroundColor: currentBackgroundColor,
228
+ clipPath: currentClipPath,
229
+ display: "flex",
230
+ justifyContent: "center",
231
+ overflow: "hidden",
232
+ zIndex: 1
233
+ }
234
+ }, /*#__PURE__*/React.createElement(PositionedWords, {
235
+ fontSize: fontSize,
236
+ frame: frame,
237
+ staticUntilIndex: previousStepIndex,
238
+ visibleUntilIndex: stepIndex,
239
+ width: width,
240
+ words: uppercaseWords
241
+ })), !disableTransitionSounds && /*#__PURE__*/React.createElement(Audio, {
242
+ src: "https://cdn.zync.ai/assets/static/swoosh.mp3",
243
+ volume: 0.18
244
+ }), /*#__PURE__*/React.createElement(AbsoluteFill, {
245
+ style: {
246
+ zIndex: 10
247
+ }
248
+ }, children));
249
+ };
@@ -1078,7 +1078,7 @@ var renderer = new RemotionRenderer({
1078
1078
  }, {
1079
1079
  recordingIndex: 2,
1080
1080
  layout: {
1081
- type: "text_with_video",
1081
+ type: "text_full_cover",
1082
1082
  data: {
1083
1083
  noBackgroundVideoEffects: {
1084
1084
  facePop: false,
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { SimpleFrameLayout } from "./SimpleFrameLayout.js";
8
8
  import { Layout } from "./DefaultLayout.js";
9
9
  import { TextWithVideoLayout } from "./TextWithVideoLayout.js";
10
+ import { TextFullCoverLayout } from "./TextFullCoverLayout.js";
10
11
  import { HandoffLayout } from "./HandoffLayout.js";
11
12
  import { CreatorCollabSplitLayout } from "./CreatorCollabSplitLayout.js";
12
13
  import { CreatorCollabColdOpenLayout } from "./CreatorCollabColdOpenLayout.js";
@@ -35,6 +36,11 @@ export var LayoutFactory = /*#__PURE__*/function () {
35
36
  layout = new TextWithVideoLayout(props).flatten();
36
37
  break;
37
38
  }
39
+ case "text_full_cover":
40
+ {
41
+ layout = new TextFullCoverLayout(props).flatten();
42
+ break;
43
+ }
38
44
  case "broll_background":
39
45
  case "simple_frame_broll":
40
46
  case "simple_frame_sentence":
@@ -0,0 +1,22 @@
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 _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); } }
3
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
+ import { TextWithVideoLayout } from "./TextWithVideoLayout.js";
15
+ export var TextFullCoverLayout = /*#__PURE__*/function (_TextWithVideoLayout) {
16
+ function TextFullCoverLayout() {
17
+ _classCallCheck(this, TextFullCoverLayout);
18
+ return _callSuper(this, TextFullCoverLayout, arguments);
19
+ }
20
+ _inherits(TextFullCoverLayout, _TextWithVideoLayout);
21
+ return _createClass(TextFullCoverLayout);
22
+ }(TextWithVideoLayout);
@@ -1,5 +1,6 @@
1
1
  import { SimpleFrame } from "./components/layouts/SimpleFrame";
2
2
  import { TextWithVideo } from "./components/layouts/TextWithVideo";
3
+ import { TextFullCover } from "./components/layouts/TextFullCover";
3
4
  import { BrollFullscreen } from "./components/effects/BrollFullscreen";
4
5
  import { PhraseRainbowEffect } from "./components/effects/PhraseRainbowEffect";
5
6
  import { Sentence } from "./components/effects/Sentence";
@@ -48,8 +49,8 @@ import { HookVideo } from "./components/layouts/HookVideo";
48
49
  import { BrollInset } from "./components/layouts/BrollInset";
49
50
  import { MotionStillInset } from "./components/layouts/MotionStillInset";
50
51
 
51
- /** Update this so that Remotion knows which component to render when it is passed via screenplay. Ex. "title" will have rendered "Title" component
52
- * Here we are mapping directly types and component names. Types are snake_case and components PascalCase.
52
+ /** Update this so that Remotion knows which component to render when it is passed via screenplay. Ex. "title" will have rendered "Title" component
53
+ * Here we are mapping directly types and component names. Types are snake_case and components PascalCase.
53
54
  * */
54
55
  export var RegisteredComponents = {
55
56
  // Layouts
@@ -58,6 +59,7 @@ export var RegisteredComponents = {
58
59
  SimpleFrameSentence: SimpleFrameSentence,
59
60
  SimpleFrameZoomCut: SimpleFrameZoomCut,
60
61
  TextWithVideo: TextWithVideo,
62
+ TextFullCover: TextFullCover,
61
63
  Handoff: Handoff,
62
64
  MultiHandoff: MultiHandoff,
63
65
  CreatorCollabSplit: CreatorCollabSplit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zync/zync-screnplay-player",
3
- "version": "0.1.237",
3
+ "version": "0.1.238",
4
4
  "files": [
5
5
  "dist"
6
6
  ],